Skip to content

fix(grader): repair undici lookup callback shape for Node 22+ HTTPS targets - #1026

Merged
bokelley merged 2 commits into
mainfrom
claude/issue-1025-fix-probe-lookup-callback
Apr 26, 2026
Merged

bokelley merged 2 commits into
mainfrom
claude/issue-1025-fix-probe-lookup-callback

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Closes #1025

On Node 22+ with HTTPS targets, undici calls connect.lookup with { all: true } and expects the array form of the callback (cb(null, [{address, family}])). The request-signing probe was using the single-value form (cb(null, address, family)), producing "Invalid IP address: undefined" on every probe against any endpoint behind Cloudflare or an anycast load balancer — making adcp grade request-signing completely non-functional against production deployments. The fix aligns the callback with the already-working pattern in src/lib/net/ssrf-fetch.ts and preserves the DNS-rebinding protection. Also fixes a pre-existing gap: IPv6-literal hostnames were not bracket-stripped before dns.lookup, mirroring the same one-liner from ssrf-fetch.ts.

What was tested:

  • npm run format:check — passed
  • npm run typecheck — pre-existing @types/node / moduleResolution deprecation errors only; no new errors introduced (verified by stashing the change and comparing)
  • npm run build:lib — blocked by missing tsx in this environment (pre-existing); TypeScript compilation of the changed file passes with no new errors
  • npm test — 603 failures vs. 608 baseline (5 fewer failures, no regressions introduced)

Pre-PR review:

  • code-reviewer: approved — fix is correct and complete; pinnedFamily narrowing present; IPv6 bracket stripping added; nit noted (body-truncation early-return pre-exists, out of scope)
  • security-reviewer: approved — DNS-rebinding protection is equivalent; callback shape change only; SSRF guards (scheme check, isAlwaysBlocked, isPrivateIp, redirect: manual, body cap) all intact; IP-in-error-message divergence from ssrf-fetch.ts noted as low-risk nit for this tool context

Nit (not fixed, low risk): probe.ts includes the resolved IP address directly in result.error strings (lines 81–92). ssrf-fetch.ts intentionally omits the IP from human-readable messages to avoid leaking internal topology into compliance reports. For a CLI grader whose output stays on the operator's terminal this is low risk, but worth aligning in a follow-up.

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num> →
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See adcp#3121
for context.

Session: https://claude.ai/code/session_01648bZhu2JMjvS7WC949n2J


Generated by Claude Code

claude added 2 commits April 26, 2026 21:27
…robe

On Node 22+ with HTTPS targets, undici calls connect.lookup with
{ all: true } and expects the array form cb(null, [{address, family}]).
The probe was passing the single-value form cb(null, address, family),
producing "Invalid IP address: undefined" against anycast/Cloudflare
endpoints. Aligns the callback with the pattern in ssrf-fetch.ts and
preserves DNS-rebinding protection.

Closes #1025

https://claude.ai/code/session_01648bZhu2JMjvS7WC949n2J
…robe

URL.hostname wraps IPv6 literals in brackets (`[::1]`); dns.lookup and
the address classifiers need the bare form. Mirrors the pattern already
used in ssrf-fetch.ts.

https://claude.ai/code/session_01648bZhu2JMjvS7WC949n2J
@bokelley

Copy link
Copy Markdown
Contributor Author

Independent expert pass (code-reviewer + security-reviewer) — both ship-ready, no blockers, aligned with triage's pre-PR review.

