Skip to content

Commit eaaa1a2

Browse files
committed
Fix security issue with renewing expired tokens
See: GHSA-9wgg-m99q-hhfc
1 parent df0fda4 commit eaaa1a2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

emailproxy.py

+7-5
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-11-18' # ISO 8601 (YYYY-MM-DD)
9+
__version__ = '2023-11-19' # 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
@@ -768,12 +768,14 @@ def get_account_with_catch_all_fallback(option):
768768
AppConfig.save()
769769

770770
else:
771-
# we used to keep tokens until the last possible moment here, but it is simpler to just obtain a
772-
# new one within TOKEN_EXPIRY_MARGIN, particularly when in CCG or ROPCG flow modes where getting
773-
# a new token involves no user interaction (note that in interactive mode it would be better to
771+
# avoid trying invalid (or soon to be) tokens - we used to keep tokens until the last possible
772+
# moment here, but it is simpler to just obtain a new one within TOKEN_EXPIRY_MARGIN, especially
773+
# when in CCG/ROPCG/Google Cloud service account modes, for all of which getting a new token
774+
# involves no interaction from the user (note that in interactive mode it would be better to
774775
# request a new token via the user before discarding the existing one, but since this happens
775776
# very infrequently, we don't add the extra complexity for just 10 extra minutes of token life)
776-
access_token = None # avoid trying invalid (or soon to be) tokens
777+
cryptographer.decrypt(access_token) # check request is valid (raises InvalidToken on failure)
778+
access_token = None
777779
else:
778780
access_token = cryptographer.decrypt(access_token)
779781

0 commit comments

Comments
 (0)