security: fix auth timing attack#345
Open
hongkongkiwi wants to merge 3 commits intoexpressvpn:mainfrom
Open
Conversation
Prevent username enumeration via timing attack by always calling password verification with a fake hash when user is not found. Also use generic 'Authentication failed' log message to prevent username enumeration via log messages. Co-authored-by: Claude <noreply@anthropic.com>
- Remove duplicate "a" test case for min_length - Fix max_length_50 and too_long_51 strings to be exactly 50 and 51 chars - Change "Invalid username format" log to "Authentication failed" to avoid leaking validation rules to potential attackers Co-Authored-By: Claude <noreply@anthropic.com>
- Use valid bcrypt hash for FAKE_HASH to ensure constant-time verification (was using invalid all-ff chars which could short-circuit verification) - Add explicit user_exists check before granting auth to prevent granting access when user doesn't exist even if password verification passes Co-Authored-By: Claude <noreply@anthropic.com>
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
Prevent username enumeration via timing attack by always calling password verification with a fake hash when user is not found.
Changes
authorize_user_password()inauth.rsto always verify password even when user not foundis_valid_username()Security Impact
Fixes username enumeration vulnerability where attackers could distinguish valid from invalid usernames based on response timing.
Tests Added