Repository navigation
fix: reject malformed token and DPoP proof input with SDK errors - #151
Merged
Merged
Conversation
nandan-bhat
reviewed
Oct 28, 2026
… the interpreter limit The non-finite iat error message now says a finite number is required.
nandan-bhat
approved these changes
Oct 28, 2026
rmad17
added a commit
that referenced
this pull request
Oct 29, 2026
Co-Authored-By: Claude <noreply@anthropic.com>
Merged
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.
📋 Changes
This PR makes
verify_access_token(),verify_dpop_proof()andverify_request()reject malformed tokens and DPoP proofs withVerifyAccessTokenErrororInvalidDpopProofError. Previously several shapes raisedAttributeError,TypeErrororValueErrorinstead, which callers that only catch the SDK's own errors did not handle.🐛 Bug Fixes
null) is rejected. Nesting too deep for the JSON parser is also rejected.alg: A header whosealgis not a string raisesVerifyAccessTokenError.expandnbf: A non-numeric or non-finiteexpraisesVerifyAccessTokenError("Invalid 'exp' claim in token"). A non-finitenbfis rejected the same way.jwkthat cannot be imported, raisesInvalidDpopProofError.htmand a non-finiteiatraiseInvalidDpopProofError.decrypt()raisesValueErrorfor a stored value whose header is not a JSON object, andsession_fingerprint()falls back to the SHA-256 of the token for any payload it cannot parse.expires_infrom the token endpoint now raisesApiErrorwith codeinvalid_responseinget_access_token_for_connection()andget_client_credentials_token(), asget_token_by_exchange_profile()already did.🔧 API Changes
get_unverified_header()andget_unverified_payload()now raiseValueErrorwhen the segment is not a JSON object or is nested too deeply. They previously returned the decoded value as is. These helpers are not exported from the package root.expset totrueorfalsenow raises "Invalid 'exp' claim in token". It previously raised "Token is expired".expset tonullor a string now raisesVerifyAccessTokenError. It previously raisedTypeError.exp,nbfandiatvalues, which are now rejected.📖 Documentation
docs/OrganizationPolicy.mdnow states thatget_token_on_behalf_of()andget_access_token_for_connection()apply the organization policy only when atoken_storeis configured andverifiedis not passed.verify_access_token()before the exchange.docs/TokenStorage.mdnow says the indextoken_keystarts with the caller'ssubin plain text.🧪 Testing
Contributor Checklist