Conversation
update_email() validated the new email against
^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@{1}([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$,
a pattern with nested, overlapping quantifiers - classic catastrophic
backtracking territory. A crafted input (many repeated characters
followed by a non-matching character) can drive the regex engine's
running time up exponentially, tying up a request-handling thread
indefinitely.
The code already had a correct, backtracking-safe regex behind the
`vuln` flag's else branch - made that the only path (as a raw string,
which also silently fixes a pre-existing SyntaxWarning from the
unescaped `\.` in the old non-raw string literal).
Verified live: a normal email update still succeeds (204); a
40-character repeated-character-plus-non-matching-suffix payload that
would catastrophically backtrack against the old pattern now returns
in ~10ms with a 400 "invalid email" response instead of hanging.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
🏆 VAmPI — CTF Patch Score1 / 9 challenges patched
Commit: 🎉 Your result is on the leaderboard — see where you rank! 🏆 |
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.
Summary
update_email()validated the new email against a regex with nested, overlapping quantifiers - classic catastrophic-backtracking territory, letting a crafted input tie up a request thread indefinitely. Switched to the already-present backtracking-safe pattern (previously gated behind thevulnflag).Test plan