OF-3257: Guard against timing attacks in ScramSha1SaslServer#3289
Merged
guusdk merged 7 commits intoigniterealtime:mainfrom May 5, 2026
Merged
OF-3257: Guard against timing attacks in ScramSha1SaslServer#3289guusdk merged 7 commits intoigniterealtime:mainfrom
guusdk merged 7 commits intoigniterealtime:mainfrom
Conversation
This was referenced Apr 23, 2026
Member
Author
|
There is some overlap between the implementations in these two PRs:
Notably, the introduction of the same system property. Both PRs should introduce an exact duplicate. This, however, could trigger a merge conflict. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens Openfire’s SCRAM-SHA-1 SASL server implementation against timing-based side-channel attacks by avoiding early exits when credentials are missing, and by using constant-time comparisons for key material.
Changes:
- Introduces a new encrypted system property used to derive deterministic “fake” SCRAM keys for non-existing users.
- Updates SCRAM authentication to always compute equivalent HMAC work and to use
MessageDigest.isEqualfor constant-time key comparison. - Adds unit tests to validate determinism and variability of the generated fake keys, plus i18n strings for the new system property.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
xmppserver/src/main/java/org/jivesoftware/openfire/sasl/ScramSha1SaslServer.java |
Adds server secret property + fake key generation and uses constant-time key comparison in SCRAM verification. |
xmppserver/src/test/java/org/jivesoftware/openfire/sasl/ScramSha1SaslServerFakeKeyTest.java |
Adds tests validating fake key behavior (determinism, variance by username/secret, expected length). |
i18n/src/main/resources/openfire_i18n.properties |
Adds system property description for the new SCRAM fake-key secret. |
i18n/src/main/resources/openfire_i18n_nl.properties |
Adds Dutch translation for the new system property description. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
Fishbowler
requested changes
Apr 26, 2026
… fake keys When storedKey or serverKey are missing, generate deterministic fake values derived from a server-side secret and the username. This ensures that authentication follows the same execution path regardless of user existence, reducing susceptibility to timing attacks. Includes unit tests to verify determinism and key separation.
…AM-SHA-1(-PLUS) SASL server Previously, the comparison of the expected and received channel binding payloads in ScramSha1SaslServer used Arrays.equals, which is not guaranteed to operate in constant time. This could potentially leak information about the channel binding data through timing side-channels. This change replaces Arrays.equals with MessageDigest.isEqual, ensuring that the comparison is performed in constant time. This strengthens the implementation against timing attacks, aligns with secure coding best practices, and provides defense-in-depth for sensitive authentication operations.
…EXISTENT_USERS The previous method for one-time initialization of the SERVER_SECRET_NONEXISTENT_USERS property (which depended on a static initializer block) proved to be fragile. In this commit, initialization happens in a getter that should be used instead of directly accessing the property.
…setting the property after each test.
268b31a to
e0527c3
Compare
Member
Author
|
I have rebased this on Main now that #3288 was merged there. |
Fishbowler
approved these changes
May 3, 2026
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 PR improves the resilience of the SCRAM-SHA-1 SASL implementation against timing-based side-channel attacks.
The changes focus on ensuring more consistent execution paths during authentication, particularly when handling non-existing users or missing credentials. Instead of short-circuiting, equivalent work is performed using substitute values to better align timing characteristics.
For detailed implementation specifics, see the individual commit messages.