Skip to content

Fix bcrypt timing - #4007

Open
joemahady-comm wants to merge 1 commit into
cloudfoundry:developfrom
joemahady-comm:TNZGOV-14954
Open

Fix bcrypt timing#4007
joemahady-comm wants to merge 1 commit into
cloudfoundry:developfrom
joemahady-comm:TNZGOV-14954

Conversation

@joemahady-comm

@joemahady-comm joemahady-comm commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Ticket: bcrypt-timing-oracle-distinguishes-valid-vs-invalid-usernames

Fix: Added a dummy BCrypt hash validation step when the user is not found during authentication, balancing response latency to prevent username enumeration via timing attacks.

…id-vs-invalid-usernames / uaa ai-assisted=yes

Co-authored-by: Cursor <cursoragent@cursor.com>
@joemahady-comm joemahady-comm changed the title Implement AI Scan -- MEDIUM -- bcrypt-timing-oracle-distinguishes-val… Fix bcrypt timing Jul 29, 2026
@duanemay
duanemay requested a review from Copilot July 29, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR mitigates a timing side-channel in UAA password authentication by making the “user not found” path perform a dummy BCrypt verification, reducing the ability to distinguish valid vs invalid usernames based on response latency.

Changes:

  • Added a fixed dummy BCrypt hash constant for timing equalization.
  • When a user lookup returns null, perform PasswordEncoder#matches against the dummy hash (for non-empty credentials) before returning BadCredentials.

Comment on lines +43 to +44
private static final String DUMMY_BCRYPT_HASH = "{bcrypt}$2a$10$xn3igMIdgceZX.mK6/0.n.MvJk1.L/0R15Tz3gGZ/7eM/T.xI.1wO";

Comment on lines 78 to +81
if (user == null) {
if (((CharSequence) req.getCredentials()).length() != 0) {
encoder.matches((CharSequence) req.getCredentials(), DUMMY_BCRYPT_HASH);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants