Skip to content

feat(security): clients SHOULD bound agent response size - #8192

Merged
bokelley merged 2 commits into
mainfrom
conductor/response-size-cap-spec
Oct 14, 2026
Merged

bokelley merged 2 commits into
mainfrom
conductor/response-size-cap-spec

Conversation

@bokelley

@bokelley bokelley commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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.mdx gets 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:

  1. Enforced while the body is received — counted as bytes arrive, connection aborted on exceed. A check after buffering, decoding or parsing is not such a bound. Names the buffered-body convenience APIs in all four target languages (requests.get() without stream=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.
  2. Pre-rejects a declared size — over-limit Content-Length, and rejects Content-Length + Transfer-Encoding: chunked or conflicting duplicates outright.
  3. Paired with a deadline — connect, read-idle, total. A peer that drips bytes under the cap forever is otherwise fully conformant and still holds a worker slot.
  4. Counts raw and decoded bytes, and bounds the decoder — decoded-only counting leaves two holes: a stream that decodes to nearly nothing never trips the counter, and decompress-then-measure materializes the zip bomb before measuring it.
  5. Covers SSE per event and per call — every stream byte counts (data, field names, 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, SubscribeToTask and Last-Event-ID resumption.
  6. Bounds what the bytes become — JSON depth 64, 100,000 aggregate members, matching the existing attestation task-body caps.
  7. Errors; does not truncate — distinct client-local error type (ResponseTooLarge), explicitly not an adcp_error.code, maps to recovery: "permanent", no auto-retry, and the error must not carry a body excerpt or reach an LLM context.
  8. Defaults to no more than 4 MiB (4,194,304 bytes) — configurable per agent and per call; an unbounded mode, if offered, is a separately named unsafe switch, not settable per call, and logged.
  9. Bounds aggregate exposure — concurrent in-flight reads and retained bytes across a fan-out batch.

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.mdx gets 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-Length pre-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_error the 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 as minor, with the migration-guide entry and changeset note.

Tests

tests/response-size-bounds.test.cjs (34 assertions, wired into test: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:

  • Normative strength. Everything hangs off one Clients SHOULD stem, per the issue text. Review flagged that the repo's precedent for comparable caps is MUST (MAX_BRAND_JSON_BYTES streaming enforcement, the attestation task-body cap). Raising property 1 to MUST would make it a conformance requirement — your call, happy to change it.
  • Configuration hardening. I took "unbounded mode is a separately named unsafe switch, not settable per call, logged" but not a hard maximum on the configurable value, since a legitimate operator may need a higher limit for a known counterparty and the issue explicitly allows per-agent configuration.

Two drive-bys and one gap:

  • Fixes a dangling #plan-state-binding anchor in security.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.
  • Notes that an unpaginated tools/list embedding projected inputSchema documents clears 1 MiB on its own — AdCP's own reference controller projects to 1,220,495 bytes.
  • Gap left open: there is no receiver-side request-body cap anywhere in 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

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]>
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Oct 14, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. No static/schemas/source/**, dist/**, or oneOf surface 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.mdx is (modified) under docs/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-audit fix 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]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approval: no reviewable delta since the prior approval; re-submitting after stale-review dismissal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spec: clients SHOULD bound agent response size (memory DoS)

1 participant