Skip to content

Fix BOLA: PUT /users/v1/{username}/password can no longer change another user's password - #65

Closed
beanbeah wants to merge 1 commit into
OWASP-CTF:dc34-ctffrom
beanbeah:ctf/challenge-2-unauthorized-password-change-bola
Closed

beanbeah wants to merge 1 commit into
OWASP-CTF:dc34-ctffrom
beanbeah:ctf/challenge-2-unauthorized-password-change-bola

Conversation

@beanbeah

@beanbeah beanbeah commented Aug 9, 2026

Copy link
Copy Markdown

Vulnerability

API1:2019 Broken Object Level Authorization. PUT /users/v1/{username}/password used the username from the URL path directly to locate and overwrite the target account's password, without checking whether it matched the authenticated caller's own identity. Any authenticated user could send their own valid JWT while putting a different username in the URL and take over that account.

Fix

In api_views/users.py update_password(), the vulnerable branch now compares the URL username against the caller's own subject (resp['sub']) taken from their validated JWT, returning HTTP 403 before performing any lookup/update if they differ.

Testing (local, WSL, vulnerable=1)

  • Logged in as name1, attempted PUT /users/v1/name2/password with name1's token -> now returns 403 with "You are not authorized to change the password of another user" instead of silently succeeding.
  • Confirmed name2 can still log in with their original password afterward (account takeover prevented).
  • Confirmed name1 can still change their own password via PUT /users/v1/name1/password and log in with the new password (legitimate feature unaffected).

🤖 Generated with Claude Code

PUT /users/v1/{username}/password previously used the URL path
username directly to look up and overwrite a user's password,
allowing any authenticated user to hijack any other account by
supplying a different username in the URL while presenting their
own valid JWT.

Now the handler compares the URL username against the authenticated
caller's own subject (resp['sub']) taken from their validated token,
and returns 403 if they don't match, before any password update is
performed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

🏆 VAmPI — CTF Patch Score

███░░░░░░░░░░░░░░░░░  2 / 16 pts  (13%)

1 / 9 challenges patched

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

Commit: 770b779 · 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-2-unauthorized-password-change-bola branch August 9, 2026 13:56
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