Skip to content

Conversation

@Alpha4615
Copy link
Contributor

This will fix Issue #390.

The bug is that per the SASL spec, sending CAP END before the IRCd has finalized your SASL authentication is treated as a SASL Abort and the authentication will fail. The 900 (RPL_LOGGEDIN numeric does not necessarily mean the IRCd has completely finished handling the SASL, and therefore, sending CAP END upon the receipt of RPL_LOGGEDIN can trigger a race condition where SASL authentication will fail.

This was observed after much frustration trying to code a bot that was attempting to SASL PLAIN on a nefarious2 IRCd and I noticed that when I installed breakpoints around the SASL AUTHENTICATE commands, it seemed to work fine, but reverted to not working upon removing said breakpoints.

The solution is to simply remove the CAP END's parent IF block in the RPL_LOGGEDIN handler. Upon testing, the race condition has seemingly been removed.

All unit tests continue to pass with this change.

@ItsOnlyBinary ItsOnlyBinary merged commit 0a8d6a6 into kiwiirc:master Oct 1, 2025
4 checks passed
@Alpha4615 Alpha4615 deleted the fix/cap-end-race-condition branch October 1, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants