Gateway: reject mixed trusted-proxy token config#58371
Gateway: reject mixed trusted-proxy token config#58371jacobtomlinson merged 2 commits intoopenclaw:mainfrom
Conversation
|
Incorporated the earlier proposed validation change here and preserved co-author credit in the commit. |
Greptile SummaryThis PR tightens gateway startup validation by making Key changes:
Confidence Score: 5/5Safe to merge — no correctness issues remain; the mutual-exclusion guard is correct and the removal of the loopback fallback is consistent with the new policy. All P1 concerns from prior review threads have been resolved: the startup validator now correctly rejects mixed configs, the loopback fallback code has been fully removed (eliminating the false-confidence from the old token-fallback tests), and the new ordering test confirms the trustedProxy presence guard still fires before the token-conflict guard. No new logic bugs or security gaps were identified in this pass. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/gateway/auth.ts | Adds mutual-exclusion guard in assertGatewayAuthConfigured for trusted-proxy + token and removes the local-direct loopback token fallback from authorizeGatewayConnect; both changes are logically consistent and correctly implemented. |
| src/gateway/auth.test.ts | Adds parameterised tests for both config-token and env-token rejection paths, adds an ordering test confirming missing-trustedProxy error takes precedence, renames the describe block, and updates all local-direct expectations from ok/token to rejected/loopback-source to match removed fallback. |
Reviews (2): Last reviewed commit: "Gateway: fail closed for loopback truste..." | Re-trigger Greptile
Co-authored-by: boy-hack <w8ay@qq.com>
32d8ce4 to
ef573d3
Compare
|
@greptile review |
* Gateway: reject mixed trusted-proxy token config Co-authored-by: boy-hack <w8ay@qq.com> * Gateway: fail closed for loopback trusted-proxy auth --------- Co-authored-by: boy-hack <w8ay@qq.com>
…proxy mode Upstream PR openclaw#58371 removed the local-direct token auth fallback from trusted-proxy mode and made auth.token mutually exclusive with trusted-proxy. This left no auth path for loopback connections (CLI, sub-agents) which connect via 127.0.0.1 with password auth. When authorizeTrustedProxy returns trusted_proxy_loopback_source, fall back to password auth if auth.password is configured and the client provided a matching password. This restores local CLI access without weakening the trusted-proxy security model for external connections. Fixes: sub-agent spawns failing with 'unauthorized' on trusted-proxy gateways.
Upstream PR openclaw#58371 removed the local-direct token auth fallback from trusted-proxy mode, leaving loopback connections (CLI, sub-agents) with no auth path. They are rejected by authorizeTrustedProxy with trusted_proxy_loopback_source, and auth.token is banned in this mode. Fix: when authorizeTrustedProxy returns trusted_proxy_loopback_source, fall back to password auth if auth.password is configured and the client provided a matching password. Rate limiting and failure recording apply. Includes 3 new tests (61 total passing).
* Gateway: reject mixed trusted-proxy token config Co-authored-by: boy-hack <w8ay@qq.com> * Gateway: fail closed for loopback trusted-proxy auth --------- Co-authored-by: boy-hack <w8ay@qq.com>
* Gateway: reject mixed trusted-proxy token config Co-authored-by: boy-hack <w8ay@qq.com> * Gateway: fail closed for loopback trusted-proxy auth --------- Co-authored-by: boy-hack <w8ay@qq.com>
* Gateway: reject mixed trusted-proxy token config Co-authored-by: boy-hack <w8ay@qq.com> * Gateway: fail closed for loopback trusted-proxy auth --------- Co-authored-by: boy-hack <w8ay@qq.com>
Summary
trusted-proxygateway auth configs that also resolve a shared tokenChanges
assertGatewayAuthConfigured(...)fortrusted-proxyplus shared-token configgateway.auth.tokenandOPENCLAW_GATEWAY_TOKENValidation
OPENCLAW_TEST_PROFILE=serial pnpm test -- src/gateway/auth.test.ts -t "rejects trusted-proxy mode when shared token comes from"claude -p "/review"and added env-token coverage based on the feedbackNotes