Enhance auth logic for trusted-proxy mode#45264
Enhance auth logic for trusted-proxy mode#45264zhangning-agent wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR adds a local-token fallback to Key changes:
Issues found:
Confidence Score: 3/5
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4b3d5c20f
ℹ️ 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".
5ff7596 to
c154260
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c154260f23
ℹ️ 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".
c154260 to
7653efd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e96a625ff7
ℹ️ 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".
e96a625 to
3cfc79f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3cfc79fe32
ℹ️ 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".
e868d2a to
168675b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 168675b9f5
ℹ️ 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: c2edd91c16
ℹ️ 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: 4cc3c869d4
ℹ️ 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".
4cc3c86 to
11373a3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11373a3d2d
ℹ️ 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".
| if (localDirect && !hasProxyIdentityHeader) { | ||
| return { ok: true, method: "trusted-proxy", user: "local" }; |
There was a problem hiding this comment.
Require secret validation for local trusted-proxy path
This branch grants ok: true for any localDirect request that omits the configured identity header, but it runs before authorizeTrustedProxy() and never checks a token/password, so any same-host process that can hit loopback with a localish Host can authenticate as user: "local" in trusted-proxy mode. That bypasses trustedProxy.userHeader/allowUsers, and downstream WebSocket policy treats method === "trusted-proxy" as shared auth (src/gateway/server/ws-connection/auth-context.ts:148-154), which can admit unauthorized operator control sessions.
Useful? React with 👍 / 👎.
|
Closing as unable to push to your branch. Tracking work on this PR and credit will be given to you #54536. |
Add fallback for local requests in token verification logic.
Summary
Describe the problem and fix in 2–5 bullets:
gateway.auth.mode: trusted-proxy, loopback CLI/sub-agent requests are immediately rejected because they cannot provide the configured proxy headers (e.g.,userHeader).trusted-proxymode.trusted-proxymode. If a request verifies aslocalDirect(loopback) and a localtokenis configured, it falls back to token verification rather than strictly failing on proxy headers.trusted-proxymode still strictly require proxy headers. The underlying token and trusted-proxy validation logic itself remains unchanged.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Local
openclawCLI commands and Sub-agent sessions will now work seamlessly (via the configuredopenclaw.jsontoken) when the gateway is running locally behindtrusted-proxymode, avoiding "trusted_proxy_user_missing" connection errors.Security Impact (required)
NoNoNoNoNoYes, explain risk + mitigation:Repro + Verification
Environment
pnpm/noden/alocal CLISteps
openclaw.jsonwithgateway.auth.mode: trusted-proxyand a validtoken.openclaw gateway run.openclaw status.Expected
Actual
unauthorizedortrusted_proxy_user_missingbecause the CLI could not emulate the proxy header. Now it successfully falls back to token validation.Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
trusted-proxymode) and executing SDK/CLI commands loopback natively over port18789.Review Conversations
Compatibility / Migration
YesNoNoFailure Recovery (if this breaks)
main.openclaw statusfailing on users who rely heavily on local proxy header injection for testing.Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.gateway.auth.tokenexists inside the configuration. The primary security model fortrusted-proxyis uncompromised for network boundaries.