Skip to content

fix(did): default allowedHttpHosts to [] in getDidResolver (HTTPS-only) - #247

Closed
forumevi wants to merge 1 commit into
agentcommercekit:mainfrom
forumevi:fix/getdidresolver-http-default
Closed

forumevi wants to merge 1 commit into
agentcommercekit:mainfrom
forumevi:fix/getdidresolver-http-default

Conversation

@forumevi

@forumevi forumevi commented Oct 7, 2026 •

Copy link
Copy Markdown

Problem

getDidResolver() ships with a default that allows localhost, 127.0.0.1 and 0.0.0.0 to serve DID documents over plain HTTP:

export function getDidResolver({
  webOptions = {
    allowedHttpHosts: ["localhost", "127.0.0.1", "0.0.0.0"],  // ← library default
  },

Because this is a library entrypoint, the default silently applies to any production service that calls getDidResolver() without explicit webOptions. A DID document served over plain HTTP is vulnerable to man-in-the-middle substitution: an attacker on the network can swap the document (and its public keys) before it reaches the resolver, bypassing every downstream signature and issuer check.

Fix

Change the default allowedHttpHosts to [] (HTTPS-only). This is the safe default for a library: production callers get HTTPS-only resolution without having to opt in.

All demos and examples that resolve did:web URIs against localhost are updated to pass allowedHttpHosts explicitly, so local development is unaffected.

Migration

If you call getDidResolver() in a local development or test environment that uses HTTP, pass the hosts explicitly:

const resolver = getDidResolver({
  webOptions: { allowedHttpHosts: ["localhost", "127.0.0.1"] },
})

Production callers that already use HTTPS require no change.

Summary by CodeRabbit

  • Security
    • DID resolution now uses HTTPS by default. HTTP access must be explicitly allowed for specific hosts.
  • Bug Fixes
    • Local DID resolution continues to work in demos and examples, which now explicitly allow HTTP requests to localhost, 127.0.0.1, and 0.0.0.0. HTTP connections may be vulnerable to interception.

The previous default allowed localhost, 127.0.0.1 and 0.0.0.0 to serve
DID documents over plain HTTP. Because getDidResolver() is a library
entrypoint, that default silently applied to any production service that
called it without explicit webOptions, opening DID documents to MITM
substitution on non-TLS networks.

Change the default to an empty list (HTTPS-only) and update all demos
and examples to pass their own allowedHttpHosts explicitly, so local
development continues to work without polluting the library default.
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ec8d111-d8c3-4409-be8c-347199d7ea6e
📥 Commits

Reviewing files that changed from the base of the PR and between 3db94d6 and 80c80a7.

📒 Files selected for processing (11)
  • demos/e2e/src/index.ts
  • demos/identity-a2a/src/bank-client-agent.ts
  • demos/identity-a2a/src/issuer.ts
  • demos/identity/src/index.ts
  • demos/payments/src/index.ts
  • demos/payments/src/payment-service.ts
  • demos/payments/src/receipt-service.ts
  • demos/payments/src/server.ts
  • examples/issuer/src/middleware/did-resolver.ts
  • examples/verifier/src/routes/verify.ts
  • packages/did/src/did-resolvers/get-did-resolver.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.


Walkthrough

The shared DID resolver now denies HTTP resolution by default. Demo and example callers explicitly allow HTTP resolution for localhost, 127.0.0.1, and 0.0.0.0.

Changes

DID Resolver HTTP Policy

Layer / File(s) Summary
Set the resolver default
packages/did/src/did-resolvers/get-did-resolver.ts
The default HTTP host allowlist is now empty. The documentation describes how to allow specific hosts and notes the risk of HTTP.
Allow local HTTP hosts in callers
demos/e2e/src/index.ts, demos/identity-a2a/src/{bank-client-agent.ts,issuer.ts}, demos/identity/src/index.ts, demos/payments/src/*, examples/issuer/src/middleware/did-resolver.ts, examples/verifier/src/routes/verify.ts
These callers now explicitly allow HTTP resolution for localhost, 127.0.0.1, and 0.0.0.0.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: venables

Merge Risk: ⚪ Minimal · up to 80c80

The DID resolver now uses HTTPS by default, and demos and examples explicitly opt in to HTTP for local hosts. Callers that relied on the old implicit localhost HTTP default must now configure allowedHttpHosts. No merge-blocking risk was found.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: getDidResolver now defaults allowedHttpHosts to an empty list and uses HTTPS by default.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@forumevi

forumevi commented Oct 7, 2026

Copy link
Copy Markdown
Author

Closing: this is a design choice, not a bug. The localhost default is intentional for developer convenience and consistent with web-did-resolver's own defaults.

@forumevi forumevi closed this Oct 7, 2026
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.

1 participant