openclaw - ✅(Solved) Fix [Bug]: Localhost trusted-proxy authentication broken [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#59167Fetched 2026-04-08 02:27:53
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×2referenced ×2cross-referenced ×1

Since #54536, it seems that a localhost trusted-proxy is no longer trusted at all. This seems to have even been explicit in the design, since a test was written that states "rejects trusted-proxy identity headers from loopback sources".

It's unclear what the new configuration should be to allow authentication via a local proxy that's performing authn/authz.

Error Message

  1. Receive unauthorized error

Root Cause

Since #54536, it seems that a localhost trusted-proxy is no longer trusted at all. This seems to have even been explicit in the design, since a test was written that states "rejects trusted-proxy identity headers from loopback sources".

It's unclear what the new configuration should be to allow authentication via a local proxy that's performing authn/authz.

Fix Action

Fixed

PR fix notes

PR #59190: fix(auth): enhance trusted-proxy handling for non-loopback forwarded IPs

Description (problem / solution / changelog)

Summary

  • Problem: Trusted-proxy auth rejected all loopback sources, which broke same-host reverse proxy setups (for example Caddy or nginx on localhost) even when gateway.trustedProxies explicitly included loopback.
  • Why it matters: Local authn/authz proxy deployments could no longer access Gateway, causing unauthorized failures with reason trusted_proxy_loopback_source.
  • What changed: In trusted-proxy mode, loopback proxy sources are now allowed only when forwarded client IP resolves to a non-loopback address.
  • What did NOT change (scope boundary): Direct loopback requests without valid forwarded client origin still fail closed; no token/password auth behavior changed.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #59167
  • Related #54536
  • This PR fixes a bug or regression

Root Cause / Regression History (if applicable)

  • Root cause: Trusted-proxy authorization added a blanket loopback-source rejection in src/gateway/auth.ts, so trusted identity headers from localhost proxies were always denied.
  • Missing detection / guardrail: No positive test existed for same-host trusted proxy with non-loopback forwarded client origin.
  • Prior context (git blame, prior PR, issue, or refactor if known): Regression introduced in the hardening change from #54536.
  • Why this regressed now: The loopback block was unconditional, so explicit trustedProxies loopback configurations could not succeed.
  • If unknown, what was ruled out: N/A

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
  • Unit test
  • Seam / integration test
  • End-to-end test
  • Existing coverage already sufficient
  • Target test or file: auth.test.ts
  • Scenario the test should lock in: Accept same-host trusted-proxy auth when x-forwarded-for resolves to a non-loopback client IP, while still rejecting missing/loopback client chains.
  • Why this is the smallest reliable guardrail: Logic is isolated in gateway auth path and can be validated deterministically in unit tests.
  • Existing test that already covers this (if any): Existing tests already covered loopback rejection and fail-closed behavior.
  • If no new test is added, why not: N/A (new test added)

User-visible / Behavior Changes

  • Trusted-proxy mode on loopback now works for local reverse proxies if forwarded client origin is present and non-loopback.
  • Requests still fail with trusted_proxy_loopback_source when forwarded client origin is missing or resolves to loopback.

Diagram (if applicable)

Before:
[localhost proxy request with identity headers] -> [loopback source check] -> [always reject]

After:
[localhost proxy request with identity headers]
-> [loopback source check]
-> [resolve forwarded client IP]
-> [non-loopback client IP: allow trusted-proxy auth]
-> [missing/loopback client IP: reject]

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Windows 11 dev environment; issue report target is Debian 13
  • Runtime/container: local test runner
  • Model/provider: N/A
  • Integration/channel (if any): Gateway trusted-proxy auth
  • Relevant config (redacted): trusted-proxy mode with trustedProxies including 127.0.0.1

Steps

  1. Configure gateway auth mode trusted-proxy with trustedProxies including loopback.
  2. Send request from loopback source with trusted identity headers and x-forwarded-for as non-loopback client IP.
  3. Validate auth succeeds; verify loopback-only or missing forwarded client origin still fails.

Expected

  • Same-host proxy auth succeeds when forwarded client origin is non-loopback.

Actual

  • Previously all loopback trusted-proxy requests were rejected; now behavior matches expected with fail-closed safety preserved.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Scoped verification run:

  • corepack pnpm test -- auth.test.ts -t "accepts same-host proxy identity headers when forwarded client IP is non-loopback|rejects trusted-proxy identity headers from loopback sources|fails closed when forwarded headers are present but the client chain resolves to loopback"
  • Result: 3 passed, 0 failed

Human Verification (required)

  • Verified scenarios: New same-host trusted-proxy success path with non-loopback x-forwarded-for; existing loopback fail-closed paths.
  • Edge cases checked: Missing forwarded headers and loopback-only forwarded chain still rejected.
  • What you did not verify: Full external reverse-proxy end-to-end (Caddy/Authelia) in this branch.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: Proxies that do not send client-origin forwarding headers remain blocked on loopback.
  • Mitigation: This is intentional fail-closed behavior; deployment guidance should require trusted proxy to set x-forwarded-for with real client IP.

https://github.com/openclaw/openclaw/issues/59167

Changed files

  • src/gateway/auth.test.ts (modified, +28/-0)
  • src/gateway/auth.ts (modified, +4/-1)

Code Example

2. Configure a local proxy that performs authentication (i.e., Caddy + authelia) and injects a Remote-User header.
3. Receive unauthorized error

### Expected behavior

User is authorized based on trusted proxy header.

### Actual behavior

User is not authenticated, logs indicate `reason=trusted_proxy_loopback_source`

### OpenClaw version

2026.3.31

### Operating system

Debian 13 (trixie)

### Install method

openclaw installer script

### Model

openrouter/minimax/minimax-m2.5

### Provider / routing chain

openclaw -> openrouter -> minimax-m2.5

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Since #54536, it seems that a localhost trusted-proxy is no longer trusted at all. This seems to have even been explicit in the design, since a test was written that states "rejects trusted-proxy identity headers from loopback sources".

It's unclear what the new configuration should be to allow authentication via a local proxy that's performing authn/authz.

Steps to reproduce

  1. Start the latest openclaw (2026.3.31) with the following in the config:
    "port": 18789,
    "mode": "local",
    "bind": "loopback",
    "trustedProxies": ["127.0.0.1", "::1"],
    "auth": {
      "mode": "trusted-proxy",
      "trustedProxy": {
              "userHeader": "Remote-User",
              "allowUsers": ["foo"]
      }
    },
  1. Configure a local proxy that performs authentication (i.e., Caddy + authelia) and injects a Remote-User header.
  2. Receive unauthorized error

Expected behavior

User is authorized based on trusted proxy header.

Actual behavior

User is not authenticated, logs indicate reason=trusted_proxy_loopback_source

OpenClaw version

2026.3.31

Operating system

Debian 13 (trixie)

Install method

openclaw installer script

Model

openrouter/minimax/minimax-m2.5

Provider / routing chain

openclaw -> openrouter -> minimax-m2.5

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

Affected: anyone using a local authentication proxy Severity: completely blocks gateway access

Additional information

No response

extent analysis

TL;DR

  • Update the trustedProxies configuration to include a specific setting that allows trusted-proxy identity headers from loopback sources.

Guidance

  • Review the OpenClaw documentation for any changes to the trustedProxies configuration that may affect loopback sources.
  • Check the test case mentioned in the issue (#54536) to understand the intended behavior of trusted-proxy identity headers from loopback sources.
  • Consider adding a new configuration option to explicitly allow trusted-proxy identity headers from loopback sources, if available.
  • Verify that the local proxy is correctly injecting the Remote-User header and that the header is being received by OpenClaw.

Example

  • No code snippet is provided as the issue does not clearly imply a specific code change.

Notes

  • The issue lacks information about the specific changes made in #54536, which may be necessary to understand the intended behavior.
  • The OpenClaw version (2026.3.31) may have introduced changes to the trustedProxies configuration that affect loopback sources.

Recommendation

  • Apply workaround: Update the trustedProxies configuration to include a specific setting that allows trusted-proxy identity headers from loopback sources, if available, as the current configuration seems to explicitly reject such headers from loopback sources.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

User is authorized based on trusted proxy header.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING