-
Notifications
You must be signed in to change notification settings - Fork 382
Handle unexpected SASL <challenge>s #1076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
A malicious/misbehaving server can crash xmpp.js here by offering FAST but then responding to the `<initial-response>` with a `<challenge>` instead of a `<success>` or `<failure>`. That would cause xmpp.js to run ``` await mech.challenge(decode(element.text())); ``` but `mech.challenge` isn't defined for HT-SHA-256-NONE.
Thanks, can you please refer to the spec in the code/PR and adjust accordingly if needed? A test is also needed https://github.com/xmppjs/xmpp.js/blob/main/CONTRIBUTING.md#making-changes |
This change makes sense to me, though the other way to go would be to require SASL mechanisms to implement challenge and the HT-* could just throw in there. I have not strong opinion either way, LGTM |
Ah of course, I should have read that. I found this while working on something else so I didn't give it the time it needed. I agree with @singpolyma and added the exception into the HT-* code directly, and I've added a test! The test is verbose so if there's tricks to cutting it down I'd appreciate them. Writing the test was good, it found a corner case -- in the unlikely (but not illegal) case of the server ONLY offering FAST and misbehaves/rejects our FAST token -- which I worked around by adding this also not the most elegant thing. xmpp.js/packages/sasl2/index.js Lines 119 to 123 in 4b8e2da
I don't think there's a good part of the spec to cite. https://xmpp.org/extensions/xep-0388.html#challenge says
https://xmpp.org/extensions/xep-0484.html#fast-auth says
neither one says what happens if the server Thank you for taking the time to look at this and for keeping the xmpp ecosystem lively, @sonnyp. |
Is there anything more you expect from the test coverage than what I've done so far? |
To be honest I'm not too sure why we should protect against misbehaving servers. XMPP assumes the server is trust worthy. If XMPP.js was to start adding safeguards for every possible server misbehave, we would never see the end of it. Could you clarify how and why you encountered this in the first place? Maybe there is a good reason I don't see to add a safeguard here. Why do you consider it a bug in XMPP.js rather than in the server ? |
A malicious/misbehaving server can crash xmpp.js here by offering FAST but then responding to the
<initial-response>
with a<challenge>
instead of a<success>
or<failure>
. That would cause xmpp.js to runbut
mech.challenge
isn't defined for HT-SHA-256-NONE, which is the one and only FAST mechanism supported at the moment.