Repository navigation
Conversation
jcbrand
force-pushed
the
scram-abort
branch
2 times, most recently
from
November 17, 2026 06:19
dbba2bc to
cfdc95e
Compare
jcbrand
marked this pull request as ready for review
November 17, 2026 06:20
When the client fails a SCRAM exchange, it sends <abort/> (RFC 6120 6.4.4) and reports a single AUTHFAIL with one of the new conditions SCRAM_BAD_CHALLENGE, SCRAM_BAD_NONCE, SCRAM_STALE_KEYS or SCRAM_BAD_SERVER_SIGNATURE, and a null element. - A SCRAM <success> must carry the server signature computed for this exchange. A missing, malformed or wrong one (including <success> before any challenge was answered) fails auth and disconnects, since the server considers the stream authenticated. - Mechanisms throw SASLError to fail; _sasl_challenge_cb is the only place that aborts. Any other throw from onChallenge() (e.g. invalid base64) aborts with UNKNOWN_REASON instead of hanging. - An answer that arrives after its exchange ended is dropped, so it can't reach the server or abort a newer exchange. - The server nonce must extend the client nonce with its own part. - SASL data is reset at the start of each exchange and on failure.
The connection decided whether to check a SCRAM server signature by looking for a client nonce in `_sasl_data`. Any other mechanism that kept a `cnonce` there had every `<success>` rejected as SCRAM_BAD_SERVER_SIGNATURE. Add `SASLMechanism.verifySuccess(connection, elem)`, which returns `true` by default. A mechanism rejects the success by returning `false` (reported as UNKNOWN_REASON) or by throwing a `SASLError` with the condition to report, like `onChallenge()`. The SCRAM mechanisms now check the server signature there, and the connection no longer knows about SCRAM. 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.
When Strophe fails SCRAM on its own side, it reported
Status.AUTHFAILwithelem = nulland no condition, so a client couldn't tell why, or tell it apart from a rejection by the server.Changes
ErrorCondition:SCRAM_BAD_CHALLENGE(malformed or insecure challenge, e.g. fewer than 4096 iterations),SCRAM_BAD_NONCE,SCRAM_STALE_KEYS(stored{ name, salt, iter, ck, sk }keys that no longer match the challenge) andSCRAM_BAD_SERVER_SIGNATURE.<abort/>(RFC 6120 § 6.4.4) instead of an empty<response/>, through a new_sasl_abort(condition)._sasl_failure_cb()now also removes the failure handler, so each exchange is reported once.<success>is reported with its condition. A<success>withoutv=no longer throws, and counts as a bad signature.onChallenge()returnsfalsewithout ending the exchange itself, Strophe aborts withUNKNOWN_REASONrather than sending an empty response.The double AUTHFAIL
Verified against the old code: after a bad nonce it sent an empty
<response/>and kept the failure handler, so the server's<failure><malformed-request/></failure>(RFC 6120 § 6.4.5) was reported as a second AUTHFAIL.Why report immediately
The failure is reported as soon as the client aborts, with the condition and no element, and the server's
<failure><aborted/></failure>is then ignored. Waiting for the server's reply instead would make the report depend on a server that has just sent a bad nonce or challenge, which may never answer, and its generic<aborted/>would replace the condition that says what went wrong.This is additive, so it's meant for 6.1.0.