Description
Context
AdCP issue adcontextprotocol/adcp#5450 and merged spec PR adcontextprotocol/adcp#5472 define the redirect policy for adagents.json discovery. The reference validator in adcontextprotocol/adcp is now aligned; this SDK needs the same behavior so all AdCP implementations resolve discovery identically.
The bug this fixes: a publisher whose apex domain 301-redirects to www (the default on most managed hosting / CDNs) is silently reported unauthorized by validators that refuse all redirects on the discovery fetch.
Policy — two hops, deliberately different
| Fetch | Redirect policy |
|---|---|
Initial https://{domain}/.well-known/adagents.json |
Follow same-registrable-domain redirects (apex↔www, HTTPS-preserving, ≤3 hops), re-validating SSRF (reject non-HTTPS, reject reserved/private IPs, pin connect) on every hop, with the same-domain comparison anchored on the originally-requested domain at every hop (not the previous hop). Refuse cross-registrable-domain redirects — that is an unscoped delegation signal; the publisher should declare delegation via authoritative_location instead. |
authoritative_location dereference (2nd hop) |
Refuse all redirects. The named URL is the declared authoritative location; a redirect away from it changes that declaration and MUST be treated as an error. |
⚠️ Security-critical: use the PSL private section
Registrable-domain comparison MUST use the Public Suffix List including its PRIVATE section. Without it, shared-hosting tenants collapse to one registrable domain — victim.github.io and attacker.github.io both reduce to github.io — and a cross-tenant redirect would be wrongly followed and trusted as authoritative. The same applies to *.pages.dev, *.web.app, *.herokuapp.com, *.wordpress.com, etc. The reference impl uses tldts.getDomain(host, { allowPrivateDomains: true }).
Conformance
Gate on the shared cross-SDK vectors: static/test-vectors/adagents-discovery-redirects.json. They cover apex↔www, subdomain, co.uk (ICANN multi-label), *.github.io (PSL private section), same→cross two-hop (origin-anchored), HTTPS downgrade, hop cap, and the authoritative-location refuse-all rule. The normative assertion per vector is result (resolved vs refused).
This SDK (adcp-client-python)
Per the #5450 report, the .well-known/adagents.json fetch currently passes follow_redirects=False (in adcp/adagents.py), which is exactly what breaks apex→www publishers.
.well-knownfetch → replacefollow_redirects=Falsewith a manual same-registrable-domain redirect loop: follow only same-eTLD+1, HTTPS-preserving, ≤3 hops, re-validating SSRF on each hop, anchored on the originally-requested domain; refuse cross-domain.authoritative_locationdereference → keep redirects refused.- PSL with private domains: e.g.
tldextractwithinclude_psl_private_domains=True, orpublicsuffixlist/publicsuffix2with private rules — sovictim.github.io≠attacker.github.io.
Acceptance: the discovery path passes every vector in adagents-discovery-redirects.json.
Activity
bokelley commentedon Jun 11, 2026
Triage
Classification: Bug
Bucket(s): signing, validation
Status: ready-for-human
Milestone: (omit — no target version named)
What the experts said:
_owned_pinned_clientper hop (usingfollow_redirects=Trueon one pinned transport reopens the DNS-rebinding window); (2) original-domain anchor must be captured before the loop and held fixed — a rolling-anchor implementation is a SSRF mitigation bypass; (3)_validate_redirect_urllacks an explicitscheme == "https"guard (theauthoritative_locationpath at line 694–699 already does this correctly and must be the model); (4) new redirect-loop code must importsame_registrable_domainfromadcp.signing.etld(already configured withinclude_psl_private_domains=True) — a second extractor constructed without that flag is a blockerurlparsereturns raw ACE labels which may not match the Unicode original domain); also: confirmed non-breaking for currently-working publishers; separateMAX_WELL_KNOWN_REDIRECT_HOPS = 3constant recommended (nit); no feature flag neededMy take: The fix is clearly scoped and the spec (adcp#5472) is normative, but both experts raised blockers on the security-sensitive SSRF-mitigation path. The IDN/punycode gap is an additional angle the issue body does not cover. Flagging for @bokelley: security-sensitive changes always go to human review per triage policy.
Implementation brief (for the assignee):
_stream_capped/_fetch_adagents_url, replacefollow_redirects=Falsewith a manual per-hop redirect loop capped by a new constantMAX_WELL_KNOWN_REDIRECT_HOPS = 3(separate fromMAX_REDIRECT_DEPTH = 5which governs theauthoritative_locationchain)Locationheader → assertscheme == "https"(explicit check, not implicit via_check_safe_host) →_check_safe_host→_dns_validate_host→_owned_pinned_client(location_url, timeout)— new pinned client per hopsame_registrable_domainfromadcp.signing.etld; compareurlparse(location_url).hostnameagainstoriginal_hostnamecaptured before the loop (not against the previous hop's URL)tldextractnormalizes punycode ACE labels internally beforesame_registrable_domaincomparison, or addidna.encode(host, uts46=True).decode("ascii")normalization on both sides; failing the IDN test vectors is a blockerauthoritative_locationdereference in_resolve_direct: no change — keep existingfollow_redirects=Falsepytestagainst the vectors instatic/test-vectors/adagents-discovery-redirects.jsonfromadcontextprotocol/adcpmain (apex↔www, PSL private section, HTTPS downgrade, hop cap, original-domain anchor, authoritative-location refuse-all)Triaged by Claude Code. Session: https://claude.ai/code/session_01UhFtrv7V583KN49V5yJ3gb
Generated by Claude Code