fix(auth): enhance trusted-proxy handling for non-loopback forwarded IPs#59190
fix(auth): enhance trusted-proxy handling for non-loopback forwarded IPs#59190Sandblaze05 wants to merge 13 commits intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0c1934bcc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adjusts Gateway trusted-proxy authentication to support same-host reverse proxies on loopback only when a non-loopback client origin is provided via forwarded IP headers, restoring intended localhost proxy deployments broken by prior loopback-source rejection hardening.
Changes:
- Allow loopback proxy sources in
trusted-proxymode whenx-forwarded-forresolves to a non-loopback client IP; otherwise continue failing closed. - Add a unit test covering the new same-host proxy success path with a non-loopback forwarded client IP.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/gateway/auth.ts | Relaxes loopback-source rejection for trusted-proxy auth when a non-loopback forwarded client IP is present. |
| src/gateway/auth.test.ts | Adds regression test ensuring same-host trusted-proxy auth succeeds only with a non-loopback forwarded client IP. |
Greptile SummaryThis PR fixes a regression (introduced in #54536) where What changed:
Logic correctness: The fix is sound. The outer One test gap: The existing test Confidence Score: 5/5
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe9c6a14d9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Added The issue: The previous loopback exception allowed any local process to forge The solution:
Trade-off: Operators with existing localhost reverse proxy setups can now enable this flag consciously, understanding the risk. The naming and documentation make the security implications explicit — this is a deliberate choice, not an implicit vulnerability. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54d0342e05
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ede127eae8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82653dae77
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…y mode and update tests
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08c61ac292
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Security + Contract UpdateSummaryThis PR hardens trusted-proxy auth for localhost reverse-proxy deployments while preserving existing observable failure semantics. What changed
Contract compatibility (important)Loopback-source rejections continue to return the existing reason code:
This preserves behavior for existing callers/consumers that rely on the previous loopback rejection contract, avoiding a reason-code migration in this PR. Why this shape
Validation
|
|
"The issue: The previous loopback exception allowed any local process to forge x-forwarded-for and identity headers, enabling privilege elevation attacks on same-host reverse proxies (nginx/Caddy on localhost)." How does being non-local stop this form of attack? If I move my proxy to a separate host, a rogue local process on that host could still forge x-forwarded-for and identity headers... You're not removing any attack surface, you're just moving the surface to another host. In practice blocking loopback proxies will make users far less secure because it pushes users toward binding Gateway on a non-loopback interface so a same-machine proxy can reach it via the host’s LAN IP, which can be less secure than a loopback-only deployment if firewalling is not perfect. The net effect may be to trade a localhost trust issue for broader network exposure. Literally when I asked my OpenClaw jow to fix my proxy setup, it told me I would need to change my network bind to bind to "lan" (IE: 0.0.0.0) and use my hosts LAN IP (192.168.x.x) in the proxy config. That is exactly what people are going to start doing. |
|
Thanks @Sandblaze05. #73266 landed the localhost trusted-proxy fix and closed #59167. I am closing this PR as superseded because the landed version keeps the same-host reverse-proxy path behind an explicit |
Summary
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
Regression Test Plan (if applicable)
User-visible / Behavior Changes
Diagram (if applicable)
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Scoped verification run:
Human Verification (required)
Review Conversations
Compatibility / Migration
Risks and Mitigations
#59167