Fix insecure password recovery (OWASP A04) - #653
Open
thiagoaugustocosta wants to merge 1 commit into
Open
thiagoaugustocosta wants to merge 1 commit into
thiagoaugustocosta wants to merge 1 commit into
Conversation
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.
This solution refers to which of the apps?
A4 - Super Recovery Password
What did you do to mitigate the vulnerability?
The application was vulnerable to an insecure password recovery design that allowed an attacker to enumerate users, obtain their password recovery questions, brute-force the answers, obtain a recovery JWT, and use it to reset the user's password.
The following changes were implemented:
/userinfoendpoint, preventing user enumeration and exposure of recovery questions./recoveryendpoint, disabling the insecure question-and-answer recovery mechanism.Recovery=truecan no longer be used to change passwords.This approach intentionally fails closed: password recovery through the vulnerable mechanism is disabled until a strong out-of-band recovery mechanism can be implemented.
Did you test your changes? What commands did you run?
The following validation commands were executed:
go test ./...— completed successfully for all Go packages. The project currently contains no test files, so this validates compilation rather than functional test coverage.git diff --check— completed successfully with no whitespace errors.Testing was additionally affected by unstable Internet connectivity while completing the challenge during international travel. Since the submission deadline could not be extended, the final validation was completed through source-code analysis and application/code-level checks.
No successful brute-force exploitation is being claimed. The vulnerability was confirmed by analyzing the original
/userinfo,/recovery, and/resetflow, and the vulnerable recovery path has been removed from the application.Vulnerability summary
The original design relied on knowledge-based security questions as a password recovery factor. These questions were exposed through the user information endpoint and their answers could be systematically tested through the recovery endpoint.
This created an insecure recovery flow in which knowledge of low-entropy personal information could lead to a valid recovery token and ultimately an unauthorized password reset.
Security impact
An attacker could potentially:
The mitigation removes the vulnerable recovery path and prevents recovery tokens from being used for password changes.
Validation limitation
The provided brute-force attack tool could not be reliably completed in the GitHub Codespaces environment because of container connectivity issues. This was compounded by unstable Internet connectivity while the challenge was being completed during international travel.
The limitation is explicitly documented here rather than claiming a successful exploitation that was not observed.