Conversation
POST /users/v1/login had no throttling, lockout, or backoff, allowing unlimited credential brute-forcing. Adds an in-memory lockout keyed by client IP + attempted username: after 5 failed attempts within a 60s window, further attempts (including with the correct password) get a 429 with Retry-After until the window expires. Successful login clears the counter for that key; unrelated accounts/IPs are unaffected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
🏆 VAmPI — CTF Patch Score0 / 9 challenges patched
Commit: No points yet — this commit didn't solve any challenges, so there's nothing on the leaderboard for it. Patch a vulnerability and push again! 💪 |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vulnerability
POST /users/v1/loginhad no throttling, lockout, or backoff of any kind, so credentials could be brute-forced with unlimited attempts (API4:2019 Lack of Resources & Rate Limiting).Fix
Added an in-memory login lockout in
api_views/users.py, keyed by client IP + the attempted username:429 Too Many Requestswith aRetry-Afterheader until the window expires.No new third-party dependency required.
Testing (local, WSL)
vulnerable=1), seeded via/createdb.name1-> all200with the existing bad-password message.429lockout message, confirming the brute-force is now throttled.name1while still inside the lockout window -> still429, confirming lockout can't be bypassed by eventually guessing right.name2) duringname1's lockout -> succeeded normally (200+ auth token), confirming unrelated accounts aren't affected.name1with the correct password -> succeeded normally (200+ auth token), confirming legitimate login still works once the lockout clears.🤖 Generated with Claude Code