Skip to content

AAO discovery crawler has no response-body byte cap (DoS via hostile vendor) #3731

Closed

Description

@bokelley

Context

Surfaced during PR #3726 security review (must-fix). After investigation, the gap is repo-wide, not specific to measurement vendors:

The AAO discovery crawler calls into @adcp/sdk for tools/list (existing) and get_adcp_capabilities (added in #3726). Neither path enforces a response-body byte cap — node_modules/@modelcontextprotocol/sdk streamableHttp and sse clients buffer the full reply before parsing. A hostile measurement vendor (or any other agent type — sales, creative, signals) publishing a 200 MB JSON-RPC reply will OOM the discovery worker before the parsed-JSON 256 KB check at capabilities.ts:243 runs.

The 10s timeout at capabilities.ts:517 does not mitigate: 200 MB at datacenter speeds arrives in well under 10s.

What this issue tracks

Add a streaming response-body byte cap (proposed: 1 MB for capability docs) at the SDK fetch layer or wrap the crawler invocations with a custom fetch that enforces it.

Two implementation paths:

  • SDK-level: add a maxResponseBytes option to @adcp/sdk's transport configuration and plumb it through the MCP/A2A clients.
  • Wrapper-level: wrap the tools/list and getAdcpCapabilities crawler calls with a fetch implementation that streams + counts bytes, aborting at the cap. Bypasses the SDK abstraction but ships in this repo.

Why deferred from #3726

The vulnerability is pre-existing — tools/list has the same surface against any registered/discovered agent today. Fixing it specifically for measurement is a band-aid that misrepresents the attack surface. Proper fix belongs in a focused hardening PR.

Existing safeFetch precedent

server/src/utils/url-security.ts and node_modules/@adcp/sdk/dist/lib/.../ssrf-fetch.js already implement size caps for other crawler paths (brand.json, adagents.json, raw response capture, network consistency checks). Mirror that pattern.

References

Activity

  1. added
    bug
    claude-triaging
    on May 1, 2026
  2. bokelley commented on May 1, 2026

    @bokelley
    ContributorAuthor

    Triage

    Classification: Bug
    Bucket(s): security-sensitive (no security-sensitive label exists in this repo — noted below)
    Status: ready-for-human

    What the experts said:

    • security-reviewer: Path A (wrapper-level cappedFetch) reliably intercepts before SDK buffering on streamableHttp — the AdCPClient constructor accepts a fetch override that fires before the MCP SDK's internal ReadableStream reader. SSE slow-drip is a complication (counter accumulates per-session, not per-message) but not a blocker for the crawler's request/response pattern. Ship Path A now; SDK-level maxResponseBytes (Path B) is the right long-term fix before self-service registration opens. 1 MB cap is too tight for tools/list (legitimate large agents can reach ~2 MB with 500 tools); safer split: 4 MB for tools/list / discoverTools, 1 MB for get_adcp_capabilities.
    • code-reviewer: Use a ReadableStream passthrough that aborts mid-stream (matches readBinaryWithSizeLimit at url-tools.ts:57–95) rather than buffer-and-reconstruct — unbounded Promise.all in discoverAll:537 means N × cap in concurrent memory under Path A. Extract a shared cappedFetch(maxBytes) helper in url-security.ts. Keep the 256 KB post-parse check at capabilities.ts:249 as independent defense-in-depth; it guards a different invariant (oversized-but-valid serialized payload) and should not be lowered to match the wire cap.

    My take: Both experts converge — wrapper-level PR now for the crawler call sites, SDK maxResponseBytes tracked as a follow-on. The unresolved questions are scope (3 crawler sites vs all 7 AdCPClient callers in this repo) and whether to split the cap by call type.

    @bokelley, your call on three points before the PR opens:

    Option A — Crawler scope only (3 call sites in capabilities.ts):

    // url-security.ts — new export (mirrors safeFetch precedent)
    export function cappedFetch(maxBytes: number): typeof fetch {
      return (input, init) => fetch(input, init).then(res => {
        let total = 0;
        const stream = res.body!.pipeThrough(new TransformStream({
          transform(chunk, ctrl) {
            total += chunk.byteLength;
            total > maxBytes
              ? ctrl.error(new Error(`Response body exceeds ${maxBytes}B cap`))
              : ctrl.enqueue(chunk);
          },
        }));
        return new Response(stream, { status: res.status, headers: res.headers });
      });
    }
    
    // capabilities.ts — discoverMCPTools + discoverA2ATools
    new AdCPClient([...], { userAgent: AAO_UA_DISCOVERY, fetch: cappedFetch(4_194_304) });
    // capabilities.ts — fetchMeasurementCapabilities
    new AdCPClient([...], { userAgent: AAO_UA_DISCOVERY, fetch: cappedFetch(1_048_576) });

    health.ts, formats.ts, properties.ts, mcp-tools.ts stay uncapped until Path B lands.

    Option B — Wider scope (all 7 AdCPClient call sites in this repo):

    - new AdCPClient([...], { userAgent: AAO_UA_DISCOVERY })
    + new AdCPClient([...], { userAgent: AAO_UA_DISCOVERY, fetch: cappedFetch(4_194_304) })

    Closes the same gap in health-check and tool-call paths without waiting for the SDK; larger diff but no additional design risk.

    The three decisions:

    1. Option A (crawler only) or Option B (all callers)?
    2. Split cap (4 MB tools/list, 1 MB capabilities) or flat 1 MB?
    3. Will you file the @adcp/sdk maxResponseBytes follow-on in the SDK repo? (This routine can't open cross-repo issues.)

    Triaged by Claude Code. Session: https://claude.ai/code/cse_01XjUzCwaRsKGTKK4xCeByH3


    Generated by Claude Code

  3. added
    claude-triaged
    and removed
    claude-triaging
    on May 1, 2026
  4. bokelley commented on May 13, 2026

    @bokelley
    ContributorAuthor

    /triage execute

    Ship Path A (wrapper-level cappedFetch) per security-reviewer's recommendation. Keep Path B (SDK maxResponseBytes) as a separate follow-up issue — don't conflate.

    Implementation requirements:

    1. Use the ReadableStream passthrough that aborts mid-stream pattern (match readBinaryWithSizeLimit at url-tools.ts:57-95) — do not buffer-and-reconstruct. The unbounded Promise.all in discoverAll:537 means buffer-then-cap would still allow N × cap concurrent memory.
    2. Extract a shared cappedFetch(maxBytes) helper rather than inlining at each call site.
    3. Caps:
      • 4 MB for tools/list / discoverTools (legitimate large agents reach ~2 MB with 500 tools)
      • 1 MB for get_adcp_capabilities
    4. Pass the helper as the fetch override on the AdCPClient constructor — it fires before the MCP SDK's internal ReadableStream reader (confirmed by security-reviewer).
    5. SSE slow-drip is not in scope for this PR — note it in the PR description as a known limitation under streamableHttp.
    6. Open a follow-up issue for Path B (SDK-level maxResponseBytes) before self-service registration opens.

    Default-deny on scope creep.

  5. bokelley commented on May 16, 2026

    @bokelley
    ContributorAuthor

    Triage correction (manual backfill — routine was failing with HTTP 429)

    The prior triage analysis was stale on one key fact: @adcp/sdk already supports transport.maxResponseBytes with the exact mid-stream-abort pattern Path A wanted (withResponseSizeLimit / wrapFetchWithSizeLimit). The proposed cappedFetch wrapper and fetch override on the AdCPClient constructor don't apply — SingleAgentClientConfig has no fetch/fetchImpl field.

    Shipped: PR on branch bokelley/triage-unassigned-issues (commit 5cf37ed5cc) passes transport.maxResponseBytes on the three AdCPClient constructors in server/src/capabilities.ts:

    • 4 MB on discoverMCPTools / discoverA2ATools
    • 1 MB on fetchMeasurementCapabilities

    Residual gap (upstream): getAgentInfo() / mcpClient.listTools() in the SDK don't currently route through withResponseSizeLimit, so the 4 MB cap is dormant on the tools/list body. get_adcp_capabilities is covered today. Filed upstream: adcontextprotocol/adcp-client#1799.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaude-triagedcompliance-suite

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions