Platform: HackerDNA Challenge: Hack the Cookie Category: Web Difficulty: Easy
Overview
The challenge involves escalating privileges from a guest user to admin by exploiting insecure cookie handling. No signatures. No encryption. Just vibes.
Tools: Burp Suite, FoxyProxy, any Base64 decoder
Step 1 — Login as Guest
Credentials given: guest:guest
Log in, land on the dashboard. Application shows "low privileges" for the guest role. Something to escalate.
Step 2 — Intercept the Cookie
Route traffic through Burp Suite. After login, inspect the response headers. There's a cookie:
Looks like Base64.
Step 3 — Decode It
Output:
Session data stored client-side. No HMAC. No signature. The role is just a field in a JSON blob.
Step 4 — Modify and Re-encode
Change "role": "guest" to "role": "admin":
Encode back to Base64:
Step 5 — Inject and Forward
In Burp, replace the user_session cookie value with the modified one. Forward the request.
Application accepts it without question. Admin panel loads. Flag captured.
Why It Works
The server trusted the cookie value entirely — never validated it server-side, never signed it. Base64 is encoding, not encryption. Anyone can decode it, modify it, re-encode it.
The vulnerability: client-side session data with no integrity protection.
The Fix
- Never store sensitive data client-side without cryptographic protection
- Use signed cookies (JWT with proper signatures, or HMAC-protected values)
- Implement server-side session management — store session data on the server, only send a session ID to the client
- Validate roles server-side on every privileged action, never trust client input for authorization decisions
Remember: Base64 is not security. It's just encoding.
0xAdham
