Skip to content

fix(gateway): require loopback proxy IP for trusted-proxy + bind=loopback#22082

Merged
mbelinky merged 2 commits intomainfrom
fix/trusted-proxy-loopback-local-proxy-guard
Feb 20, 2026
Merged

fix(gateway): require loopback proxy IP for trusted-proxy + bind=loopback#22082
mbelinky merged 2 commits intomainfrom
fix/trusted-proxy-loopback-local-proxy-guard

Conversation

@mbelinky
Copy link
Contributor

@mbelinky mbelinky commented Feb 20, 2026

Problem

After #20097, auth.mode=trusted-proxy + bind=loopback is allowed (good), but misconfigured gateway.trustedProxies values (for example only 10.0.0.1) can still make auth fail in confusing ways for same-host proxy setups.

Fix

  • In runtime config validation, when auth.mode=trusted-proxy and resolved bind is loopback, require gateway.trustedProxies to include a loopback proxy address (127.0.0.1, ::1, or loopback CIDR).
  • Add tests for:
    • loopback trusted-proxy with ::1 (allowed)
    • loopback trusted-proxy with non-loopback trusted proxy IP (rejected)
  • Update Trusted Proxy docs to reflect loopback-first same-host proxy setup guidance.

Verification

  • pnpm vitest run src/gateway/server-runtime-config.test.ts

Follow-up hardening for #20097.

Greptile Summary

Adds runtime validation to prevent misconfigured gateway.trustedProxies from breaking auth in same-host proxy setups. When bind=loopback and auth.mode=trusted-proxy, the gateway now requires at least one loopback address (127.0.0.1, ::1, or a loopback CIDR) in the trusted proxy list.

The implementation leverages existing isTrustedProxyAddress CIDR-matching logic and includes comprehensive test coverage for both IPv4 and IPv6 loopback addresses, as well as rejection cases. Documentation correctly reflects the new requirement with clear guidance for same-host proxy configurations.

Confidence Score: 5/5

  • This PR is safe to merge with no blocking issues
  • The implementation is straightforward and defensive - it adds validation to catch a misconfiguration scenario early. The code correctly reuses existing CIDR-matching logic via isTrustedProxyAddress, includes comprehensive test coverage for both acceptance and rejection paths (covering 127.0.0.1, ::1, non-loopback addresses, and empty proxy lists), and follows the existing validation pattern. Documentation is properly updated to reflect the new requirement.
  • No files require special attention

Last reviewed commit: 7cdbb65

@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Feb 20, 2026
@mbelinky mbelinky merged commit 094dbda into main Feb 20, 2026
10 checks passed
@mbelinky mbelinky deleted the fix/trusted-proxy-loopback-local-proxy-guard branch February 20, 2026 18:03
@mbelinky
Copy link
Contributor Author

Merged via squash.\n\n- Prepared head SHA: 6ff3ca9\n- Merge commit: 094dbda\n\nThanks @mbelinky!

rodrigogs pushed a commit to rodrigogs/openclaw that referenced this pull request Feb 20, 2026
…back (openclaw#22082)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 6ff3ca9
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
Hansen1018 added a commit to Hansen1018/openclaw that referenced this pull request Feb 21, 2026
…back (openclaw#22082)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 6ff3ca9
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
vincentkoc pushed a commit that referenced this pull request Feb 21, 2026
…back (#22082)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 6ff3ca9
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
dgarson pushed a commit to dgarson/clawdbot that referenced this pull request Feb 21, 2026
…back (openclaw#22082)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 6ff3ca9
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
mmyyfirstb pushed a commit to mmyyfirstb/openclaw that referenced this pull request Feb 21, 2026
…back (openclaw#22082)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 6ff3ca9
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
obviyus pushed a commit to guirguispierre/openclaw that referenced this pull request Feb 22, 2026
…back (openclaw#22082)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 6ff3ca9
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
mreedr pushed a commit to mreedr/openclaw-custom that referenced this pull request Feb 24, 2026
…back (openclaw#22082)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 6ff3ca9
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…back (openclaw#22082)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 6ff3ca9
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant