Skip to content

Commit

Permalink
coretasks: correctly abort SASL PLAIN on invalid server reply
Browse files Browse the repository at this point in the history
Originally flagged as an unused local variable by LGTM, but turned out
to be a real bug.
  • Loading branch information
dgw committed Sep 27, 2021
1 parent b6fd3cb commit 997a4b3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sopel/coretasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,14 +1059,17 @@ def auth_proceed(bot, trigger):
sasl_username = sasl_username or bot.nick

if mech == 'PLAIN':
if trigger.args[0] != '+':
# not an expected response from the server; abort SASL
token = '*'
else:
if trigger.args[0] == '+':
sasl_token = _make_sasl_plain_token(sasl_username, sasl_password)
LOGGER.info("Sending SASL Auth token.")
send_authenticate(bot, sasl_token)
return
return
else:
# Not an expected response from the server
# Send `authenticate-abort` command
# See https://ircv3.net/specs/extensions/sasl-3.1#the-authenticate-command
bot.write(('AUTHENTICATE', '*'))
return

# TODO: Implement SCRAM challenges

Expand Down

0 comments on commit 997a4b3

Please sign in to comment.