Skip to content

Commit 7e37db0

Browse files
committed
Properly match RFC 4422's sasl-mech not RFC 4954's xchar
Resolves https://github.com/simonrob/email-oauth2-proxy/security/code-scanning/3
1 parent 8b2c0ad commit 7e37db0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

emailproxy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__author__ = 'Simon Robinson'
77
__copyright__ = 'Copyright (c) 2023 Simon Robinson'
88
__license__ = 'Apache 2.0'
9-
__version__ = '2023-12-20' # ISO 8601 (YYYY-MM-DD)
9+
__version__ = '2023-12-21' # ISO 8601 (YYYY-MM-DD)
1010
__package_version__ = '.'.join([str(int(i)) for i in __version__.split('-')]) # for pyproject.toml usage only
1111

1212
import abc
@@ -1938,8 +1938,9 @@ def process_data(self, byte_data):
19381938
if self.client_connection.connection_state is SMTPOAuth2ClientConnection.STATE.EHLO_AWAITING_RESPONSE:
19391939
# intercept EHLO response AUTH capabilities and replace with what we can actually do - note that we assume
19401940
# an AUTH line will be included in the response; if there are any servers for which this is not the case, we
1941-
# could cache and re-stream as in POP. Formal syntax: https://tools.ietf.org/html/rfc4954#section-8
1942-
updated_response = re.sub('250([ -])AUTH( [!-*,-<>-~]+)+', r'250\1AUTH PLAIN LOGIN', str_data,
1941+
# could cache and re-stream as in POP. AUTH command: https://datatracker.ietf.org/doc/html/rfc4954#section-3
1942+
# and corresponding formal `sasl-mech` syntax: https://tools.ietf.org/html/rfc4422#section-3.1
1943+
updated_response = re.sub(r'250([ -])AUTH(?: [A-Z\d_-]{1,20})+', r'250\1AUTH PLAIN LOGIN', str_data,
19431944
flags=re.IGNORECASE)
19441945
updated_response = b'%s\r\n' % updated_response.encode('utf-8')
19451946
if self.starttls_state is self.STARTTLS.COMPLETE:

0 commit comments

Comments
 (0)