-
Notifications
You must be signed in to change notification settings - Fork 221
Add Origin header validation for DNS-rebind protection #4908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -331,6 +331,18 @@ func WithAllowDockerGateway(allow bool) RunConfigBuilderOption { | |
| } | ||
| } | ||
|
|
||
| // WithAllowedOrigins sets the HTTP Origin-header allowlist used for | ||
| // DNS-rebinding protection (MCP 2025-11-25 §"Security Warning"). | ||
| // An empty slice defers the choice to middleware wiring, which derives a | ||
| // loopback-only default when the bind host is loopback and otherwise leaves | ||
| // the middleware disabled. | ||
| func WithAllowedOrigins(origins []string) RunConfigBuilderOption { | ||
| return func(b *runConfigBuilder) error { | ||
| b.config.AllowedOrigins = origins | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new Is this intentional, or an omission? If intentional, what's the rationale for excluding
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch — and the fix needed to go deeper than moving the call into |
||
| return nil | ||
| } | ||
| } | ||
|
|
||
| // WithTrustProxyHeaders sets whether to trust X-Forwarded-* headers from reverse proxies | ||
| func WithTrustProxyHeaders(trust bool) RunConfigBuilderOption { | ||
| return func(b *runConfigBuilder) error { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The operator path uses
PopulateMiddlewareConfigsso the factory side is wired, butMCPServerSpec/MCPRemoteProxySpec/VirtualMCPServerSpechave noAllowedOriginsfield. Combined with operator-deployed pods binding to non-loopback addresses,ResolveAllowedOriginsreturnsnilandaddOriginMiddlewareskips registration with a WARN — so K8s deployments ship with Origin validation disabled.Is this expected, planned for a follow-up PR, or considered out of scope for the CRDs? If a follow-up, would it be worth a
// TODOor a note in the PR description so it's tracked?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deferring CRD wiring to a follow-up to keep this PR focused on CLI/proxyrunner. Documented explicitly in the commit message and in the
prependOriginMiddlewaredoc comment: operator non-loopback pods log the WARN rather than enforcing until the CRD field lands. Tracked in a follow-up issue: "AddallowedOriginsto MCPServer/MCPRemoteProxy/VirtualMCPServer CRDs + operator wiring."