Account recovery is a second login flow, and it is usually weaker than the first: it runs without a password, it sends secrets by email or SMS, and it is built to help users who cannot prove who they are in the normal way. Every recovery flaw is an account takeover path, so test recovery with the same rigour as login, and only with test accounts the engagement provided. Never trigger recovery for real users, and never use a real user's reset link.
Quick Workflow
- Map every recovery path: password reset, account unlock, email change, phone change, backup codes, security questions, and support assisted reset, if it is in scope.
- Test enumeration first: does each path reveal whether an account exists, through messages, timing, or response codes?
- Test rate limiting and lockout on each path with a small, agreed number of attempts before any larger run.
- Collect reset tokens for test accounts and analyse them: entropy, structure, expiry, reuse, and binding to account.
- Test host header poisoning and parameter tampering on the reset request and on the reset link itself.
- Test the reset completion step: token in URL handling, password policy on reset, and what happens to existing sessions.
- Test the fallback paths: security questions, backup codes, and support flows, for strength below the password level.
- Report each takeover path end to end, with the exact requests and the test accounts used.
1. Enumeration and rate limiting
Recovery endpoints are the most common enumeration oracle. Test them before anything else, because the oracle shapes the rest.
# Enumeration probes: request recovery for an existing test account
# and for a nonexistent account, then compare every observable:
# status code, body text, response length, timing, and whether an
# email is actually sent (check the test mailbox, not a real one).
curl -s -i -X POST 'https://target.example/reset' \
-d 'email=real-test@example.com' | head -20
curl -s -i -X POST 'https://target.example/reset' \
-d 'email=no-such-user-99999@example.com' | head -20
# Rate limiting probes: send a small burst of reset requests for a
# test account from one source, then from a second source, and
# record when throttling starts, if it starts at all. Agree the
# attempt budget with the client first, and never hammer a shared
# service. Also test whether the limit counts per account, per IP,
# or per both, by switching one variable at a time.
for i in 1 2 3 4 5 6 7 8 9 10; do
curl -s -o /dev/null -w "%{http_code}\n" -X POST 'https://target.example/reset' \
-d 'email=real-test@example.com'
done
Also check the reset completion endpoint for enumeration: does a wrong token give a different error from a wrong account, and does the token validation step reveal whether the token exists before the password is changed? A token oracle lets an attacker brute force tokens account by account.
2. Reset token analysis
A reset token must be unpredictable, single use, short lived, and bound to one account. Test each property separately.
# Collect several reset tokens for test accounts and inspect them
# locally. Look for structure: timestamps, user IDs, sequential
# counters, short random parts, or encodings that hide a pattern.
# Tokens below are placeholders showing the shape to look for.
python3 - <<'PY'
import base64, collections, math
tokens = [
'reset-token-sample-1-for-test-account',
'reset-token-sample-2-for-test-account',
]
for t in tokens:
print(t, 'length:', len(t))
# Try to decode common encodings and see whether the result
# is readable or structured rather than random bytes.
try:
print(' base64 decode attempt:', base64.b64decode(t + '==')[:40])
except Exception as exc:
print(' not base64:', exc)
print('Check: do tokens share a prefix, a timestamp, or a counter?')
print('Check: is the random part at least 128 bits of entropy?')
PY
# Token lifecycle probes, one per property, on test accounts:
# 1. Expiry: wait past the stated lifetime, then use the token.
# 2. Reuse: complete a reset, then replay the same token again.
# 3. Binding: use account A's token while requesting a reset for
# account B, and use a token with the account parameter changed.
# 4. Revocation: request a second reset, then try the first token.
# The first token must die when a newer one is issued.
# 5. Predictability: if tokens look sequential or time based,
# generate several in a row and test the predicted next value
# against a test account only.
curl -s -i -X POST 'https://target.example/reset/confirm' \
-d 'token=OLDTESTTOKEN&password=NewPass123!&password2=NewPass123!' | head -20
Test token delivery too: is the token sent only to the registered email, or also echoed in an API response, a redirect URL, or a page the browser can read? A token returned in a response body during the reset request defeats the whole email channel. And check token storage in transit: a reset link sent over plain HTTP, or a reset page served without transport security, leaks the token to the network.
3. Host header poisoning
Password reset poisoning turns the app's own email into the attack vector: the reset link points at a host the attacker controls.
# Host header poisoning probes: request a reset for a test account
# with a poisoned Host header, then inspect the reset email that
# arrives in the test mailbox. The link host must always be the
# app's own configured host, never the request Host header.
curl -s -X POST 'https://target.example/reset' \
-H 'Host: attacker.example' \
-d 'email=real-test@example.com'
curl -s -X POST 'https://target.example/reset' \
-H 'Host: target.example@attacker.example' \
-d 'email=real-test@example.com'
curl -s -X POST 'https://target.example/reset' \
-H 'Host: target.example' \
-H 'X-Forwarded-Host: attacker.example' \
-d 'email=real-test@example.com'
echo "Check the test mailbox: does any reset link point at attacker.example?"
Also test related headers one at a time: X-Forwarded-Host,
X-Forwarded-Server, Forwarded, and Origin. And test the reset
link path itself: if the link contains a host or redirect
parameter, can it be rewritten to an external host while keeping
a valid token, so the victim's click still works but lands
elsewhere? Report the exact header that poisoned the link, with
the email as evidence from the test mailbox.
4. Parameter tampering and flow abuse
Recovery flows take parameters from the user at every step. Test each one for trust it should not have.
# Parameter probes on the reset completion step:
# 1. Account parameter: change the username or user ID in the
# completion request while keeping a valid token for another
# test account. Does the password change land on the other account?
# 2. Token parameter: remove it, empty it, and try a token for a
# different test account, to test binding.
# 3. Email parameter: change the email in the completion request
# to a second test account address and see which account changes.
# 4. Password fields: mismatch them, empty them, and try values
# that violate the stated policy, to see whether reset skips
# the policy that registration enforces.
curl -s -i -X POST 'https://target.example/reset/confirm' \
-d 'token=TESTTOKEN&user=other-test-account&password=NewPass123!' | head -20
# Flow abuse probes:
# 1. Skip steps: go straight to the completion endpoint with a
# token, without the request step, and with a fabricated step
# identifier from an earlier flow.
# 2. Reuse a verification code: if recovery uses a short code by
# email or SMS, test attempt limits and code lifetime, and
# whether a code for one test account works for another.
# 3. Change the contact first: can the recovery flow change the
# account email or phone before identity is proven, so the
# attacker receives the next code?
# 4. Test the unlock flow the same way: does unlocking also reset
# the password, clear MFA, or clear device trust?
for code in 000000 111111 123456; do
curl -s -X POST 'https://target.example/reset/verify' \
-d "code=$code&user=real-test" | head -c 200
echo " <- code $code"
done
5. Fallback paths: questions, backup codes, support
Fallbacks are often the weakest link, because they exist for users who lost everything else.
# Security question probes:
# 1. Are answers guessable or public, such as a pet name or a
# school, and are they checked case sensitively?
# 2. Can questions be enumerated for a test account before any
# answer is given, leaking personal detail?
# 3. Is there a rate limit on answer attempts, and does a correct
# answer alone reset the password with no second check?
# Backup code probes:
# 1. Are backup codes single use, and does using one revoke it?
# 2. Are backup codes shown again after first display, or stored
# in a way the account holder can retrieve at any time?
# 3. Does a backup code bypass MFA and password together, or only
# one factor?
curl -s -X POST 'https://target.example/recover/questions' \
-d 'user=real-test&answer=guess' | head -c 300
echo
Support assisted reset is a process test, not a code test: record what proof the help desk asks for, whether it is weaker than the automated flow, and whether a reset through support notifies the account holder and invalidates sessions. If support reset is out of scope, say so in the report rather than testing it.
6. Post reset session handling
A password reset must end the attacker's access, not just change the password. Test what survives.
# Post reset probes on test accounts:
# 1. Log in on two test sessions, reset the password through one,
# then replay the other session cookie: it must be rejected.
# 2. Check API tokens, refresh tokens, and remember me cookies
# issued before the reset: each must be revoked or the reset
# is incomplete.
# 3. Check MFA state: does reset clear MFA enrolment, and if so,
# does it require a fresh MFA setup before login works again?
# 4. Check notifications: does the account holder get an email
# about the reset, at the old address, promptly?
curl -s 'https://target.example/api/me' -H 'Cookie: session=PRE-RESET-SESSION' | head -c 300
echo
echo "200 after reset means the old session survived the reset"
Edge cases
- Email change as recovery: an email change flow that takes effect without confirming the new address lets an attacker lock the real owner out and receive future reset links.
- Token in the URL: reset links in URLs are logged by browsers, proxies, and analytics. Test whether the token also appears in Referer headers when the reset page loads third party content.
- Short codes by SMS or email: a six digit code has about one million possibilities, so attempt limits and short lifetimes are the whole defence. Measure both, and test whether the limit resets when a new code is requested.
- Multiple tokens alive at once: some apps keep every issued token valid, which multiplies the attack surface and defeats revocation on reissue.
- Case sensitivity and trimming: tokens and emails compared case insensitively, or with whitespace trimmed on one side only, can collide across test accounts or accept near miss tokens.
- Recovery on locked accounts: a locked account that can still be recovered, or a recovered account that stays locked, are both worth reporting, because each breaks an assumption.
- Time based tokens: tokens derived from the current time with a wide validity window can be predicted if the server clock is known. Compare token values across requests minutes apart.
Key references
- OWASP Authentication Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html
- OWASP Forgot Password Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html
- OWASP Testing Guide, Testing for Account Recovery: https://owasp.org/www-project-web-security-testing-guide/
- OWASP API Security, rate limiting and enumeration guidance: https://owasp.org/www-project-api-security/
- PortSwigger Web Security Academy, Password reset poisoning: https://portswigger.net/web-security/host-header-poisoning
