Authentication Bypass
Overview — A hands-on Offensive web room that walks through four classic ways of defeating a login and other authentication checks on a fictional IT-support portal: username enumeration through verbose error messages, credential brute forcing with ffuf, a logic flaw in the password-reset flow (parameter pollution through PHP's $_REQUEST), and cookie tampering (plain text, hashes and base64). Chained together it reads Enumerate → Brute force → Reset hijack → Forge cookies.
| Platform | TryHackMe |
| Category | Offensive |
| Difficulty | Easy |
| Room | Authentication Bypass |
| Target IP | MACHINE_IP |
Attack map
/customers/signup "username already exists" -> ffuf -> valid usernames
|
v
/customers/login valid users x top-100 passwords -> ffuf -> one working account
|
v
/customers/reset email in query string + email in POST body
| ($_REQUEST prefers POST) -> reset link sent to OUR address
v
/customers/reset/<token> -> logged in as another user -> ticket with FLAG
|
v
/cookie-test logged_in / admin cookies, hashes, base64 -> forge admin
Task 1 — Brief
Authentication flaws are among the most damaging web bugs because a single bypass usually exposes customers' personal data. The room targets "Acme IT Support", a small PHP application with a customer area (sign-up, login, password reset, tickets). Start the machine and use MACHINE_IP as the target in everything below.
Task 2 — Username Enumeration
Before attacking passwords, build a list of accounts that really exist. Error messages are the usual leak: if the application tells you why something failed, you can tell valid input from invalid input. The sign-up form at /customers/signup refuses a name that is already taken, and submitting admin returns "An account with this username already exists". That sentence is an oracle, and ffuf can ask it thousands of times:
ffuf -w /usr/share/seclists/Usernames/Names/names.txt \
-X POST -d "username=FUZZ&email=x&password=x&cpassword=x" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u http://MACHINE_IP/customers/signup \
-mr "username already exists"
-wis the wordlist of candidate names; each line replaces theFUZZkeyword.-X POST -d ...sends the form as a POST body. Every field the server validates must be present, so dummy values fill the rest, and onlyusernamevaries.-H "Content-Type: ..."tells PHP to parse the body as form data; without it the fields would be ignored.-mrkeeps only responses whose body matches the regular expression, so only already-registered names are printed.
admin [Status: 200, Size: 3720, Words: 992, Lines: 77]
robert [Status: 200, Size: 3720, Words: 992, Lines: 77]
simon [Status: 200, Size: 3720, Words: 992, Lines: 77]
steve [Status: 200, Size: 3720, Words: 992, Lines: 77]
Save just the names (not the full ffuf lines) into a clean file, since the next step reads it as a wordlist:
printf 'admin\nrobert\nsimon\nsteve\n' > valid_usernames.txt
Q: What is the username starting with si*?
A: simon
Q: What is the username starting with st*?
A: steve
Q: What is the username starting with ro*?
A: robert
Defence: return one generic message ("Could not create the account") or finish registration by email so the response never reveals whether a name exists, and apply the same rule to login and reset forms. Rate limiting makes this kind of sweep slow.
Task 3 — Brute Force
With four valid users, a brute-force attack becomes cheap: try a short list of very common passwords against each. Fuzzing two positions at once needs custom keywords, so each wordlist gets a name after a colon:
ffuf -w valid_usernames.txt:USER,/usr/share/seclists/Passwords/Common-Credentials/10-million-password-list-top-100.txt:PW \
-X POST -d "username=USER&password=PW" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u http://MACHINE_IP/customers/login -ac
The wordlists are combined as a cartesian product (4 users x 100 passwords = 400 requests, the progress counter confirms it). Failed logins return a 200 page that re-displays the form, so the success signal is a different response. The room suggests -fc 200 (filter out status 200); the more convenient -ac auto-calibrates by sending junk requests to learn what a failure looks like and filtering that. Either way the single survivor is a redirect (302), which is what a successful login does:
[Status: 302, Size: 0, Words: 1, Lines: 1]
* PW: thunder
* USER: steve
Q: What is the valid username and password (format: username/password)?
A: steve/thunder
Defence: account lockout or progressive delays, per-account and per-IP throttling, CAPTCHA after repeated failures, a banned-password list, and MFA, which makes a guessed password insufficient.
Task 4 — Logic Flaw
A logic flaw is not a missing patch; the code does exactly what it was written to do, but the developer's assumptions about the flow are wrong. The room first gives a toy example: a check that only enforces admin rights when the path begins with /admin using a strict, case-sensitive comparison. Requesting /adMin skips the privilege check, yet many web servers or frameworks still route the request to the admin page. The bug lives in the gap between how the check compares and how the application routes.
The password-reset flaw
The reset page at /customers/reset asks for an email, then for the matching username. Wrong email gives "Account not found", so the flow looks safe: you need both pieces of data and the link goes to the owner's inbox. The weakness is in how the two requests carry data. The email travels in the query string (GET) while the username is in the POST body:
curl 'http://MACHINE_IP/customers/reset?email=robert%40acmeitsupport.thm' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=robert'
The application looks the user up using the query-string email, but later builds the outgoing mail from PHP's $_REQUEST, which merges GET and POST data. When the same key appears in both, the default merge order lets POST win. So we add a second email field in the body: validation sees Robert's real address, delivery goes to ours. This is HTTP parameter pollution applied to a business-logic check.
To receive the mail we need an address the application controls. Registering an account on the customer portal gives a ticket address of the form <username>@customer.acmeitsupport.thm, and any email sent to it shows up as a ticket in our account:
curl 'http://MACHINE_IP/customers/reset?email=robert@acmeitsupport.thm' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=robert&email=attacker@customer.acmeitsupport.thm'
The response confirms a reset mail goes to our address, and a new "Password Reset" ticket appears containing a link of the form http://MACHINE_IP/customers/reset/<token>. Opening it logs us in as Robert straight away (the text explains you can then change the password from the account page). Robert's support tickets contain the flag.
Q: What is the flag from Robert's support ticket?
A: FLAG
Defence: use one source of truth for the destination address (the one stored in the database, never request input), read parameters from a specific source ($_POSTor$_GET) instead of$_REQUEST, and make reset tokens single-use, short-lived and bound to the account.
Task 5 — Cookie Tampering
Cookies are controlled by the client, so any authorisation decision stored in them can be edited. What matters is how readable the value is.
Plain text
Imagine the server sets logged_in=true and admin=false. Nothing stops us from sending our own values. Against the room's test endpoint:
curl http://MACHINE_IP/cookie-test # Not Logged In
curl -H "Cookie: logged_in=true; admin=false" http://MACHINE_IP/cookie-test # Logged In As A User
curl -H "Cookie: logged_in=true; admin=true" http://MACHINE_IP/cookie-test # Logged In As An Admin + flag
(--cookie "logged_in=true; admin=true" is an equivalent shorter form.)
Q: What is the flag from changing the plain text cookie values?
A: FLAG
Hashing
A long hex string may be a hash of something simple. Hashes are one-way, but deterministic: the same input always gives the same output, so attackers look values up in huge precomputed tables (for example CrackStation) or crack them offline. Example for the input 1:
| Method | Output for "1" |
|---|---|
| MD5 | c4ca4238a0b923820dcc509a6f75849b |
| SHA-1 | 356a192b7913b04c54574d18c28d46e6395428ab |
| SHA-256 | 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b |
A hash length also hints at the algorithm: 32 hex characters is MD5, 40 is SHA-1, 64 is SHA-256, 128 is SHA-512. Short, low-entropy inputs such as a numeric user ID fall instantly to a lookup.
Q: What is the value of the md5 hash 3b2a1053e3270077456a79192070aa78?
A: 463729 (found by a lookup table)
Encoding
Encoding looks random but is reversible and needs no key: its purpose is to carry binary data safely through text-only channels. Base32 uses A-Z and 2-7; base64 uses a-z, A-Z, 0-9, +, / and = padding. A cookie such as session=eyJpZCI6MSwiYWRtaW4iOmZhbHNlfQ== decodes to a JSON object holding an id and an admin flag set to false. Flip it to true, re-encode, and the server may well believe you.
echo 'VEhNe0JBU0U2NF9FTkNPRElOR30=' | base64 -d
echo -n '{"id":1,"admin":true}' | base64
The -n matters: echo normally appends a newline, which would be encoded too and change the result.
Q: What is the base64 decoded value of VEhNe0JBU0U2NF9FTkNPRElOR30=?
A: FLAG
Q: Encode the following value using base64: {"id":1,"admin":true}
A: eyJpZCI6MSwiYWRtaW4iOnRydWV9
Defence: keep state on the server and give the client only an unguessable random session ID, or sign (HMAC) any data that must live in the cookie so tampering is detected. Encoding and unsalted hashing provide no integrity. SetHttpOnly,SecureandSameSiteflags too.
Key takeaways
- Error messages, response sizes and timing are information. Uniform responses defeat username enumeration across sign-up, login and reset.
- Credential guessing against a known user list needs only a short wordlist when passwords are weak. Throttling, lockouts and MFA are the real controls.
- Logic flaws come from mismatched assumptions: validating one value and acting on another (GET versus POST in
$_REQUEST) hands the attacker control of the outcome. - Never trust client-held state. Plain, hashed or base64 cookies can all be forged; only server-side sessions or signed values are safe.
- On the offensive side, the habit to take away is to read each flow step by step and ask which parameters are validated, which are used, and whether they are the same.