fix(merchant-backend): make signature verifier RFC 9421-conformant - #21
Open
chopmob-cloud wants to merge 1 commit into
Open
fix(merchant-backend): make signature verifier RFC 9421-conformant#21chopmob-cloud wants to merge 1 commit into
chopmob-cloud wants to merge 1 commit into
Conversation
chopmob-cloud
force-pushed
the
fix/rfc9421-signature-verifier
branch
from
August 4, 2026 06:55
f411e56 to
cd9caa1
Compare
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.
Summary
The merchant backend's signature verifier (
merchant-backend/app/security/signature_verification.py) cannot verify any RFC 9421 HTTP Message Signature, so a signature produced for the CDN proxy is always rejected at the merchant. The merchant backend README states this component provides "RFC 9421 HTTP Message Signatures support" and "Integration with CDN Proxy for signature validation", but the current verifier diverges from RFC 9421 and from the repository's owncdn-proxyreference.Root cause
Comparing the verifier with
cdn-proxy/server.js(parseRFC9421SignatureInput/buildRFC9421SignatureString):@signature-paramsline (RFC 9421 section 2.5). The verifier instead appends barenonce/created/expireslines, so the base it reconstructs can never match what a conformant signer signed. Verification fails for every RFC 9421 signature.("@authority @path"), whereas RFC 9421 and the CDN proxy use individually quoted identifiers("@authority" "@path"). The regex also hardcodes thesig1label and a fixed parameter order, so a conformantSignature-Inputfails to parse at all.algparameter is ignored and only RSA-PSS is handled, so Ed25519 keys (supported by the agent registry and the CDN proxy) cannot be verified.Fix
Bring the verifier in line with the CDN proxy's RFC 9421 implementation, with no change to the
is_trusted_agent(...)or/auth/verify-signaturecontract:@signature-paramsline as the final component, carrying the verbatim signature parameters.alg(rsa-pss-sha256anded25519), with an explicit key type check on each path.Validation
cdn-proxy/server.js'sbuildRFC9421SignatureStringoutput for the same inputs.POST /api/auth/verify-signatureendpoint: a conformant RSA-PSS and Ed25519 signature is accepted, while tampered, replayed, and expired signatures are rejected. The pre-fix verifier rejects the same valid signature with "Invalid signature format".Signature-Inputparameters are all rejected. Verified on Python 3.12 with cryptography 41 and 48.