Skip to content

Require a numeric port for wildcard Host and Origin entries - #3867

Open
Kludex wants to merge 2 commits into
mainfrom
require-numeric-wildcard-port
Open

Kludex wants to merge 2 commits into
mainfrom
require-numeric-wildcard-port

Conversation

@Kludex

@Kludex Kludex commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

An allowed_hosts or allowed_origins entry ending in :* matched any value that started with the base and a colon, without checking that a port followed. So localhost:* also accepted Host: localhost:abc and Host: localhost:.

A :* entry now matches only a numeric port, which is what the deploy and troubleshooting docs already say it does.

Validation

  • 4 new cases in tests/server/test_transport_security.py (non-numeric port, empty port, non-numeric origin port, digits with no colon). The first three fail on main.
  • ./scripts/test passes with 100% coverage and strict-no-cover clean. Ruff and Pyright pass.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

Session: claude --resume 25d1e11b-aaa2-4dbf-bb33-c05d1f09b27a

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T09:31:56.999840Z 174aa56 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Turn on auto-fix | Re-trigger cubic

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Beyond the inline findings, I also checked two things and found no problem with either:

  • IPv6 literals: [::1]:8080 splits on the last colon into [::1] and 8080, so it still matches an [::1]:* entry, and a bare [::1] is rejected as it was before.
  • Docs: docs/run/deploy.md:24 and docs/troubleshooting.md:220 already describe "host:*" as matching any port, so they read correctly with the stricter matcher.
Extended reasoning...

The change rewrites the :* wildcard matching for Host and Origin in src/mcp/server/transport_security.py, the DNS-rebinding protection for the HTTP transports, and adds three parametrized test cases. That is security-sensitive request validation and it changes which header values existing allowlists accept, so the inline findings need a maintainer's judgement.

Comment thread src/mcp/server/transport_security.py Resolved
Comment thread src/mcp/server/transport_security.py Resolved
Comment thread src/mcp/server/transport_security.py Resolved
Comment thread src/mcp/server/transport_security.py Resolved

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

This branch has not been deployed

No deployments
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