DEV Community

CTFDojo
CTFDojo

Posted on Originally published at ctfdojo.com

PicoCTF logon Writeup — Become Admin by Editing a Cookie

Log in with any username and password. The server sets a cookie admin=False; change it to True in DevTools and reload — the flag appears.

  • Platform: picoGym
  • Verified against: thomasbui's picoCTF 2019 writeup
  • Category: Web Exploitation
  • Difficulty: Beginner
  • Tools: Browser DevToolscurl

Challenge description

The site belongs to a company that "doesn't seem to care about security". The login works for any name except Joe, but a normal user is told there's no flag for them.

Provided: a link to a login page

Step 1 — Log in with anything

Enter any username and password (avoid Joe, which is rejected). You get in, but the page says there's no flag for you.

If a login accepts arbitrary credentials, the decision about what you can see must be made somewhere else — usually a cookie.

Step 2 — Inspect the cookies

Open DevTools (F12) → Application (Chrome) or Storage (Firefox) → Cookies. Alongside your username and password, there's one more:

admin    False
Enter fullscreen mode Exit fullscreen mode

The server stores your authorization level on the client, in plain text, with no signature.

Step 3 — Flip it to True

Double-click the value, change it to True, and reload the page. The flag is shown.

From the command line, send the cookie yourself:

$ curl -b 'admin=True' http://CHALLENGE/flag
Enter fullscreen mode Exit fullscreen mode

🚩 picoCTF{ flag intentionally hidden }

The flag is deliberately hidden — follow the method, you've earned it. 💪

Key takeaways

Anything stored on the client can be changed by the client:

  • Cookies are user input — a server must never trust them for authorization
  • DevTools lets you read and edit cookies directly
  • Signed or server-side sessions are the fix for this class of bug

Originally published on CTFdojo — join the CTFdojo Discord to discuss writeups and get notified about new ones.

Top comments (0)