Skip to content

security(gateway): refuse the standard spoofable client-IP and host headers - #870

Merged
lakhansamani merged 1 commit into
mainfrom
security/spoofable-header-override
Nov 8, 2026
Merged

lakhansamani merged 1 commit into
mainfrom
security/spoofable-header-override

Conversation

@lakhansamani

Copy link
Copy Markdown
Contributor
  • The gateway header matcher refused 4 of the ~29 standard client-IP and host headers, and groupLocation built an absolute URL from the request Host, which bypassed --url. grpc-gateway v2.33.0 already drops every Grpc-Metadata-* header, so the matcher change is a guard against that behaviour coming back; the groupLocation change closes a gap that is open now.
  • internal/gateway/mount.go: the refusal list moves into refusedForwardingHeaders, a package-level set of 29 canonical header keys. The matcher and its test both read that set, so the list cannot drift away from the policy. Add a key there, not at the call site.
  • internal/http_handlers/scim/groups.go: groupLocation takes its base from parsers.GetHostFromRequest, so --url wins over every header. A SCIM client could previously choose the host in the meta.location it got back. Risk to check: on a deployment that sets no --url, meta.location now always carries a value, where it was omitted when Host was empty.
  • X-Forwarded-For and X-Forwarded-Host keep their bare spelling. runtime.AnnotateContext writes both itself, before this matcher runs, so no header policy here can refuse them. Their consumers hold the other half: transport.clientIPFromGRPC reads the rightmost x-forwarded-for value, and transport.hostURLFromGRPC prefers --url and reads x-authorizer-url.
  • Limit of the change: the matcher governs gRPC metadata only. It does not strip headers from a raw *http.Request, so the gin path still reads X-Forwarded-For and X-Real-Ip under --trusted-proxies. Nothing in this repo reads the vendor keys (Cf-Connecting-Ip, True-Client-Ip and the rest) today, and gin's TrustedPlatform is unset, so those entries prevent a future regression rather than fix a present one.

The matcher listed 4 of ~29 standard client-IP and host headers, and
groupLocation built a URL from the request Host, bypassing --url.
@lakhansamani
lakhansamani force-pushed the security/spoofable-header-override branch from 4db8502 to d8c5344 Compare November 8, 2026 13:50
@lakhansamani
lakhansamani merged commit 191208e into main Nov 8, 2026
4 checks passed
@lakhansamani
lakhansamani deleted the security/spoofable-header-override branch November 8, 2026 14:01
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