Skip to content

[Server] Validate Host and Origin independently - #589

Merged
chr-hertel merged 2 commits into
modelcontextprotocol:mainfrom
ausi:fix/independent-host-origin-validation
Oct 13, 2026
Merged

chr-hertel merged 2 commits into
modelcontextprotocol:mainfrom
ausi:fix/independent-host-origin-validation

Conversation

@ausi

@ausi ausi commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #522

Breaking Changes

New constructor parameter $allowedOrigins for DnsRebindingProtectionMiddleware class.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@chr-hertel chr-hertel added Server Issues & PRs related to the Server component enhancement Request for a new feature that's not currently supported labels Oct 13, 2026
@chr-hertel chr-hertel changed the title Validate Host and Origin independently [Server] Validate Host and Origin independently Oct 13, 2026
@chr-hertel chr-hertel added this to the 0.9.0 milestone Oct 13, 2026
@chr-hertel
chr-hertel requested a balanced review from Copilot October 13, 2026 22:19

Copilot AI 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.

🟢 Approval recommended

The implementation matches the issue requirements and includes comprehensive tests and documentation.

0 open findings

What changed in this PR

Separates Host and Origin validation in DNS rebinding protection.

Changes:

  • Always validates Host and independently validates Origin.
  • Adds separate allowlists, wildcard support, and same-origin handling.
  • Expands transport tests and documentation for the breaking API change.
File Description
src/​Server/​Transport/​Http/​Middleware/​DnsRebindingProtectionMiddleware.php Implements independent Host and Origin validation.
tests/​Unit/​Server/​Transport/​Http/​Middleware/​DnsRebindingProtectionMiddlewareTest.php Covers validation, wildcards, malformed values, and same-origin cases.
tests/​Unit/​Server/​Transport/​StreamableHttpTransportTest.php Verifies Host enforcement with allowed Origins.
tests/​Unit/​Server/​Transport/​StatelessHttpTransportTest.php Tests independent validation in stateless transport.
docs/​run/​http.md Documents configuration and proxy usage.
CHANGELOG.md Records the constructor and behavioral breaking changes.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chr-hertel

chr-hertel commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Thanks @ausi - pushed one commits on top: allowedOrigins entries are now normalized (case, trailing slash & default port), plus a clearer note that wildcard hosts need a proxy validating Host, a few more tests and a shorter changelog entry.

@chr-hertel
chr-hertel force-pushed the fix/independent-host-origin-validation branch from 1210bbe to 6d393d0 Compare October 13, 2026 22:41
@chr-hertel
chr-hertel requested a balanced review from Copilot October 13, 2026 22:42

Copilot AI 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.

🟢 Approval recommended

The security behavior is well tested; only a minor documentation clarification remains.

1 open finding

🧠 Review effort: Balanced

Comment thread docs/run/http.md Outdated
@chr-hertel
chr-hertel force-pushed the fix/independent-host-origin-validation branch from eb2e8c7 to f457470 Compare October 13, 2026 23:10
@chr-hertel
chr-hertel merged commit d1e8091 into modelcontextprotocol:main Oct 13, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature that's not currently supported Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Server] Validate Host and Origin independently in DnsRebindingProtectionMiddleware

3 participants