Repository navigation
SD-JWT: refuse at issuance the SD-JWTs the Holder and the Verifier reject - #809
Merged
Merged
Conversation
…er reject SDJWTIssuer issued SD-JWTs whose processed payload is deeper than the 64 levels of DisclosureProcessor, or whose Disclosures hold more JSON values than the budget of BoundedJsonDecoder: the Holder and the Verifier then refused them. Before signing, the Issuer now parses an SD-JWT that has the payload, the Disclosures, the serialization and the unprotected headers of the one to issue, then processes it as SDJWT::select() does. Both bounds come from the classes that enforce them, and such claims are refused with an InvalidArgumentException. Fixes #805
Anonymous readonly classes need PHP 8.3: the property is readonly instead, as in SDJWTIssuerTest.
Spomky
added a commit
to Spomky-Labs/docs
that referenced
this pull request
Nov 9, 2026
…ould reject for its size Before signing, SDJWTIssuer::issue() and issueJson() now parse and process the SD-JWT to issue, with placeholder signatures, as the Holder and the Verifier do (web-token/jwt-framework#809). A Processed SD-JWT Payload of more than 64 levels, or Disclosures over the budget of 4096 JSON values, is refused with an InvalidArgumentException that names the bound. The page gave that budget as about 1,300 claims in the compact format and about 1,000 in the JWS JSON serialization. It now gives the figures measured on 4.3.x (85d5df0a): 1,365 claims or 2,048 array elements in the compact format, and 1,022 claims or 1,363 array elements in the JWS JSON serialization with one signature.
This was referenced Nov 9, 2026
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 #805.
The defect
Since #795,
SDJWTVerifier::verify(),verifyWithKeyBinding()andSDJWT::select()reject a processed payload deeper than 64 levels, andSDJWT::fromString()decodes at most 4,096 JSON values per SD-JWT.SDJWTIssuerchecked neither bound. It issued SD-JWTs that the Holder and the Verifier of this library then refused, so the error appeared at presentation or verification, possibly on another system, instead of at issuance.The fix
Before signing,
issue()andissueJson()build an SD-JWT with the encoded payload and the Disclosures of the one to issue. It also has the same serialization and the same unprotected headers. The protected headers and signatures are placeholders, which are base64url strings and hold no JSON value. The Issuer then:SDJWT::fromString(), as the Holder and the Verifier do. In the JWS JSON serialization, the values of the JSON document count too, including the unprotected headers and the commas of thedisclosuresarray;select()and no claim path, the processing the Holder runs to select Disclosures.Both bounds therefore come from the classes that enforce them, and nothing is copied. Depth is counted the way the Verifier counts it. An object counts with the levels of its JSON, and a
Disclosableadds no level. The claims are refused with anInvalidArgumentException:The processed payload of the SD-JWT is nested more than 64 levels deep.This is the message of the processor, which stays chained as the previous exception;The Disclosures of the SD-JWT hold more JSON values than the 4096 the Holder and the Verifier decode.TheInvalidSerializationExceptionof the parser stays chained. This message names the bound, whichThe Disclosure is not valid JSON./Unsupported input.did not.Measured with an ES256 key, 1 to 3 decoys:
cnf)Tests
IssuerBoundsTesthas 23 cases:SDJWT::fromString()can parse the result. This is checked with no unprotected header, with one, and with two general signatures (3 cases);JsonSerializableare counted (1 case);issueJson()keep working. They are collected under a string key, which the placeholder has to turn into a list (1 case).On 4.3.x without the fix, all 14 refusal cases fail and the 7 acceptance cases pass. The two cases for the chained exception and the named signatures were added afterwards.
Infection on the diff, with a 60 s timeout: 25 of 30 mutants are killed. The 5 that escape are the
0code of the twoInvalidArgumentException(4, equivalent, and no test in the repository asserts an exception code) and thearray_values()call. The named-signature case now covers that call: it fails without it.Compatibility
The SD-JWT component has not been released yet: 4.3.0 will be its first release. No signature changes, nothing is deprecated, and no dependency is added to the split. Only private methods and a private constant are added to
SDJWTIssuer.SDJWTIssuer,SDJWTIssuerInterface,SDJWTandDisclosureProcessorby reflection, on 4.3.x and on this branch. The two dumps are identical (24 entries).phpqa:8.4.