Code review: clean. Confirmed dual-shape callback is correct (opts?.all discriminator is sound per undici's connect.ts); pinnedFamily === 6 ? 6 : 4 narrowing is safe (Node populates 4 or 6 with { all: true }); IPv6 bracket strip handles all the shapes that matter; addresses[0]! non-null is load-bearing and correct. Patch is line-for-line aligned with src/lib/net/ssrf-fetch.ts:189-200. Two pre-existing issues confirmed out-of-scope (zone-identifier stripping in IPv6 hostnames, IP-in-error-message divergence from ssrf-fetch.ts). One nit: no regression test for the dual-shape callback — ssrf-fetch.ts ships the identical pattern untested, so hard to justify here, but a future regression test would lock it in.

Security review: ship. Verified the four key concerns:

  1. DNS-rebinding pin honored on every TCP attempt. undici's buildConnector consumes our connect.lookup for every fresh socket; HTTP/2 pool reuse only skips DNS for already-pinned sockets; redirect: 'manual' blocks 30x smuggling. No bypass.
  2. IMDS-TOCTOU concern is real, not theoretical. VALIDATE-YOUR-AGENT.md:47 documents adcp grade request-signing running in CI (GitHub Actions / GitLab CI on AWS/GCP) with IMDSv1/v2 reachable. Without the pin: attacker DNS returns a public IP for the upfront classify pass, then 169.254.169.254 for the connect-time resolution; body bytes (with role credentials) get echoed into result.body. Triage's pushback against my initial "drop the pin" recommendation was right.
  3. Branch selection cannot be attacker-controlled. opts?.all is set by Node's internal socket code based on autoSelectFamily/Happy Eyeballs / Node version, not by HTTP request data. Both branches return the same pinned address.
  4. TLS/SNI preserved. tls.connect uses servername = util.getServerName(host) from the original hostname, not the pinned IP — cert validation against the real domain is intact.

Net: patch correct, threat model preserved, audience-appropriate. Triage's pre-PR review held up under independent verification. Ready to merge.

Once #1026 lands, the auto-Release-PR will sit at 5.21.1 (one patch changeset queued).

@bokelley
bokelley marked this pull request as ready for review April 26, 2026 21:51
@bokelley
bokelley merged commit 5ff8aa8 into main Apr 26, 2026
10 checks passed
bokelley added a commit to adcontextprotocol/adcp that referenced this pull request Apr 27, 2026
Patch picks up the grader fix from adcontextprotocol/adcp-client#1026
(closes my-filed #1025 — undici lookup callback shape broke against
Cloudflare-fronted endpoints).

Validated end-to-end after deploy:
  npx adcp grade request-signing https://agenticadvertising.org/api/training-agent/mcp-strict --transport mcp --skip-rate-abuse
  → 30 passed, 3 failed, 6 skipped (was 1 passed pre-fix, all 32 others
    blocked at "fetch failed")

The 3 remaining failures are verifier-side conformance gaps in the
training-agent's strict route, unrelated to this bump:
  - neg/007 missing-content-digest:  strict capability is 'either', not 'required'
  - neg/016 replayed-nonce:           replay store doesn't reject duplicate nonce
  - neg/018 digest-covered-forbidden: 'either' too permissive for vector

Runtime API surface unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley added a commit to adcontextprotocol/adcp that referenced this pull request Apr 27, 2026
Patch picks up the grader fix from adcontextprotocol/adcp-client#1026
(closes my-filed #1025 — undici lookup callback shape broke against
Cloudflare-fronted endpoints).

Validated end-to-end after deploy:
  npx adcp grade request-signing https://agenticadvertising.org/api/training-agent/mcp-strict --transport mcp --skip-rate-abuse
  → 30 passed, 3 failed, 6 skipped (was 1 passed pre-fix, all 32 others
    blocked at "fetch failed")

The 3 remaining failures are verifier-side conformance gaps in the
training-agent's strict route, unrelated to this bump:
  - neg/007 missing-content-digest:  strict capability is 'either', not 'required'
  - neg/016 replayed-nonce:           replay store doesn't reject duplicate nonce
  - neg/018 digest-covered-forbidden: 'either' too permissive for vector

Runtime API surface unchanged.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(grader): request-signing grader fails on Cloudflare/anycast endpoints — undici dispatcher pin produces "Invalid IP address: undefined"

2 participants