Skip to content

fix: MCP server accepts malformed IPv6 loopback hosts - #1180

Merged
jacobtomlinson merged 1 commit into
openclaw:mainfrom
joelagnel:fix/mcp-ipv6-host-validation
Aug 20, 2026
Merged

jacobtomlinson merged 1 commit into
openclaw:mainfrom
joelagnel:fix/mcp-ipv6-host-validation

Conversation

@joelagnel

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes an issue where malformed bracketed IPv6 Host headers could pass the local MCP server's loopback Host validation when arbitrary text or an invalid port followed the closing bracket. This weakened the defensive Host-header gate intended to reject non-loopback request authorities.

Why This Change Was Made

Validate the entire bracketed IPv6 authority, accepting only [::1] or [::1]: within the 16-bit port range. The validator is internal so the existing friend test assembly can exercise this security boundary directly without adding public API surface.

User Impact

Operators can expect the local MCP endpoint to reject malformed IPv6 Host values instead of treating them as valid loopback authorities. Normal IPv4 endpoints and valid bracketed IPv6 loopback hosts remain compatible.

Evidence

Before the parser change, the focused regression run failed 4 malformed-host cases and passed 2 valid-host cases. At current head, the same focused run passes all 6 cases.

  • Full build: all 5 projects passed on Windows ARM64.
  • Shared tests: 3,704 passed, 32 skipped, 0 failed.
  • Tray tests: 2,620 passed, 0 skipped, 0 failed.
  • Focused current-head tests: 6 passed, 0 skipped, 0 failed.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Validation

  • powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\build.ps1
    • Passed: Shared, Cli, WinNodeCli, SetupEngine, and WinUI.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore
    • Passed: 3,704; skipped: 32; failed: 0.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore
    • Passed: 2,620; skipped: 0; failed: 0.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter FullyQualifiedName~IsHostAllowed
    • Passed: 6; skipped: 0; failed: 0.

Real Behavior Proof

  • Environment tested: Windows ARM64, .NET SDK 10.0.400
  • PR head or commit tested: b48a242
  • Exact steps or command run: dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter FullyQualifiedName~IsHostAllowed
  • Evidence after fix: Passed! Failed: 0, Passed: 6, Skipped: 0, Total: 6
  • Observed result: [::1] and [::1]:8765 were accepted; [::1]evil, an empty port, a nonnumeric port, and port 65536 were rejected.
  • Screenshot or artifact links verified? N/A
  • Not verified or blocked: No manual raw-HTTP runtime test was performed; validation directly exercises the Host parser and includes the repository build and baseline suites.

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • New or changed network calls? No
  • Command or tool execution surface changed? No
  • Data access scope changed? No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? Yes
  • Config or environment changes? No
  • Migration needed? No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

Validate the suffix after a bracketed IPv6 loopback address.
Block junk and invalid ports from bypassing the MCP Host gate.

Signed-off-by: Joel Fernandes <[email protected]>
@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed August 19, 2026, 4:03 PM ET / 20:03 UTC.

ClawSweeper review

What this changes

The PR validates the complete bracketed IPv6 loopback authority in local MCP Host headers and adds accepted and rejected parser cases.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 2 items remain

Keep open pending real MCP listener proof. The focused parser fix addresses a current-main Host validation gap and its direct tests look sound, but the running HTTP boundary has not been demonstrated.

Priority: P2
Reviewed head: b48a24214d380adf2d09741848b2b79a75bebd05

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused parser change looks good, but merge confidence is capped by missing real listener behavior proof.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR supplies focused unit-test output, but no after-fix raw HTTP or MCP request through the running listener; redact tokens and endpoint details in any added transcript. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR supplies focused unit-test output, but no after-fix raw HTTP or MCP request through the running listener; redact tokens and endpoint details in any added transcript. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Current-main defect: Current main accepts a bracketed authority after only comparing the text between '[' and the first ']', leaving its suffix unvalidated.
Proposed repair: The PR requires either no suffix or a colon followed by an invariant-culture UInt16 port after an exact [::1] address.
Focused coverage: The branch covers two valid bracketed IPv6 authorities and four malformed suffixes through the internal validator; the existing friend-assembly grant permits this without public API expansion.
Findings None None.
Security None None.

