Repository navigation
feat(security): clients SHOULD bound agent response size - #8192
Conversation
An agent response is untrusted input. A seller reply of a few tens of megabytes drives a buyer process to multi-gigabyte peak usage once the bytes are decompressed, parsed, and materialized — most of it outside the runtime's managed heap — and the process dies before schema validation or any other control in security.mdx gets to run. Checking size after the body is buffered is too late. Add a "Response Size Bounds" section to the security considerations. Clients SHOULD bound every AdCP response they read on their own call path: MCP tools/call, tools/list, initialize and the transport-native tasks/get and tasks/result results that carry an async CallToolResult; A2A message and task operations including streamed frames; the A2A agent card; and get_adcp_capabilities. A conforming bound is enforced while the body is received, pre-rejects an over-limit or self-contradictory Content-Length, is paired with connect, read-idle and total deadlines, counts raw and decoded bytes with a bounded decoder output buffer, counts every SSE byte against both a per-event and a per-retained-task allowance that carries across resumption, bounds JSON depth and node count after the byte cap passes, errors with a distinct client-local type rather than truncating, defaults to no more than 4 MiB with per-agent and per-call override, and bounds aggregate concurrent exposure. The byte cap bounds ingress; the parse bounds bound memory. At the incident's own materialization ratio a 4 MiB cap alone still reaches a multi-gigabyte peak, so the depth-64 / 100,000-node bounds — the same pairing the attestation task-body and brand.json fetch contracts already require — are what actually close the bug. A precedence paragraph states that path-specific caps govern their own paths (MAX_BRAND_JSON_BYTES, MAX_JWKS_BYTES, MAX_CAPABILITIES_BYTES, the attestation task-body cap, the 4096-byte adcp_error cap, the SSRF fetch caps) and that 4 MiB is a ceiling on a default, not a target. The MCP and A2A response-extraction profiles restate the obligation on their own call paths and both state a 1 MiB whole-call default, so the two transports cannot diverge. Streamable HTTP may answer with a single JSON body or an SSE stream and the bound covers both, so a peer cannot escape it via Content-Type: text/event-stream, by splitting a result across frames, or by forcing a resumption. The pagination guidance now says large-catalog sellers paginate rather than rely on buyers raising limits, and notes that an unpaginated tools/list carrying projected schemas clears 1 MiB on its own. The 3.2 to 3.3 migration guide carries the adopter-facing warning: this tightens a limit, and the failure arrives as a mid-body connection abort rather than an adcp_error. Also fixes a dangling #plan-state-binding anchor in security.mdx, which now points at the governance spec's plan binding and audit section. Refs: #8190 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — docs-only additive PR with no blocking or medium findings.
This PR adds a "Response Size Bounds" security section, MCP/A2A profile restatements, pagination guidance, and a 3.2→3.3 migration entry, plus a test. Key checks:
- Changeset correctness: Present and correctly
minor— this is an additive client-side SHOULD recommendation, not a wire-shape break. Nostatic/schemas/source/**,dist/**, oroneOfsurface touched, so schema↔docs coherence, oneOf discriminator, and artifact-immutability gates are all N/A. - Not breaking-class: Additive normative guidance (SHOULD), not a breaking change — the breaking-class hard gate does not apply.
- High-risk flag: True only because
docs/reference/migration/3-2-to-3-3.mdxis(modified)underdocs/reference/**. Per the decision rules, a modified high-risk file with no medium-or-higher finding is presumed safe — no escalation on the flag alone. - Cross-links verified by reviewer;
#plan-state-binding→#plan-binding-and-auditfix and anchor patterns check out.
No gated paths (gated_paths: false), no no-auto-approve team match. review_decision is REVIEW_REQUIRED, but no hard gate (path-based or prose-based) applies here, so that status does not force escalation.
Only finding is a single Low test-robustness nit (same-page anchor regex excludes underscore anchors), which is omitted from blocking. No rows 1–8 fire → row 9 approve.
Nit (non-blocking): tests/response-size-bounds.test.cjs:594 — same-page anchor test silently skips underscore anchors.
The same-page and cross-page anchor patterns matched only [a-z0-9-], and the slugger stripped underscores, so any anchor containing one was silently skipped rather than validated. That hid three live links in the new Response Size Bounds section, all pointing at #discovering-an-agents-signing-keys-via-brand_json_url. Mintlify keeps underscores in heading slugs, so the slugger now does too and all three patterns accept them. Verified by breaking those anchors: the suite now fails where it previously passed. Addresses the non-blocking review nit on #8192. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Closes #8190.
Why
A seller agent answered a discovery call with a ~17.8 MB response and OOM-killed a hosted compliance worker — 10+ GB peak, most of it outside the JS heap. An agent response is untrusted input, and a client that reads whatever a counterparty sends has handed that counterparty an allocation primitive. The process dies before schema validation, prompt-injection hygiene, or any other control in
security.mdxgets to run.The same requirement is being implemented across the TypeScript, Python, Java and Go SDKs (tracking issue), so this text is what four implementations will be written against.
What
A new Response Size Bounds section in
docs/building/by-layer/L1/security.mdx, under Input Validation. Clients SHOULD bound every AdCP response they read on their own call path, and a conforming bound has nine properties:requests.get()withoutstream=True,BodyHandlers.ofString(),io.ReadAll,await res.json()), because a client using those satisfies "it errors" while violating "it streams" and the author won't notice.Content-Length, and rejectsContent-Length+Transfer-Encoding: chunkedor conflicting duplicates outright.id:/retry:, comments, keepalives), enforced on bytes accumulated rather than events dispatched. The cumulative bound is scoped to bytes the client retains for one task and carries across reconnects,SubscribeToTaskandLast-Event-IDresumption.ResponseTooLarge), explicitly not anadcp_error.code, maps torecovery: "permanent", no auto-retry, and the error must not carry a body excerpt or reach an LLM context.Plus a precedence paragraph (path-specific caps govern their own paths; 4 MiB is a ceiling on a default, not a target), a scope note on inbound pushed deliveries, and a buyer-agent checklist line.
The MCP and A2A response-extraction profiles restate the obligation on their own call paths.
docs/building/concepts/managing-response-size.mdxgets the pagination note, and the 3.2→3.3 migration guide gets the adopter-facing entry.The byte cap alone would not have closed this bug
Worth calling out, because it changed the shape of the change. 17.8 MB → 10 GB is roughly a 575× materialization ratio. At that ratio a 4 MiB cap still reaches ~2.3 GB peak, which still kills a 1–2 GB worker. 4 MiB of densely nested arrays is ~2M JSON nodes at tens of bytes each, and deep nesting exhausts the stack in a recursive-descent parser before any schema check runs.
The byte cap bounds ingress; the depth/node bounds in property 6 bound memory. This repo already requires exactly that pairing everywhere else it bounds untrusted JSON — depth 64 + 100k members for attestation task bodies, depth 32 + node count for brand.json — and the response path, the one that actually killed a process, had neither. Properties 3, 4, 5, 6 and 9 all came from review finding bypasses that were conformant with the first draft.
Prior art
security.mdx§ brand.json trust-root fetch step 4 is the normative template this reuses: streaming cap,Content-Lengthpre-reject, decoded bytes, total deadline covering the body read,Accept-Encoding: identity, nesting depth, node count, bounded concurrent fetches. The migration-guide entry is modeled on#brand-json-size-cap-rises-to-2-mib, the precedent for documenting an asymmetric limit change.Behavior change
This tightens a limit. A buyer SDK that adopts the default fails a response above its limit instead of buffering it, and the failure arrives as a mid-body connection abort rather than an
adcp_errorthe seller can read off the wire. Sellers with large catalogs paginate; buyers who need more from a specific known counterparty raise the limit for that agent or that call, never globally and never by disabling it. Shipped asminor, with the migration-guide entry and changeset note.Tests
tests/response-size-bounds.test.cjs(34 assertions, wired intotest:contracts). Mutation-checked: removing the 4 MiB default, the parse bounds, the deadline, the raw-byte count, the SSE accounting rule, the async MCP path, the opt-out rule, the A2A whole-call default, or the pagination note each fails it. It also pins the two transports to the same 1 MiB whole-call default, so an SDK can't end up accepting a 2 MiB response over A2A and rejecting it over MCP.Local:
test:contracts,test:docs-nav,test:doc-compliance-drift,test:compliance-snippets,lint:schema-links,test:error-codes, test-coverage registration, and the full pre-commit hook (4610 server unit tests + typecheck) all pass.Review notes for the maintainer
Two things I did not decide unilaterally:
Clients SHOULDstem, per the issue text. Review flagged that the repo's precedent for comparable caps is MUST (MAX_BRAND_JSON_BYTESstreaming enforcement, the attestation task-body cap). Raising property 1 to MUST would make it a conformance requirement — your call, happy to change it.Two drive-bys and one gap:
#plan-state-bindinganchor insecurity.mdx(no such heading anywhere in the repo); it now points at the governance spec's plan binding and audit section, which three sibling references already use.tools/listembedding projectedinputSchemadocuments clears 1 MiB on its own — AdCP's own reference controller projects to 1,220,495 bytes.docs/for inbound A2A push notifications or AdCP webhooks. The same OOM applies to a buyer's webhook receiver. I scoped it out with a pointer sentence rather than grow this PR; happy to file a follow-up issue.Reviewed before opening by an ad-tech-protocol-expert and a security-reviewer agent against
.agents/roles/; every finding is implemented or answered above.🤖 Generated with Claude Code
Open workspace in Conductor