Bump PyJWT to 2.15.1 and test real token validation - #11
Merged
Merged
Conversation
PyJWT 2.10.1 carries 14 open advisories (1 critical, 4 high). 2.15.1 is the first release clear of all of them. Not all apply here. validate_access_token decodes with algorithms=["RS256", "ES256"], so the HS256 key-confusion forgeries (the critical one included) need a mixed algorithm list this code does not use; the new tests confirm they fail on both versions. What does apply is PyJWKClient handling attacker tokens before any signature check: JWKS re-fetches on unknown `kid` values and the RecursionError in get_signing_key_from_jwt. The existing OAuth tests replace validate_access_token with a fake, so the real verification path had no coverage. tests/test_oauth_tokens.py drives it with RS256 tokens and an in-memory JWKS through the real PyJWKClient: valid, expired, wrong audience/issuer, another key under the same kid, missing sub, missing scope (403), HS256 signed with the public key as PEM, CRLF PEM and DER, alg=none, and garbage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PyJWT[crypto]goes from 2.10.1 to 2.15.1. 2.15.1 is the first release clear of all 14 open Dependabot alerts onmain(1 critical, 4 high, 8 moderate, 1 low). All 14 are PyJWT.tests/test_oauth_tokens.pyis the first real coverage ofvalidate_access_token.How much of this applied to us
Not all of it, and it's worth being precise:
validate_access_tokenpassesalgorithms=["RS256", "ES256"], so an HS256 token is refused before any key handling. The new tests confirm these forgeries fail on both 2.10.1 and 2.15.1.validate_access_tokenhands an attacker-supplied token toPyJWKClient.get_signing_key_from_jwtbefore any signature check. That's where unbounded JWKS re-fetches on unknownkidvalues happen, along with the pre-verificationRecursionErrorDoS. On a public OAuth deployment (render.yaml), anyone can send those tokens.Tests
The existing OAuth tests replace
validate_access_tokenwith a fake, so the real verification path had no coverage. The new tests drive it with RS256 tokens and an in-memory JWKS, through the realPyJWKClient(onlyfetch_datais stubbed). They cover:kid, missingsub,alg=none, and garbage.Results:
After merge
The running local service uses API-key auth, not OAuth, so it never reaches this code. It'll pick up the new version on its next reinstall. The Render deployment should be redeployed.
🤖 Generated with Claude Code