Skip to content

Commit 67599f8

Browse files
committed
[Security] Specify the list of accepted algorithms in jwt.decode() calls to mitigate https://nvd.nist.gov/vuln/detail/CVE-2024-33663.
We specify the accepted algorithms to be [RS256] as suggested by Amazon Cognito.
1 parent 8e6798d commit 67599f8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

api/PclusterApiHandler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@
6262
JWKS_URL = os.getenv("JWKS_URL",
6363
f"https://cognito-idp.{REGION}.amazonaws.com/{USER_POOL_ID}/" ".well-known/jwks.json")
6464

65+
6566
def jwt_decode(token, audience=None, access_token=None):
66-
return jwt.decode(token, requests.get(JWKS_URL).json(), audience=audience, access_token=access_token)
67+
return jwt.decode(
68+
token, requests.get(JWKS_URL).json(), audience=audience, access_token=access_token, algorithms=["RS256"]
69+
)
6770

6871

6972
def setup_api_credentials(role_arn, credential_external_id=None):

0 commit comments

Comments
 (0)