Session and Cookie Manipulation
What you'll learn: How attackers modify session data and cookies to gain unauthorized privileges and bypass access controls.
The Core Idea
Sessions and cookies store information about who you are and what you're allowed to do in a web application. When this data isn't properly protected, attackers can tamper with it to elevate their privileges—turning a regular user account into an admin account, for example.
Think of it like a backstage pass at a concert. If the pass is just a piece of paper that says "VIP" in marker, someone could easily erase it and write "ALL ACCESS" instead. That's essentially what happens when applications trust client-side data without verification.
Common Manipulation Techniques
Cookie Tampering: Attackers modify cookie values to change their role or permissions. For example, changing role=user to role=admin in a cookie that isn't cryptographically signed.
Session ID Prediction: If session identifiers follow predictable patterns, attackers can guess valid session IDs belonging to privileged users and hijack their sessions.
Session Fixation: An attacker forces a victim to use a known session ID, then uses that same ID after the victim authenticates, inheriting their privileges.
Client-Side Session Data: Some applications store session data entirely in cookies (like JWTs without signatures or weakly signed tokens). Modifying claims like isAdmin=false to isAdmin=true grants unauthorized access.
Why This Works
Applications fail when they:
- Trust data from the client without server-side validation
- Don't cryptographically sign or encrypt sensitive session data
- Fail to regenerate session IDs after authentication or privilege changes
- Store authorization decisions in cookies instead of server-side sessions
Key Takeaway: Never trust client-controlled data like cookies and session values for authorization decisions—always validate privileges server-side and use cryptographically secure, tamper-proof session mechanisms.