Repository navigation
fix: RARSet without HTML escaping; typed-nil trust fields; RAR hook docs - #766
Merged
Merged
Conversation
RARSet re-encoded details with json.Marshal, which escapes '<', '>' and '&' as six-byte <-style sequences. A consent page that reads requested details with RARGet and grants them re-encoded with RARSet, as the RAR guide shows, could therefore grow a request that was validated within MaxBytesPerObject and the registry's total bound past them, and CompleteAuthorization then refused the grant after the user had consented. RARSet now encodes with the same unescaped encoder the server uses for granted and stored details, so the granted bytes and the token's claim match what was validated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
X5CAttesterChain.validate called Revocation's own validate before its typed-nil check, so New panicked on a nil *ClientCertificateCRLs instead of returning an error. TrustedClientCAs.validate had the same call with no typed-nil check at all. Both now refuse a typed nil in an interface field first, naming the field, and RegisteredAttesterKeys refuses a typed-nil Keys the same way rather than failing on the first attestation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spell out that a nil ValidateNarrowing falls back to ValidateGrant and fails open at the token endpoint for server-minted members; that typed hooks can't tell an absent or null member from its zero value and compare floats after rounding; that greedy matching depends on the order a client sends objects in; and that an embedder forwarding a client's authorization_details to IssueAccessToken or IssueRefreshToken should run RARRegistry.ParseRequest on them itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
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 changed
extension.RARSetno longer HTML-escapes (fix). RARSet re-encoded detail objects withjson.Marshal, which turns each<,>and&into a six-byte<-style escape. The documented consent pattern (RARGet, show, RARSet,GrantedAuthorization.AuthorizationDetails) could therefore grow a request validated withinMaxBytesPerObjectand the registry's total bound past them, soCompleteAuthorizationrefused the grant after the user had consented. When the grant did fit, the token carried escaped bytes instead of the validated ones. RARSet now usesstrictjson.MarshalUnescapedfor the value, thetypemember and the assembled object, the same encoder v0.67.2 introduced for granted and stored details.Other extension encode paths checked and left unchanged:
extension.Set: it size-checks its own output, and the client sends that output as-is; the client's request encoding re-escapes it anyway, so switching Set alone would let it pass values the server then refuses.withoutTypeMemberandcompare's canonical encoding: their output is only decoded or compared, never size-checked or issued.Values/RARValues.MarshalJSON(interaction storage): restored objects are only read back through Get/RARGet.Typed-nil trust fields (fix).
X5CAttesterChain.validatecalledRevocation's ownvalidatebefore its typed-nil check, soserver.Newpanicked on(*ClientCertificateCRLs)(nil).TrustedClientCAs.validatemade the same call and had no typed-nil check. Both now refuse a typed nil in an interface field first, naming the field.RegisteredAttesterKeysrefuses a typed-nilKeysthe same way, instead of failing on the first attestation.Docs. The
RARDefinitiondoc comments anddocs/guides/rar.mdnow spell out four pitfalls:ValidateNarrowingfalls back toValidateGrant, which fails open at the token endpoint for server-minted members. Such definitions must setValidateNarrowing.Validateto require the member, or a pointer,json.Numberorjson.RawMessagefield.authorization_detailstoIssueAccessToken/IssueRefreshTokenshould runRARRegistry.ParseRequeston them itself.Tests
TestAuthorizationDetailsKeepTheirBytesThroughRARSet(server): a request full of<>&near tight bounds is accepted at PAR and granted through RARGet then RARSet. The access token claim must equal the validated bytes. Before the fix,CompleteAuthorizationreturned a local error.TestRARSetDoesNotEscapeHTML(extension).TestNewRefusesTypedNilTrustFields: covers typed nils in X5CAttesterChain.Revocation (by value and by pointer), RegisteredAttesterKeys.Keys and TrustedClientCAs.Revocation. Each must be refused with an error naming the field. Before the fix, three of them panicked and one was accepted.🤖 Generated with Claude Code