Repository navigation
fix(checker): deprecate a second checker of the same claim or header parameter - #778
Merged
Merged
Conversation
…parameter ClaimCheckerManager and HeaderCheckerManager index their checkers by the name each one covers. When two checkers of the list cover the same claim or header parameter, the second replaces the first, which never runs, and nothing tells the application. With an ExpirationTimeChecker followed by a CallableChecker on "exp", an expired token passes; in the other order, a token valid for ten years passes. In a header checker manager, the replacement can also drop the protected-only requirement of the parameter. All the construction paths end in these two constructors: the factories of the library and of the bundle, the jose.checkers.claims and jose.checkers.headers managers, the header_checkers of the loaders, and the typ option, whose TypeChecker replaces any typ checker listed in the headers of the same manager. Building a manager with a second checker for a name already covered now triggers a deprecation that names the claim or header parameter and the classes of the two checkers. The last checker is still the one kept. The same instance listed twice, for instance under two aliases, stays silent. 5.0.0 will throw instead. Two functional tests reproduce the bundle cases of the report: the claims exp, iat, nbf and max_lifetime, where max_lifetime is a CallableChecker on "exp", and a typ checker listed next to the typ option. Reported by Anthropic's OSS Scanner (ANT-2026-YWJFJRRB). Fixes #756
* origin/4.3.x: Name both key orders for the sender key of decrypt() Throw the Jose exception from the loader factories fix(bundle): keep the key attribute of the alias lists fix(key-mgmt): keep the JKU/X5U requests whose headers cannot be serialized fix(encryption): accept the AES-CBC-HMAC tags of earlier versions until 5.0.0 Only wrap the x5u entries that start with file:// fix(bundle): deprecate tagging two services with the same alias fix(bundle): stop merging the alias lists of a service by position fix(encryption): AL of AES-CBC-HMAC is the length of the whole AAD fix(core): reject the bytes outside the alphabet on the sodium path Compute ECDH-SS from the two static keys only fix(key-mgmt): include the request headers in the key of the JKU/X5U cache fix: refuse header checkers that a loader factory cannot apply Keep an x5u entry from naming a local file fix(checker): accept a value only when the callable returns true # Conflicts: # tests/Bundle/JoseFramework/TestBundle/Resources/config/services.php
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.
Fixes #756.
The defect
ClaimCheckerManagerandHeaderCheckerManagerindex their checkers bysupportedClaim()/supportedHeader(). When two checkers of the list cover the same name, the second replaces the first, which never runs, and nothing is thrown or logged:In the other order, a token valid for ten years passes, so no order enforces both rules. In a header checker manager, the replacement can also drop the protected-only requirement:
AudienceChecker('api', true)followed byAudienceChecker('api')accepts an unprotectedaud.All the construction paths end in these two constructors: the factories of the library and of the bundle,
jose.checkers.claims/jose.checkers.headers, theheader_checkersof the loaders, and thetyp:option, whose generatedTypeCheckerreplaces anytypchecker listed inheaders:of the same manager.The fix
As proposed in the issue, for 4.3.0:
The 5.0.0 part, an
InvalidArgumentExceptioninstead of the deprecation, is #783 on5.0.x.Not in 4.2.7: the fix is a deprecation, and the patch branches take none. The issue moves to the 4.3.0 milestone with this PR.
Behaviour change
No public or protected signature changes.
Tests
ClaimCheckerManagerTestand the newHeaderCheckerManagerTest: the notice for two audiences, forexpfollowed by aCallableCheckeronexp, for twoTypeCheckers, and for a protectedaudchecker replaced by an unprotected one; the behaviour kept (the replaced checker still never runs, with exactly one notice); the same instance listed twice stays silent.claims: ['exp', 'iat', 'nbf', 'max_lifetime']withmax_lifetimeaCallableChecker('exp', …)service, and atypchecker listed inheaders:next to thetyp:option. Both managers are new entries ofconfig_test.yml; the checker is a new service of the test bundle.typ.*checkers.Verification
exp_twicemanager holds theCallableCheckerand noExpirationTimeChecker. With the fix, the 106 tests oftests/Component/Checkerandtests/Bundle/JoseFramework/Functional/Checkerpass.trigger_deprecation()shows that only the new tests trigger the notice.phpqa:8.4image.src/, dumped by reflection, is identical to the base. A probe over 13 cases (both managers, both library factories, the two deprecated bundle subclasses, a generator, one checker under two aliases) returns the same results on the base and on the branch. Only the notice count differs, and only where a checker is replaced.trigger_deprecation()comes fromsymfony/deprecation-contracts, whichweb-token/jwt-library, the split that ships the managers, already requires (^2.5|^3.0). The lowest-deps job passes.typ:option. It triggers the notice only when the application also lists atypchecker inheaders:. The managers of the test configuration that usetyp:alone trigger nothing.5.0.xwithout conflict. The 5.0.0 part is fix(checker): reject a second checker of the same claim or header parameter #783 (draft).Found by the Anthropic OSS Scanner (ANT-2026-YWJFJRRB).