Cookie Monster's Jar unsigned base64 JSON session cookie

web
flag L3m0n{ea00ae29b665dcc28b7168e55291c133}

A 75-point beginner lesson. The lab greets you by name and tells you what it thinks you are. Everything it knows about you travels in exactly one cookie, and that cookie is base64-encoded JSON with a role field the server trusts with zero verification.

Hint

The page literally says "the bouncer reads the label you carry." Labels can be rewritten.

Reading the label

output
set-cookie: jar_session=eyJ1c2VyIjoidmlzaXRvciIsInJvbGUiOiJndWVzdCJ9; Path=/; SameSite=Lax

No HttpOnly, no signature, no MAC. The value starts with eyJ (base64 for {"), so it's base64 JSON through and through:

json
1{"user":"visitor","role":"guest"}

Rewriting it

python
1import base64, json
2c = {"user": "visitor", "role": "admin"}
3print(base64.b64encode(json.dumps(c, separators=(",", ":")).encode()).decode())
4# eyJ1c2VyIjoidmlzaXRvciIsInJvbGUiOiJhZG1pbiJ9

Send it back as the cookie and the jar pops: "ME LOVE ADMINS! OM NOM NOM!" followed by the flag.

Pitfall

Two things nearly fooled me on this one, and they're worth the 30 seconds to read:

My terminal truncated the cookie. The Set-Cookie header printed as jar_session=eyJ1c2...dCJ9, elided by my own terminal, not the server. I mistook that for the server literally setting a placeholder and started guessing JSON shapes (user vs username, etc). Every guess that happened to include "role":"admin" opened the jar - which proved nothing, since role is the only field the server reads. Just decode the real header.

My flag detector matched the wrong thing. Checking for success with 'L3m0n{' in html also matches the page's own footer, <div>Flag format: L3m0n{32 hex characters}</div> - present on every page, authenticated or not. That made it briefly look like the flag was unauthenticated static content. Matching the real shape, L3m0n\{[0-9a-f]{32}\}, drops the footer and leaves exactly one hit, on the admin page only.

Note

Control check: the identical request with "role":"guest" still in the cookie renders the "Me sorry" greeting and no flag - confirming the gate really is keyed on the tampered field, not open to everyone.