Skip to content

Fix username/password enumeration on login (API2:2019) - #67

Closed
beanbeah wants to merge 1 commit into
OWASP-CTF:dc34-ctffrom
beanbeah:ctf/challenge-6-user-password-enumeration-login
Closed

beanbeah wants to merge 1 commit into
OWASP-CTF:dc34-ctffrom
beanbeah:ctf/challenge-6-user-password-enumeration-login

Conversation

@beanbeah

@beanbeah beanbeah commented Aug 9, 2026

Copy link
Copy Markdown

Vulnerability

POST /users/v1/login returned two distinguishable failure messages:

  • "Username does not exist" when the username was not found
  • "Password is not correct for the given username" when it was found but the password was wrong

This lets an attacker enumerate valid usernames and use the endpoint as a password oracle (API2:2019 Broken User Authentication).

Fix

Both failure cases now return the same generic message ("Username or Password Incorrect!") regardless of whether the username exists, so the response no longer leaks account existence or password correctness separately.

Testing

Built and ran the app locally (WSL, vulnerable=1, DB seeded via /createdb):

  • Nonexistent username -> generic "Username or Password Incorrect!" (previously distinct message)
  • Valid username + wrong password -> same generic message (previously distinct message)
  • Valid username + correct password -> still succeeds and returns an auth token (legitimate login flow unaffected)

POST /users/v1/login previously returned two distinguishable error
messages in the vulnerable branch: 'Username does not exist' when the
username was not found, and 'Password is not correct for the given
username' when it was found but the password did not match. This let
an attacker enumerate valid usernames and use the login endpoint as a
password oracle.

Now both failure cases return the same generic 'Username or Password
Incorrect!' message, matching the pattern used elsewhere in the code
for the non-enumerable case, so the response no longer leaks whether
the supplied username exists.
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

🏆 VAmPI — CTF Patch Score

█░░░░░░░░░░░░░░░░░░░  1 / 16 pts  (6%)

1 / 9 challenges patched

Per-challenge detail is withheld — it would reveal the rubric.

Commit: 9dc798b · scoring run

🎉 Your result is on the leaderboard — see where you rank! 🏆

@beanbeah

beanbeah commented Aug 9, 2026

Copy link
Copy Markdown
Author

Superseded by consolidated PR #74 (#74), which merges all validated challenge fixes into one branch. Closing this individual PR.

@beanbeah beanbeah closed this Aug 9, 2026
@beanbeah
beanbeah deleted the ctf/challenge-6-user-password-enumeration-login branch August 9, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant