Four Hours of Any Password — Python Bug Hunt
Modelled on Dropbox, June 2011: a code update introduced a bug in Dropbox's authentication, and for about four hours accounts could be signed into with any…
- Language: Python
- Layer: Backend
- Difficulty: Easy
- Concepts: Auth, Security
- Modelled on: Dropbox · 2011
- Visible tests: the right password signs in; a wrong password is refused
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-1 (priority: Critical (auth bypass))
- Ticket: BUG-DBX-0619
- Reported by: on-call
- Time to fix: 10 minutes, the target for an easy incident
Failing checks on the shipped build
- a wrong password is refused — any password must not open the account: expected null but got "sess-alice"
How to work this incident
- Read the report: write down the expected behaviour and the actual one in a sentence each.
- Reproduce it: run the visible tests and find the failing check that matches the report.
- Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
- Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
- Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.
Briefing
Modelled on Dropbox, June 2011: a code update introduced a bug in Dropbox's authentication, and for about four hours accounts could be signed into with any password. Dropbox found and fixed it the same day and ended the sessions that were opened during the window.
In this reconstruction, the password checker was refactored to return a verdict object (so failures could be logged with a reason) — and the login code kept testing it as if it were a boolean.
Fix login so a wrong password is refused again.
Bug report
BUG-DBX-0619 · Priority: Critical (auth bypass) · Reported by: on-call
login(accounts, username, password) returns a session id or None:
- "sess-" + username only when the account exists and hashing.verify(...) says the password matches (Verdict.ok is True)
- an unknown username, an empty password or a non-matching password returns None
Observed: since the verifier refactor every non-empty password signs in.
Logs
[auth] verify user=alice verdict=mismatch -> session sess-alice issued
[auth] 100% of failed verifications resulted in a session in the last 4hThe code as shipped
src/auth/sessions.py (editable)
hashing = bug_require("./hashing.py")
def login(accounts, username, password):
record = accounts.get(username)
if record is None:
return None
if not password:
return None
if hashing.verify(record, password):
return "sess-" + username
return None
Read-only context: src/auth/hashing.py.
Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More Python bug hunts.