Live Verification

Command: dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter FullyQualifiedName~IsHostAllowed

Result: FAIL (failed) — execution before step 1 run: sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.22.0.tgz

sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.22.0.tgz

Assertions:

  • FAIL expect_output: Passed!

How this fits together

The tray's local MCP server receives loopback HTTP requests before passing JSON-RPC calls to Windows capabilities. Its request gate rejects unsafe browser and Host-header contexts before authentication and tool dispatch.

flowchart LR
A[Local MCP client] --> B[Loopback HTTP listener]
B --> C[Request security gate]
C --> D{Origin and Host allowed?}
D -->|No| E[Forbidden response]
D -->|Yes| F[Bearer authentication]
F --> G[JSON-RPC tool bridge]
G --> H[Windows capabilities]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR supplies focused unit-test output, but no after-fix raw HTTP or MCP request through the running listener; redact tokens and endpoint details in any added transcript. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The submitted proof exercises the helper directly, so it does not yet show how the actual HttpListener path handles malformed bracketed Host headers.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Focused change 2 files affected; production +13/-2, tests +18 The patch keeps the security repair narrow and adds direct regression coverage.

Merge-risk options

Maintainer options:

  1. Add running-listener proof (recommended)
    Provide a redacted current-head raw HTTP or MCP transcript that rejects malformed bracketed hosts and preserves a valid IPv6 loopback authority.

Technical review

Best possible solution:

Land the narrow complete-authority validation with a raw listener regression and a redacted current-head HTTP or MCP transcript showing malformed rejection and valid IPv6 loopback compatibility.

Do we have a high-confidence way to reproduce the issue?

Yes, from source. Current main accepts an exact [::1] prefix without checking the remainder of the Host authority.

Is this the best way to solve the issue?

Yes. Validating the complete authority is the narrowest maintainable repair, provided it is proven through the listener boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 12b84457a464.

Labels

Label changes:

  • add P2: This repairs a contained local MCP security validation gap without evidence of wider runtime impact.
  • add merge-risk: 🚨 security-boundary: The diff changes the Host-header gate that protects the local MCP endpoint from DNS-rebinding and browser-context pivots.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies focused unit-test output, but no after-fix raw HTTP or MCP request through the running listener; redact tokens and endpoint details in any added transcript. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This repairs a contained local MCP security validation gap without evidence of wider runtime impact.
  • merge-risk: 🚨 security-boundary: The diff changes the Host-header gate that protects the local MCP endpoint from DNS-rebinding and browser-context pivots.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies focused unit-test output, but no after-fix raw HTTP or MCP request through the running listener; redact tokens and endpoint details in any added transcript. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Chris Anderson: Introduced the recorded local MCP hardening work and a subsequent transport stability pass. (role: MCP hardening contributor; confidence: high; commits: 9fa43f347703, 353a4b9a5356; files: src/OpenClaw.Shared/Mcp/McpHttpServer.cs, tests/OpenClaw.Shared.Tests/McpHttpServerTests.cs)
  • Vincent Koc: Added the prior MCP authentication-before-dispatch hardening on the same HTTP server. (role: MCP authentication-boundary contributor; confidence: high; commits: 424f69083bce; files: src/OpenClaw.Shared/Mcp/McpHttpServer.cs)
  • Scott Hanselman: Recent history shows continued work on the shared MCP server surface. (role: recent adjacent contributor; confidence: medium; commits: 4206611f2b2e; files: src/OpenClaw.Shared/Mcp/McpHttpServer.cs)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted current-head raw HTTP or MCP transcript showing malformed Host rejection and valid IPv6 loopback acceptance.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@jacobtomlinson
jacobtomlinson merged commit 3880b62 into openclaw:main Aug 20, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants