Repository navigation
fix(rest): verify dual-audience (WBA-shape) request signatures - #279
Open
SergeevDmitry wants to merge 2 commits into
Open
SergeevDmitry wants to merge 2 commits into
SergeevDmitry wants to merge 2 commits into
Conversation
signatures.md recommends one dual-audience signature for Web Bot Auth interop and says a UCP verifier accepts it. That signature covers "signature-agent";key="sig1" and carries tag="web-bot-auth" with the key's RFC 7638 thumbprint as keyid. parse_signature_input returned None for any component with a parameter, so such a request was answered signature_missing. Select the Dictionary member a key parameter names (RFC 9421 Section 2.1.2), require signature-agent coverage when the header is present, and under tag="web-bot-auth" require keyid to be the key's thumbprint, as the verification routine in signatures.md does. A component parameter other than key now skips only that signature, not the whole header.
The Node verifier had the same gap as the Python one: a component with a parameter made parseSignatureInput return null, so the dual-audience signature signatures.md recommends was answered signature_missing. Mirror the Python change: Dictionary member selection for the key parameter (RFC 9421 Section 2.1.2), signature-agent coverage when the header is present, the RFC 7638 keyid check under tag="web-bot-auth", and skipping only the signature that uses another component parameter. buildSignatureBase takes a name or a [name, key] pair.
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.
Description
signatures.mdrecommends a single dual-audience signature for Web Bot Auth interop, one that both a UCP verifier (resolving viaUCP-Agent) and a WBA verifier accept (L246-L252). It covers"signature-agent";key="sig1"and carriestag="web-bot-auth"with the key's RFC 7638 thumbprint askeyid. For a UCP verifier the spec says thekeyparameter "selects a Dictionary member per RFC 9421 §2.1.2" (L368-L372), and its verification routine requiressignature-agentcoverage when the header is present and the thumbprintkeyidundertag="web-bot-auth"(L693-L698, L717).Both reference verifiers return no parse result for any component with a parameter (ucp_signing.py L217, signature.ts L170), so the recommended signature is answered
signature_missing. The code lists this as a follow-up (L324); this PR is that follow-up, for Python and Node.The spec's example request, signed with the RFC 9421
test-key-ed25519key, whose thumbprint is the example'skeyid:mainsignature_missingkeyidis not the key's thumbprintsignature_missingsignature_invalidSignature-Agentpresent but not coveredsignature_invalid(coverage)"@method";sfnext to the valid onesignature_missingThe third row is a coverage gap on
main: a signature that leaves the request'sSignature-Agentunsigned is accepted.Changes, the same in
rest/python/server/ucp_signing.pyandrest/nodejs/src/utils/signature.ts:Signature-Inputparser keeps each component'skeyparameter. A component with any other parameter marks only its own signature unsupported, which is then skipped like any other failing candidate (RFC 9421 Section 4.3) instead of failing the whole header.(name, key)resolves to that Dictionary member's value, re-serialized without optional whitespace, as RFC 9421 Section 2.1.2 defines it (dictionary_member/dictionaryMember).required_components/requiredComponentsrequiresignature-agentwhen the header is present.tag="web-bot-auth",keyidmust equal the RFC 7638 thumbprint of the resolved JWK (jwk_thumbprint/jwkThumbprint)."signature-agent";key="sig1"for such a component.buildSignatureBasein Node is generic over the component type, so existing callers are unchanged.createdandexpiresare not enforced; the spec leaves that to the application (L374-L379).Testing:
ucp_signing_test.pyandtest/signing.test.ts: RFC 7638 vectors (RFC 8037 A.3 and the spec'skeyid), Dictionary member serialization,keyparameter parsing, and the four rows above against a signature base built by hand in the test.pytest366 passed;ruff checkandruff format --checkclean (ruff 0.17.3). The new tests fail onmain.npm run build(tsc, which also type-checks the tests) andnpm test182 passed;prettier@4.0.0-alpha.8 --checkclean. Onmainthe test file does not load, since the new helpers do not exist there; run against themainverifier, the dual-audience and;sfcases answersignature_missing.Category (Required)
ucp-schematool (resolver, linter, validator). (Requires Maintainer approval)Related Issues
None.
Checklist
!for breaking changes).