Title: Implement RFC 9421 request signing (AdCP 3.0 optional profile) · Issue #183 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: Implement RFC 9421 request signing (AdCP 3.0 optional profile) · Issue #183 · adcontextprotocol/adcp-client-python
X Title: Implement RFC 9421 request signing (AdCP 3.0 optional profile) · Issue #183 · adcontextprotocol/adcp-client-python
Description: Paired SDK work for the AdCP RFC 9421 request-signing profile in adcp#2323 (3.0 optional, 4.0 required — tracked in adcp#2307). Scope Implement client signing and server verification for outgoing/incoming AdCP requests per the Signed Req...
Open Graph Description: Paired SDK work for the AdCP RFC 9421 request-signing profile in adcp#2323 (3.0 optional, 4.0 required — tracked in adcp#2307). Scope Implement client signing and server verification for outgoing/i...
X Description: Paired SDK work for the AdCP RFC 9421 request-signing profile in adcp#2323 (3.0 optional, 4.0 required — tracked in adcp#2307). Scope Implement client signing and server verification for outgoing/i...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/183
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Implement RFC 9421 request signing (AdCP 3.0 optional profile)","articleBody":"Paired SDK work for the AdCP RFC 9421 request-signing profile in adcp#2323 (3.0 optional, 4.0 required — tracked in adcp#2307).\n\n## Scope\n\nImplement client signing and server verification for outgoing/incoming AdCP requests per the [Signed Requests (Transport Layer)](https://adcontextprotocol.org/docs/building/implementation/security#signed-requests-transport-layer) profile. Conforms against the test vectors shipped in the spec repo at `static/test-vectors/request-signing/`.\n\n## Deliverables\n\n### Client-side (signer)\n\n- `AdcpClient(signing_key=..., agent_url=...)` — optional keyword-only params. `signing_key` is a `cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey` or `EllipticCurvePrivateKey` (P-256).\n- On every outgoing request to operations in the seller's advertised `request_signing.required_for` or `supported_for`, compute the canonical signature base per RFC 9421 §2.5 with the covered components mandated by the AdCP profile:\n - Always: `@method`, `@target-uri`, `@authority`\n - With body: `content-type`\n - With body AND seller advertises `covers_content_digest: \"required\"`: `content-digest` (RFC 9530, sha-256)\n - If seller advertises `covers_content_digest: \"forbidden\"`, signer MUST NOT cover `content-digest`.\n- Attach `Signature`, `Signature-Input`, and (when covered) `Content-Digest` headers.\n- Sign with Ed25519 (default via `cryptography`) or ES256 (P-256 ECDSA). For ES256, encode r||s per RFC 9421 §3.3.2 — NOT DER. `cryptography`'s default is DER; convert.\n- Honor the profile's sig-params: `created`, `expires` (≤ `created + 300`), `nonce` (≥ 128 bits, base64url), `keyid` (matches a JWK `kid` in the signer's published JWKS), `alg` (`ed25519` or `ecdsa-p256-sha256`), `tag` (exactly `adcp/request-signing/v1`).\n- CLI helper: `python -m adcp.generate_signing_key [--alg ed25519|es256]` → writes PEM + prints JWK with `adcp_use: \"request-signing\"` for publication at `jwks_uri`.\n\n### Server-side (verifier)\n\n- `adcp.signing` module: middleware for Flask, FastAPI, Starlette.\n- Signature: `def verify_request_signature(request, *, options: VerifyOptions) -> VerifiedSigner`.\n- Implement the 13-step verifier checklist + pre-check from the spec:\n 0. Pre-check: reject unsigned request to operation in `required_for` with `request_signature_required`. Reject if `Signature` present without `Signature-Input` (or vice versa) — the downgrade loophole vector 019 catches this.\n 1. Parse `Signature-Input` / `Signature`\n 2. Params presence (all 6 required)\n 3. Tag check (`adcp/request-signing/v1`)\n 4. Alg allowlist\n 5. Window (including `expires > created`, ±60s skew, ≤ 300s max)\n 6. Covered components (considering `covers_content_digest` policy: `required` / `forbidden` / `either`)\n 7. Resolve `keyid` → JWKS → agent entry (with SSRF validation per AdCP webhook SSRF rules and 30-second JWKS refetch cooldown BETWEEN refetches)\n 8. Check `use: \"sig\"`, `key_ops` contains `verify`, `adcp_use == \"request-signing\"` (note: strip `adcp_use` before feeding the JWK to strict consumers like PyJWT's strict modes — retain for policy check)\n 9. Revocation check (BEFORE crypto verify to avoid cheap amplification)\n 10. Cryptographic verification of the signature base\n 11. Recompute and compare `content-digest` when covered\n 12. Replay dedup on `(keyid, nonce)`\n 13. Insert into replay cache only after all prior steps pass\n- Pluggable JWKS cache + SSRF-validated fetcher. Recommend `httpx` with a custom transport that validates the resolved IP against reserved ranges before connecting.\n- Pluggable replay store (in-memory `cachetools.TTLCache` default; Redis adapter via `redis-py` for multi-instance).\n- Return `VerifiedSigner(key_id=..., agent_url=..., verified_at=...)` for downstream authorization.\n- Emit typed errors matching the spec error taxonomy:\n - `request_signature_required`\n - `request_signature_header_malformed`\n - `request_signature_params_incomplete`\n - `request_signature_tag_invalid`\n - `request_signature_alg_not_allowed`\n - `request_signature_window_invalid`\n - `request_signature_components_incomplete`\n - `request_signature_components_unexpected`\n - `request_signature_key_unknown`\n - `request_signature_key_purpose_invalid`\n - `request_signature_invalid`\n - `request_signature_digest_mismatch`\n - `request_signature_replayed`\n - `request_signature_key_revoked`\n - `request_signature_revocation_stale`\n - `request_signature_jwks_unavailable`\n - `request_signature_jwks_untrusted`\n- Return 401 with `WWW-Authenticate: Signature error=\"\u003ccode>\"` on rejection. Realm MUST be omitted per spec.\n- Respect the \"one Signature-Input label per request\" rule — verify `sig1` and ignore additional labels.\n\n### Conformance tests\n\n- Consume the test vectors shipped in the spec repo under `static/test-vectors/request-signing/`:\n - 19 **negative** vectors — the verifier MUST return `expected_outcome.error_code` exactly. `failed_step` is informational.\n - 3 **positive** vectors — the verifier MUST accept. Ed25519 signatures are byte-exact reproducible (determinism); ES256 is verify-only (random-k is conformant for verify).\n- Run order per the README's \"Recommended run order\" section: positives first, then parse-level negatives, then semantic, then key-path, then crypto/stateful.\n- Add end-to-end test: spin up FastAPI with `verify_request_signature`, point an `AdcpClient` at it with `signing_key`, drive a `create_media_buy`. Exercise `covers_content_digest: \"either\"` and `\"required\"`.\n\n### Docs\n\n- README section on \"Signing in 3.0\" — how to opt in as a buyer or a seller.\n- Python examples in the AdCP quickstart showing the 5-line integration.\n\n## Library recommendations\n\n- **RFC 9421 canonicalization + verification**: [`http-message-signatures`](https://pypi.org/project/http-message-signatures/) (PyPI) is the most mature Python implementation. Validate its output against the `expected_signature_base` in each positive vector — the library supports pluggable covered-component selection and sig-params, so configuring it for the AdCP profile is straightforward.\n- **JWK / JWKS**: [`python-jose`](https://pypi.org/project/python-jose/) or [`cryptography`](https://pypi.org/project/cryptography/) directly. `python-jose` preserves unknown JWK members (`adcp_use`) on parse. `cryptography`'s JWK handling is stricter; may need to strip `adcp_use` before conversion.\n- **Content-Digest (RFC 9530)**: small custom impl — `hashlib.sha256(body).digest()` then base64-encode per RFC 8941 structured dictionary shape (`sha-256=:\u003cb64>:`).\n- **SSRF-validated fetch**: `httpx.HTTPTransport` with custom `connect` hook, or a socket-level wrapper that validates the resolved IP against reserved ranges per the [Webhook URL validation](https://adcontextprotocol.org/docs/building/implementation/security#webhook-url-validation-ssrf) rules.\n- **Ed25519/ES256**: `cryptography.hazmat.primitives.asymmetric.ed25519` and `.ec`. Note: `cryptography` signs ECDSA with DER by default; you need to convert to IEEE P1363 (r||s) for RFC 9421 — use `cryptography.hazmat.primitives.asymmetric.utils.decode_dss_signature` to get `(r, s)` then big-endian pack.\n\n## Ordering\n\n1. Implement the verifier first — it consumes the conformance vectors directly and validates the spec.\n2. Implement the signer.\n3. End-to-end tests + docs.\n\n## Why this belongs in adcp-client-python\n\nThe spec is language-agnostic; the SDK is what Python implementers actually integrate. Shipping signing support in the SDK is what turns \"the profile is optional in 3.0\" from a theoretical statement into something Python-based counterparties can pilot. Without this, 4.0 required-signing lands on unimplemented libraries.\n\n## References\n\n- Spec PR: https://github.com/adcontextprotocol/adcp/pull/2323\n- v4.0 RFC: https://github.com/adcontextprotocol/adcp/issues/2307\n- TypeScript SDK equivalent: https://github.com/adcontextprotocol/adcp-client/issues/575\n- Go SDK equivalent: https://github.com/adcontextprotocol/adcp-go/issues/43\n- Governance JWS profile (shares JWKS substrate): adcp#2316\n- Follow-up 3.x: `warn_for` capability at adcp#2326; others at adcp#2324, #2325, #2327, #2328","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-04-18T18:48:03Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/183"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2b95836c-6259-03e7-d18d-74f3edbbe8d8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF0E:296654:BF921F:101D0A3:6B00F8D9 |
| html-safe-nonce | 20723c9ace1222a52e3fbe478f22190cb2773cef327c3ff25cdb78cd5c38cd69 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjBFOjI5NjY1NDpCRjkyMUY6MTAxRDBBMzo2QjAwRjhEOSIsInZpc2l0b3JfaWQiOiI5MDY0NjQyOTk2NzE2MjM5MDY2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 95ac2252d2b2891f90af08a0876c02a1b4a91490607d4704fe7bc4458bd7c23b |
| hovercard-subject-tag | issue:4288881350 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/183/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0ad64fae63d9d83f40bb7779a6b5af643897918bf3a8593baeb2b856ec6670ab/adcontextprotocol/adcp-client-python/issues/183 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0ad64fae63d9d83f40bb7779a6b5af643897918bf3a8593baeb2b856ec6670ab/adcontextprotocol/adcp-client-python/issues/183 |
| og:image:alt | Paired SDK work for the AdCP RFC 9421 request-signing profile in adcp#2323 (3.0 optional, 4.0 required — tracked in adcp#2307). Scope Implement client signing and server verification for outgoing/i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bokelley |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| turbo-cache-control | no-preview |
| go-import | github.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git |
| octolytics-dimension-user_id | 221690821 |
| octolytics-dimension-user_login | adcontextprotocol |
| octolytics-dimension-repository_id | 1090305973 |
| octolytics-dimension-repository_nwo | adcontextprotocol/adcp-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1090305973 |
| octolytics-dimension-repository_network_root_nwo | adcontextprotocol/adcp-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width