Password Reset Lab: Guess the Reset Token and Take the Admin Account

✨ AI Summary
OldMail emails you a password-reset link with a token. The trouble is the token is not random at all — it is the user's id and the current time, base64-encoded. Anything you can predict, you can forge, and the admin's id is 1.
Lab at a glance: Intermediate · 90 XP · about 15 minutes · runs in your browser, no signup or setup. Try it yourself first; the full solution is behind a spoiler below.

What this lab teaches

A password-reset token is a temporary secret that proves the person following the link is the one who asked for the reset. If the token is predictable — derived from an id, a timestamp, a counter or a weak hash — an attacker can generate a valid one for any account and reset its password.

The lesson: a reset token must be unguessable, which means a large amount of cryptographically random data, and it must be single-use.

How OldMail builds its reset token

OldMail takes the user's id and the current timestamp, joins them and base64-encodes the result to make the token. Base64 is encoding, not encryption — it hides nothing. If you know roughly when the reset happened and the target's id, you can rebuild the exact token.

The attack approach

  • Request a reset for your own account and decode the token to see how it is built.
  • Notice it is just your id and a timestamp, base64-encoded — no secret, no randomness.
  • Rebuild the token for user id 1 (admin) using a timestamp around the moment you trigger the reset.
  • Use the forged token to set a new admin password and log in.

Full walkthrough (spoiler)

If your forged token is rejected, the timestamp is slightly off — open the steps.

Show the step-by-step solution
  1. Trigger a reset for your own account and base64-decode the token to reveal the id + timestamp pattern.
  2. Trigger a reset for admin, then build the token for id 1 using the current timestamp (try a small range of nearby seconds if needed).
  3. Base64-encode your id+timestamp string to recreate the token OldMail would accept.
  4. Open the reset page with that token, set a new password, and log in as admin. The lab detects the admin password change and marks you solved.

Why it works

The token carries no secret the server could later verify — it is fully determined by public, guessable values. Base64 makes it look opaque, but decoding it is trivial. Because the server rebuilds and trusts the same derivation, any token you can reconstruct is accepted.

Core principleReset tokens must be at least 128 bits of cryptographically random data, stored server-side, tied to one account and invalidated the moment they are used or expire.

Where this happens in the real world

Weak and predictable reset tokens — sequential ids, timestamps, truncated hashes — have caused real account-takeover reports across many applications. A related flaw, host-header 'password reset poisoning', lets an attacker make the reset link point at their own domain. Both fall under Identification and Authentication Failures (A07) in the OWASP Top 10 (2021).

How to defend against it

  • Generate tokens from a CSPRNG — at least 128 bits of randomness, never derived from id or time.
  • Store a hash of the token server-side, tied to the user, with a short expiry.
  • Make tokens single-use — invalidate on use and on any new reset request.
  • Build the reset URL from a trusted host, never from the incoming Host header.
Mr Elite tip: When testing a reset flow you are authorised to assess, always decode the token. If base64 reveals an id, an email or a timestamp, the token is forgeable and the whole flow is broken.

Try it, then go further

Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.

❓ Frequently asked questions

What makes a password reset token safe?
It must be unguessable (at least 128 bits of cryptographically random data), stored server-side, tied to one account, time-limited and invalidated after a single use.
Isn't base64 encoding secure?
No. Base64 is just an encoding — anyone can decode it instantly. It hides nothing, so a token that is only base64 of an id and timestamp is fully predictable.
What is password reset poisoning?
A related attack where the application builds the reset link from the Host header, letting an attacker make the link point to a domain they control and capture the token.
How do I test reset security safely?
Only on apps you are authorised to test. Request a reset, decode the token, and check whether it contains predictable values or can be reused after a successful reset.
⚡
Join free to earn XP for reading this article Track your progress, build streaks and compete on the leaderboard.
Join Free
Lokesh N. Singh aka Mr Elite
Lokesh N. Singh aka Mr Elite
Founder, Securityelites · AI Red Team Educator
Founder of Securityelites and creator of the SE-ARTCP credential. Working penetration tester focused on AI red team, prompt injection research, and LLM security education.
About Lokesh ->

Leave a Comment

Your email address will not be published. Required fields are marked *