René's URL Explorer Experiment


Title: brand.json resolver: _canonicalize_url drops IPv6 brackets, and the jwks_origin_mismatch gate compares a canonical origin to a raw one · Issue #989 · adcontextprotocol/adcp-client-python · GitHub

Open Graph Title: brand.json resolver: _canonicalize_url drops IPv6 brackets, and the jwks_origin_mismatch gate compares a canonical origin to a raw one · Issue #989 · adcontextprotocol/adcp-client-python

X Title: brand.json resolver: _canonicalize_url drops IPv6 brackets, and the jwks_origin_mismatch gate compares a canonical origin to a raw one · Issue #989 · adcontextprotocol/adcp-client-python

Description: Summary Two origin-normalization defects in the brand.json resolver, both from hand-rolled netloc string work: _canonicalize_url rebuilds the netloc from parts.hostname, which strips IPv6 brackets and never re-adds them. A bracketed IPv6...

Open Graph Description: Summary Two origin-normalization defects in the brand.json resolver, both from hand-rolled netloc string work: _canonicalize_url rebuilds the netloc from parts.hostname, which strips IPv6 brackets ...

X Description: Summary Two origin-normalization defects in the brand.json resolver, both from hand-rolled netloc string work: _canonicalize_url rebuilds the netloc from parts.hostname, which strips IPv6 brackets ...

Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/989

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"brand.json resolver: _canonicalize_url drops IPv6 brackets, and the jwks_origin_mismatch gate compares a canonical origin to a raw one","articleBody":"## Summary\n\nTwo origin-normalization defects in the `brand.json` resolver, both from hand-rolled netloc string work:\n\n1. `_canonicalize_url` rebuilds the netloc from `parts.hostname`, which strips IPv6 brackets and never re-adds them. A bracketed IPv6 `brand.json` URL is turned into a malformed URL, and the failure surfaces as an untyped `SSRFValidationError` escaping the resolver instead of a `BrandJsonResolverError`.\n2. The `jwks_origin_mismatch` gate compares a *canonicalized* brand origin against a *raw* agent origin, so cosmetic spelling differences in `agent.url` produce a spurious mismatch with an error message that blames a cross-origin trust pivot.\n\nBoth fail closed. Neither is a bypass — see \"Direction\" below, which matters because the second one sits on a security gate and reads worse than it is.\n\n## 1. `_canonicalize_url` de-brackets IPv6 authorities\n\n`src/adcp/signing/brand_jwks.py:714-721`:\n\n```python\nhost = parts.hostname or \"\"            # :714 — strips [ ] from IPv6\n...\nnetloc = host if port is None else f\"{host}:{port}\"   # :720 — never re-adds them\nreturn urlunsplit((scheme, netloc, parts.path, parts.query, \"\"))\n```\n\n```python\n>>> from adcp.signing.brand_jwks import _canonicalize_url\n>>> _canonicalize_url(\"https://[::1]/x\", allow_private=True)\n'https://::1/x'\n```\n\nThat string is then both the redirect-loop `seen` key (`:551-553`) and the URL handed to the transport builder at `:569` and to `client.get` at `:580`. The builder rejects it:\n\n```python\n>>> from adcp.signing.ip_pinned_transport import build_async_ip_pinned_transport\n>>> build_async_ip_pinned_transport(\"https://::1/x\", allow_private=True)\nadcp.signing.jwks.SSRFValidationError: URI has no host: 'https://::1/x'\n```\n\n`build_async_ip_pinned_transport` at `:569` is **outside** the `try` opened at `:577`, and the `except SSRFValidationError` at `:581` only wraps `client.get`. So the exception escapes `_fetch_brand_json` untyped — callers that handle `BrandJsonResolverError` see an `SSRFValidationError` instead. (httpx would have refused the same URL with `httpx.InvalidURL`, which is not an `httpx.HTTPError` and so is not caught by `:585` either.)\n\nMarginal in frequency — `brand.json` URLs are normally DNS names — but the diagnostic is wrong and the exception type is not part of the resolver's contract.\n\n**Same function, second gap.** Its docstring (`:685-701`) states it exists to close \"trivial aliasing attacks (case-mismatched host, default-port elision)\" against the `seen` set, and that a Python-only deployment would otherwise \"fail open where JS fails closed\". It does not strip the trailing FQDN-root dot and does not IDNA-encode, so it does not close those two aliases:\n\n```python\n>>> _canonicalize_url(\"https://Brand.Example./x\", allow_private=True)\n'https://brand.example./x'                 # distinct `seen` entry from .../x\n>>> _canonicalize_url(\"https://bücher.example/x\", allow_private=True)\n'https://bücher.example/x'                 # distinct from the xn-- spelling\n```\n\n`max_redirects` still bounds the chain, so this is not an unbounded loop — it means the depth cap, not the loop detector, is what stops it. Worth closing so the function meets its own stated contract, not because it is currently exploitable.\n\n## 2. The `jwks_origin_mismatch` gate compares canonical to raw\n\n`src/adcp/signing/brand_jwks.py:895-898`:\n\n```python\nbrand_parts = urlsplit(final_brand_url)\nagent_origin = f\"{agent_parts.scheme}://{agent_parts.netloc}\"\nbrand_origin = f\"{brand_parts.scheme}://{brand_parts.netloc}\"\nif agent_origin != brand_origin:\n    raise BrandJsonResolverError(\"jwks_origin_mismatch\", ...)\n```\n\n`final_brand_url` is the output of `_canonicalize_url` (`:548`, `:641`, `:659` → `:673`): host lowercased, default port stripped, fragment stripped, userinfo rejected. `agent_url` is the raw `agents[].url` string from the document. So this is a byte comparison between a canonical value and an uncanonicalized one, and it uses raw `.netloc` — the one accessor in the module that keeps userinfo.\n\n```python\n>>> from adcp.signing.brand_jwks import _default_jwks_uri\n>>> BRAND = \"https://brand.example/.well-known/brand.json\"   # already canonicalized\n\n>>> _default_jwks_uri(\"https://brand.example/agent\", BRAND)\n'https://brand.example/.well-known/jwks.json'\n\n>>> _default_jwks_uri(\"https://Brand.Example/agent\", BRAND)\nBrandJsonResolverError: jwks_origin_mismatch\n>>> _default_jwks_uri(\"https://brand.example:443/agent\", BRAND)\nBrandJsonResolverError: jwks_origin_mismatch\n>>> _default_jwks_uri(\"https://brand.example./agent\", BRAND)\nBrandJsonResolverError: jwks_origin_mismatch\n>>> _default_jwks_uri(\"https://user@brand.example/agent\", BRAND)\nBrandJsonResolverError: jwks_origin_mismatch\n```\n\nThe IDN pair diverges the same way: a `brand.json` fetched from `https://bücher.example/...` produces `brand_origin == \"https://bücher.example\"`, so an `agent.url` of `https://xn--bcher-kva.example/agent` mismatches despite naming the same host.\n\n### Direction: this fails closed, and cannot fail open\n\nStating this explicitly because the site is a security gate and the shape invites the opposite reading.\n\n- The brand side is always the output of `_canonicalize_url`: lowercase host, no userinfo, no default port, no fragment. The agent side is raw. A normalization divergence can therefore only make a raw string *unequal* to a canonical one. There is no input that makes two origins denoting **different** hosts compare equal, because equality here is byte equality against a value that is already in canonical form.\n- The return value at `:907` is built from `agent_origin`, but only on the equality branch — where `agent_origin` is byte-identical to `brand_origin`. So the derived `jwks_uri` is always rooted at the canonical brand origin. No trust pivot is reachable through this path.\n\nThe honest severity is therefore **interop / diagnostics, low**: a publisher who writes `agent.url: \"https://Brand.Example/agent\"` or includes an explicit `:443` in a `brand.json` served from `https://brand.example/` loses the default-`jwks_uri` path, and the error text tells them their agent is on a different origin from their brand.json — which it is not. The documented escape hatch (declare an explicit `jwks_uri`) works, so this is recoverable, just confusing.\n\n## Suggested direction\n\nBoth findings have the same fix shape: derive the origin through the package's designated host canonicalizer rather than string-concatenating a netloc.\n\n- `_canonicalize_url`: re-bracket the host when it is an IPv6 literal before reassembling the netloc, and route the host through `_idna_canonicalize.canonicalize_host` (which strips one trailing dot, lowercases, short-circuits IP literals, and A-label-encodes). Note `canonicalize_host` returns IPv6 literals unbracketed, so bracket re-addition is the caller's job either way.\n- `_default_jwks_uri`: build both origins the same way — `scheme.lower()` + `canonicalize_host(parts.hostname)` + non-default port — rather than comparing raw `.netloc` on one side and a canonical string on the other. Using `.hostname` rather than `.netloc` also drops the userinfo that only the agent side can currently carry.\n- Also move `build_async_ip_pinned_transport` at `:569` inside the `try` at `:577`, or wrap it, so an SSRF refusal on the transport-construction path surfaces as `BrandJsonResolverError(\"fetch_failed\", ...)` like the one on the request path already does.\n\n`canonicalize_host` raises on underscore hosts and over-long labels where these functions return them today; both sites are already fail-closed (they raise `BrandJsonResolverError` on bad input), so mapping the raise onto `invalid_url` is consistent with what is there.\n","author":{"url":"https://github.com/KonstantinMirin","@type":"Person","name":"KonstantinMirin"},"datePublished":"2026-07-29T09:59:14Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/989"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:768d4056-4942-e728-06cb-13643a505210
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB0AA:3A4875:BC6F87:FC0814:6B00F698
html-safe-nonce880530e882a641a696e52bddb01d41c860a5c1b41d4eb625bead4d4183c696a4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEFBOjNBNDg3NTpCQzZGODc6RkMwODE0OjZCMDBGNjk4IiwidmlzaXRvcl9pZCI6IjExOTc2NTAzNzM4NTk0MDc1MTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4f40d177198aea308132e6ec7bf28f0ff89ab93e0d9187a6ffbf1b63d31c4c06
hovercard-subject-tagissue:5007929821
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/989/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f3ec9bc6bdc8f9c167956a7989f1afc43c3525ae9a426782fb075d1cca2a746f/adcontextprotocol/adcp-client-python/issues/989
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f3ec9bc6bdc8f9c167956a7989f1afc43c3525ae9a426782fb075d1cca2a746f/adcontextprotocol/adcp-client-python/issues/989
og:image:altSummary Two origin-normalization defects in the brand.json resolver, both from hand-rolled netloc string work: _canonicalize_url rebuilds the netloc from parts.hostname, which strips IPv6 brackets ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKonstantinMirin
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
turbo-cache-controlno-preview
go-importgithub.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git
octolytics-dimension-user_id221690821
octolytics-dimension-user_loginadcontextprotocol
octolytics-dimension-repository_id1090305973
octolytics-dimension-repository_nwoadcontextprotocol/adcp-client-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1090305973
octolytics-dimension-repository_network_root_nwoadcontextprotocol/adcp-client-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/adcontextprotocol/adcp-client-python/issues/989#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fadcontextprotocol%2Fadcp-client-python%2Fissues%2F989
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fadcontextprotocol%2Fadcp-client-python%2Fissues%2F989
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=adcontextprotocol%2Fadcp-client-python
Reloadhttps://github.com/adcontextprotocol/adcp-client-python/issues/989
Reloadhttps://github.com/adcontextprotocol/adcp-client-python/issues/989
Reloadhttps://github.com/adcontextprotocol/adcp-client-python/issues/989
adcontextprotocolhttps://github.com/adcontextprotocol
adcp-client-pythonhttps://github.com/adcontextprotocol/adcp-client-python
Codehttps://github.com/adcontextprotocol/adcp-client-python
Issues44 (44)https://github.com/adcontextprotocol/adcp-client-python/issues
Pull requests13 (13)https://github.com/adcontextprotocol/adcp-client-python/pulls
Actionshttps://github.com/adcontextprotocol/adcp-client-python/actions
Projectshttps://github.com/adcontextprotocol/adcp-client-python/projects
Security and qualityhttps://github.com/adcontextprotocol/adcp-client-python/security
Insightshttps://github.com/adcontextprotocol/adcp-client-python/insights
https://github.com/adcontextprotocol/adcp-client-python
New issuehttps://github.com/login?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/989
New issuehttps://github.com/login?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/989
#998https://github.com/adcontextprotocol/adcp-client-python/pull/998
brand.json resolver: _canonicalize_url drops IPv6 brackets, and the jwks_origin_mismatch gate compares a canonical origin to a raw onehttps://github.com/adcontextprotocol/adcp-client-python/issues/989#top
#998https://github.com/adcontextprotocol/adcp-client-python/pull/998
bugSomething isn't workinghttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22bug%22
claude-triagedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaged%22
https://github.com/KonstantinMirin
KonstantinMirinhttps://github.com/KonstantinMirin
on Jul 29, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/989#issue-5007929821
bokelleyhttps://github.com/bokelley
claude-triagingTriage routine is actively working on this issue (1-3 min)https://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaging%22
on Jul 29, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/989#event-28651912883
https://github.com/bokelley
bokelleyhttps://github.com/bokelley
on Jul 29, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/989#issuecomment-5116228567
@bokelleyhttps://github.com/bokelley
https://claude.ai/code/cse_01H58XjPkmzZTdrJnLWL5aGWhttps://claude.ai/code/cse_01H58XjPkmzZTdrJnLWL5aGW
Claude Codehttps://claude.ai/code
bokelleyhttps://github.com/bokelley
bugSomething isn't workinghttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22bug%22
claude-triagedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaged%22
claude-triagingTriage routine is actively working on this issue (1-3 min)https://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaging%22
on Jul 29, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/989#event-28652222359
bokelleyhttps://github.com/bokelley
on Jul 29, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/989#event-28660522951
fix(signing): canonicalize both origins in the brand.json jwks gate (#…https://github.com/adcontextprotocol/adcp-client-python/commit/b7ef1dfcff2bf116e1c18586fd26a497669cdc41
#…https://github.com/adcontextprotocol/adcp-client-python/pull/998
https://docs.github.com/articles/closing-issues-via-commit-messages
b7ef1dfhttps://github.com/adcontextprotocol/adcp-client-python/commit/b7ef1dfcff2bf116e1c18586fd26a497669cdc41
bokelleyhttps://github.com/bokelley
completedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#998https://github.com/adcontextprotocol/adcp-client-python/pull/998
on Jul 29, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/989#event-28660522957
Sign up for freehttps://github.com/signup?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/989
Sign in to commenthttps://github.com/login?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/989
bugSomething isn't workinghttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22bug%22
claude-triagedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaged%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.