Skip to content

fix(gateway): reject unattributable loopback proxy traffic [AI] - #119950

Merged
joshavant merged 15 commits into
openclaw:mainfrom
pgondhi987:fix/fix-898-v2
Aug 17, 2026
Merged

joshavant merged 15 commits into
openclaw:mainfrom
pgondhi987:fix/fix-898-v2

Conversation

@pgondhi987

@pgondhi987 pgondhi987 commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Gateway ingress-attribution hardening associated with GHSA-3q9h-fq44-7qjh and NVIDIA-dev/openclaw-tracking#898. This is defense in depth for header-bearing HTTP proxy traffic; it does not claim to identify the advisory's headerless raw TCP/socat forwarder.

  • Prepare one typed, immutable ingress-attribution result at the HTTP/WebSocket boundary and carry it through shared-secret auth, Control UI/device fallback, readiness, public device join, public worker admission, node capability, hooks/watch, plugins, and limiter check/failure/reset paths.
  • Reject header-bearing proxy traffic that cannot be attributed to a narrowly configured trusted proxy, with a bounded HTTP+WebSocket diagnostic and actionable configuration guidance.
  • Give configured proxies, managed Tailscale Serve, and managed Funnel per-client limiter subjects. Verified tokenless Serve identity runs before same-source shared-secret lockout.
  • Bind a private ephemeral loopback listener before enabling an OpenClaw-managed Serve/Funnel route, so listener provenance—not spoofable headers—owns managed-Tailscale admission.
  • Remove the former forwarded-loopback magic-key/fallback policy and downstream client-IP rediscovery from core WebSocket auth.

Root cause and owner boundary

The Gateway already knew that forwarded headers made a loopback request non-local, but shared-secret rate limiting could later reconstruct identity from the loopback socket address and regain the configurable loopback exemption. The fix records the authoritative ingress class where the listener accepts the request and reuses that prepared fact everywhere auth state is checked or mutated.

The typed direct-local class records direct-local eligibility; gateway.auth.rateLimit.exemptLoopback remains the authoritative policy for whether loopback is actually exempt. This avoids duplicating runtime limiter configuration inside attribution while still preventing consumers from rediscovering request provenance.

Managed Tailscale contract and lifecycle

  • The private listener is bound before tailscale serve/tailscale funnel changes node configuration.
  • Graceful resetOnExit: false cleanup closes listeners before restoring the stable configured Gateway port; resetOnExit: true clears the OpenClaw-owned route.
  • Any post-attach startup failure joins and invokes Tailscale cleanup before the original startup error is rethrown.
  • A failed persistent-route restore warns without falling back to node-wide serve reset/funnel reset, which could erase newer or unrelated operator routes.

Authoritative upstream contract review at Tailscale commit d200b3f18f0ee4cff1f6819a78a9fe8e6a7367f2:

Abrupt process death can still leave a background route targeting the prior ephemeral port until the next startup rewrites it; eliminating that operational limitation requires a foreground-Tailscale or durable-private-socket design outside this repair.

Compatibility and security boundary

  • No new config keys, defaults, protocol fields, or Plugin SDK API changes.
  • Existing direct-local clients retain the configured loopback-exemption behavior.
  • gateway.tailscale.preserveFunnel is retained only as a deprecated migration guard. An externally preserved Funnel keeps plugin-authenticated webhook routes, but Gateway-authenticated HTTP/WebSocket routes reject it until the operator migrates to managed Funnel; docs include the migration order.
  • Plugin-authenticated routes retain their existing signature/credential owners and receive only the socket source when generic forwarded claims are untrusted. A declined plugin WebSocket upgrade cannot fall through into core auth.
  • The advisory's headerless raw TCP/socat transport remains indistinguishable from a direct local TCP connection. Its GET / probe also does not exercise Gateway auth. This patch does not claim to identify headerless local TCP forwarding.
  • The published local-first trust model still treats public reverse-proxy exposure as unsupported. This is product hardening for a real limiter/provenance invariant, separate from the advisory disposition.

Maintainer decision requested

This repair intentionally makes two product/security tradeoffs. Please record explicit acceptance of both before merge.

  1. Fail closed for unattributable same-host proxies. A loopback peer that sends forwarding headers but is not narrowly configured in gateway.trustedProxies receives proxy_attribution_required before Gateway credentials or fallback auth are evaluated.

    • Operator impact: existing unconfigured same-host nginx/Caddy-style deployments must add a narrow trusted-proxy entry and make the proxy overwrite or safely rebuild the forwarded chain. Clean direct-local traffic is unchanged.
    • Why: a permissive shared fallback cannot establish client identity and permits one unauthenticated client to lock out unrelated clients. Rejecting ambiguous ingress preserves the direct-local exemption without trusting spoofable headers.
    • Approval wording: I accept fail-closed attribution for unconfigured proxy-shaped ingress as the supported upgrade behavior.
  2. Treat the managed Tailscale route claim as startup-critical. In Serve/Funnel mode, the Gateway binds its private listener and must successfully inspect/claim the managed Tailscale route before the ordinary listener begins accepting traffic.

    • Operator impact: a Tailscale CLI, status, authentication, or route-configuration failure aborts Gateway startup instead of leaving ordinary ingress available. Recovery is to repair Tailscale or set gateway.tailscale.mode to off before restarting.
    • Why: continuing after the route claim fails can leave stale or ambiguous routing that bypasses listener-owned provenance. Startup failure is visible and recoverable; silently running with a mismatched exposure boundary is not.
    • Approval wording: I accept the managed Tailscale route claim as startup-critical; claim failures should prevent ordinary Gateway ingress from starting.

The headerless raw TCP/socat case remains intentionally outside this hardening because it is indistinguishable from direct loopback TCP. No GHSA publication or merge is requested without security-owner approval.

Verification

Exact head: ef3f1bbe86b1fc11001d85ea9c94083b62524b8c, based on main 2dffeae12692f6524a1b624ae49108f6832486bc.

  • git diff --check 2dffeae12692f6524a1b624ae49108f6832486bc ef3f1bbe86b1fc11001d85ea9c94083b62524b8c -- .: pass.
  • Focused post-conflict exact-head Gateway suites pass across ingress attribution, device-pairing ingress, public/core WebSocket pre-auth, managed-Tailscale listener provenance, and Tailscale setup/cleanup.
  • Pre-fix regression control reproduced header-bearing same-host proxy traffic retaining the loopback limiter exemption; the prepared-attribution implementation rejects it before authentication.
  • Earlier isolated nginx proof, linked in the PR comments, observed the expected 403 before authentication, a successful direct-local control, and independent budgets for narrowly trusted forwarded clients.
  • Native Tailscale credentials are unavailable in this environment, so no native tailnet Serve/Funnel run is claimed. The pinned upstream Tailscale source review above plus focused lifecycle/attribution tests cover the header and route contracts.

Production/test/docs LOC versus the current exact base (moves and support files classified by role):

  • Production: +1052/-482, net +570.
  • Tests and test support: +1931/-260, net +1671.
  • Docs: +88/-24, net +64.

The production growth is the canonical ingress owner, bounded diagnostics, and dedicated-listener/lifecycle capability. Connected duplicate WebSocket IP resolution, aggregate-key policy, and destructive cleanup fallback were removed rather than retained as compatibility layers.

AI-assisted implementation.

@pgondhi987
pgondhi987 requested a review from a team as a code owner August 6, 2026 13:02
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime security Security documentation size: L maintainer Maintainer-authored PR labels Aug 6, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 6, 2026
@clawsweeper

clawsweeper Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 11:36 PM ET / August 17, 2026, 03:36 UTC.

ClawSweeper review

What this changes

The PR prepares Gateway ingress attribution before HTTP/WebSocket authentication, rejects unattributable proxy-shaped loopback traffic, and makes managed Tailscale routes lifecycle-owned foreground claims.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open for explicit security-owner approval: the patch’s ingress owner is coherent and real behavior proof is strong, but it intentionally changes proxy compatibility and Gateway startup availability.

Priority: P1
Reviewed head: ac395ee33347d2c6e4caefe4e472c863c2ecdbf3
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The branch has strong real behavior evidence and no discrete correctness finding, but its intentional upgrade policy still needs owner approval.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Linked disposable-host nginx and native/managed Funnel runs demonstrate after-fix rejection, controls, public reachability, and cleanup; redact any sensitive host or tailnet details if evidence is reposted.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): Linked disposable-host nginx and native/managed Funnel runs demonstrate after-fix rejection, controls, public reachability, and cleanup; redact any sensitive host or tailnet details if evidence is reposted.
Evidence reviewed 6 items Current-main manifestation: Gateway authentication resolves a client address from forwarded headers but falls back to the socket address, while direct-local status is decided separately; this is the source shape the PR replaces with prepared ingress attribution.
Shipped configuration contract: Current documentation exposes named Tailscale Services and reset-on-exit behavior, so retiring both is an upgrade-sensitive contract change rather than internal cleanup.
PR owner boundary: The submitted head reads prepared ingress attribution before attaching the WebSocket message handler, preventing that consumer from rediscovering client provenance.
Findings None None.
Security None None.

How this fits together

Gateway ingress turns socket and trusted-proxy evidence into an authentication and rate-limit identity before protected HTTP, WebSocket, plugin, and device routes run. Managed Tailscale exposure feeds that same boundary through a private listener and affects Gateway startup and shutdown.

flowchart LR
  A[HTTP or WebSocket request] --> B[Ingress attribution]
  B --> C{Attributable source?}
  C -->|No| D[Actionable rejection]
  C -->|Yes| E[Limiter subject]
  E --> F[Gateway or plugin authentication]
  F --> G[Protected route or connection]
  H[Managed Tailscale route] --> B
Loading

Decision needed

Question Recommendation
Should OpenClaw make unattributable same-host proxy traffic fail closed and make managed Tailscale route claims startup-critical for existing Gateway installations? Adopt listener-owned ingress: Accept both contracts and land the documented Doctor/manual migration path as the supported security posture.

Why: The source and proof support the single-attribution design, but only maintainers can choose the compatibility and availability contract for existing proxy, Service, and Tailscale users.

Before merge

  • Resolve merge risk (P1) - Existing same-host reverse proxies that send forwarding headers will receive a pre-auth rejection until narrowly configured, and named Tailscale Service or preserved external Funnel setups require migration.
  • Resolve merge risk (P1) - A managed Tailscale CLI, authentication, status, or route-claim failure now prevents ordinary Gateway startup; this is a deliberate availability tradeoff.
  • Resolve merge risk (P1) - The repair remains substantial (+951 reported production net lines at the behavior-equivalent head), increasing the value of explicit owner acceptance and exact-head CI.
  • Resolve merge risk (P1) - The current checkout lacks the exact PR-head object and cannot fetch it, so a maintainer should retain the supplied exact-head CI and proof links when making the final decision.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test growth production net +951; tests/support net +2152 at the behavior-equivalent reviewed head The security repair adds a new ingress and route-lifecycle owner, so its substantial production growth merits owner review despite focused proof.
Tailscale upgrade surface 2 retired config fields; 1 hidden legacy CLI flag accepted as a no-op Existing Service and reset-on-exit setups require Doctor or manual migration before they retain supported behavior.

Stored data model

Persistent data-model change detected: migration/backfill/repair: docs/channels/pairing.md, migration/backfill/repair: docs/cli/qr.md, migration/backfill/repair: docs/gateway/doctor.md, migration/backfill/repair: src/commands/doctor-config-flow.test.ts, migration/backfill/repair: src/commands/doctor-config-flow.ts, migration/backfill/repair: src/commands/doctor-tailscale.test.ts, and 14 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #119950
Summary: This PR is the viable canonical repair for the proxied-loopback limiter issue; the earlier branch is dirty and narrower.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the documented hardening contract (recommended)
    Record owner acceptance that unconfigured proxy-shaped ingress fails closed and managed route-claim failures stop Gateway startup.
  2. Choose an upgrade-compatible policy
    Keep the PR open while maintainers specify a supported behavior for legacy proxy, Service, and preserved-Funnel deployments.
  3. Pause the broader route-lifecycle rewrite
    Close or split the PR if the security value does not justify the compatibility and availability policy change.

Technical review

Best possible solution:

Adopt one ingress-attribution owner only after the Gateway/security owner explicitly accepts the fail-closed proxy migration and startup-critical managed-route contract, with Doctor and public migration guidance as the recovery path.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main can fall back to the loopback socket after forwarded-client resolution, and the PR records a pre-fix nginx reproduction of that limiter behavior.

Is this the best way to solve the issue?

Unclear on product policy. Preparing one immutable ingress fact at the listener is the best architectural repair, but maintainers must choose whether the fail-closed and startup-critical consequences are the supported upgrade contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 992a88b7281b.

Labels

Label justifications:

  • P1: This changes a live Gateway authentication/rate-limiting path for proxy and managed-Tailscale users.
  • merge-risk: 🚨 compatibility: Existing unconfigured proxies, named Services, and external Funnel routes can stop reaching Gateway-authenticated paths after upgrade.
  • merge-risk: 🚨 security-boundary: The patch determines which proxy and listener facts can influence authentication and limiter identity.
  • merge-risk: 🚨 availability: Managed Tailscale setup failures become Gateway startup failures.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): Linked disposable-host nginx and native/managed Funnel runs demonstrate after-fix rejection, controls, public reachability, and cleanup; redact any sensitive host or tailnet details if evidence is reposted.
  • proof: sufficient: Contributor real behavior proof is sufficient. Linked disposable-host nginx and native/managed Funnel runs demonstrate after-fix rejection, controls, public reachability, and cleanup; redact any sensitive host or tailnet details if evidence is reposted.

Evidence

What I checked:

  • Current-main manifestation: Gateway authentication resolves a client address from forwarded headers but falls back to the socket address, while direct-local status is decided separately; this is the source shape the PR replaces with prepared ingress attribution. (src/gateway/auth.ts:116, 992a88b7281b)
  • Shipped configuration contract: Current documentation exposes named Tailscale Services and reset-on-exit behavior, so retiring both is an upgrade-sensitive contract change rather than internal cleanup. Public docs: docs/gateway/tailscale.md. (docs/gateway/tailscale.md:42, 992a88b7281b)
  • PR owner boundary: The submitted head reads prepared ingress attribution before attaching the WebSocket message handler, preventing that consumer from rediscovering client provenance. (src/gateway/server/ws-connection.ts:683, ac395ee33347)
  • After-fix behavior proof: The PR discussion records disposable-host nginx proof and native plus managed Funnel proof with an independent public verifier, including route disappearance after graceful shutdown and parent death. (src/infra/tailscale-route-owner.worker.ts:18, 955c5e855074)
  • History and ownership sample: Current local history is shallow, but shortlog over the Gateway/Tailscale owner files identifies steipete as the dominant historical contributor; PR follow-up commits identify joshavant as the recent lifecycle contributor. (src/infra/tailscale.ts:308, 992a88b7281b)
  • Inspection limitation: The exact PR-head object is absent from the local checkout and the attempted promisor fetch could not resolve github.com, so head-specific source review relies on the supplied PR diff and discussion evidence.

Likely related people:

  • steipete: Local shortlog shows the strongest historical contribution volume across the central Gateway authentication and Tailscale owner files. (role: long-term Gateway/Tailscale contributor; confidence: medium; files: src/gateway/auth.ts, src/gateway/server-tailscale.ts, src/infra/tailscale.ts)
  • joshavant: Recent PR commits and follow-up discussion cover foreground route ownership, cleanup ordering, migrations, and rebase reconciliation. (role: recent lifecycle contributor; confidence: high; commits: 366d639048f8, b47f7aab67a6, fbc0e3c46cd0; files: src/infra/tailscale.ts, src/infra/tailscale-route-owner.worker.ts, src/commands/doctor-tailscale.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record explicit Gateway/security-owner acceptance of the proxy and managed-route upgrade contract.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (34 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-14T12:15:00.508Z sha 152e10d03abbe35ac866ba5680a2920bbada82c3 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T12:31:25.537Z sha a6e0254d3a16f114ecfc22fa9119d34c74ed7870 :: found issues before merge. :: [P1] Preserve the reset-on-exit compatibility contract
  • reviewed 2026-08-14T13:10:07.929Z sha 397ccd5e5eaa1ed58b75b0f4476cab7913686fa5 :: found issues before merge. :: [P1] Preserve the reset-on-exit cleanup contract
  • reviewed 2026-08-14T23:24:26.253Z sha 4c6b1df03dd86c2d3d89169c39c5555cdb1b57b9 :: found issues before merge. :: [P1] Keep Funnel enabled when removing an ignored Service setting | [P1] Do not turn the retired reset flag into a dead-end error
  • reviewed 2026-08-14T23:41:07.345Z sha 7116365881c28a40093eca6b11faba22efc4d5ed :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T21:29:34.375Z sha 171816bc621d9487a1b1cb356d1f10f36a7d17b6 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T21:46:43.226Z sha 955c5e855074516366c5915ac96133bcf364c34b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T03:05:18.224Z sha 054f7072a64e6cc3b8bd15eea9c8ba688e8162d7 :: needs maintainer review before merge. :: none

@pgondhi987

pgondhi987 commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Current-head behavior evidence

Head: 81274beeec5cb4cbb22ee990b361b29764cf7fca

Production boundary exercised: the Gateway's real createGatewayHttpServer request router, readiness authentication, plugin dispatch, WebSocket pre-auth admission, and shared ingress-attribution/rate-limiter implementation through the repository's in-memory HTTP/WebSocket adapter.

Command:

node scripts/run-vitest.mjs src/gateway/ingress-attribution.test.ts src/gateway/server-http.probe.test.ts src/gateway/server.preauth-hardening.test.ts src/gateway/server.auth.modes.test.ts src/gateway/server/ws-connection/auth-context.state.test.ts src/gateway/server.plugin-http-auth.test.ts --reporter verbose

Observed denied/fixed scenarios:

  • Header-bearing untrusted loopback traffic was rejected with configuration guidance before protected HTTP and WebSocket routing.
  • Protected API, plugin, and WebSocket route handlers were not called after that rejection, so no credential-validation or protected-route request reached the downstream sink.
  • Repeated wrong remote readiness credentials locked later detail disclosure.
  • A direct-local success reset did not clear managed-proxy failures.
  • IPv4 and IPv4-mapped spellings of the same managed peer selected one opaque bucket.
  • Managed WebSocket pre-auth admission used the prepared non-spoofable peer bucket rather than an unverified forwarded address.

Observed positive controls:

  • A clean direct-loopback token request was allowed and reached normal authentication, retaining its configured exemption.
  • Trusted proxy clients retained isolated per-client subjects.
  • Tagged managed Serve traffic remained eligible for explicit shared-secret authentication while tokenless identity stayed unavailable without a verified login.
  • Managed Funnel plugin dispatch received the prepared forwarded client identity while pre-auth admission retained the peer-keyed limiter subject.

Result:

Test Files  10 passed (10)
Tests       161 passed (161)

Live-environment gap: this run did not use a native Tailscale tailnet, Serve/Funnel daemon, or an external nginx/Caddy process because no approved tailnet credentials or prepared live artifact were available in this session. The evidence therefore proves the current-head Gateway boundary through its nearest production adapter, not native network integration.

@pgondhi987

Copy link
Copy Markdown
Contributor Author

Current-head behavior evidence

Head: b09f807832785383ff81e0a7520be95f35540f5a

Production boundary exercised: the Gateway's real createGatewayHttpServer request router, readiness authentication, WebSocket pre-auth admission, and shared ingress-attribution/rate-limiter implementation through the repository's in-memory HTTP/WebSocket adapter.

Command:

node scripts/run-vitest.mjs src/gateway/ingress-attribution.test.ts src/gateway/server-http.probe.test.ts src/gateway/server.preauth-hardening.test.ts src/gateway/server.auth.modes.test.ts src/gateway/server/ws-connection/auth-context.state.test.ts --reporter verbose

Observed denied/fixed scenarios:

  • Header-bearing untrusted loopback traffic was rejected with configuration guidance before protected HTTP and WebSocket routing.
  • Protected API, plugin, and WebSocket route handlers were not called after that rejection, so no credential-validation or protected-route request reached the downstream sink.
  • Repeated wrong remote readiness credentials locked later detail disclosure.
  • A direct-local success reset did not clear managed-proxy failures.
  • IPv4 and IPv4-mapped spellings of the same managed peer selected one opaque bucket.

Observed positive controls:

  • A clean direct-loopback token request was allowed and reached normal authentication, retaining its configured exemption.
  • Trusted proxy clients retained isolated per-client subjects.
  • Tagged managed Serve traffic remained eligible for explicit shared-secret authentication while tokenless identity stayed unavailable without a verified login.

Result:

Test Files  9 passed (9)
Tests       133 passed (133)

Live-environment gap: this run did not use a native Tailscale tailnet, Serve/Funnel daemon, or an external nginx/Caddy process because no approved tailnet credentials or prepared live artifact were available in this session. The evidence therefore proves the current-head Gateway boundary through its nearest production adapter, not native network integration.

@pgondhi987

Copy link
Copy Markdown
Contributor Author

Current-head behavior evidence

Head: 81274beeec5cb4cbb22ee990b361b29764cf7fca

Production boundary exercised: the Gateway's real createGatewayHttpServer request router, readiness authentication, plugin dispatch, WebSocket pre-auth admission, and shared ingress-attribution/rate-limiter implementation through the repository's in-memory HTTP/WebSocket adapter.

Command:

node scripts/run-vitest.mjs src/gateway/ingress-attribution.test.ts src/gateway/server-http.probe.test.ts src/gateway/server.preauth-hardening.test.ts src/gateway/server.auth.modes.test.ts src/gateway/server/ws-connection/auth-context.state.test.ts src/gateway/server.plugin-http-auth.test.ts --reporter verbose

Observed denied/fixed scenarios:

  • Header-bearing untrusted loopback traffic was rejected with configuration guidance before protected HTTP and WebSocket routing.
  • Protected API, plugin, and WebSocket route handlers were not called after that rejection, so no credential-validation or protected-route request reached the downstream sink.
  • Repeated wrong remote readiness credentials locked later detail disclosure.
  • A direct-local success reset did not clear managed-proxy failures.
  • IPv4 and IPv4-mapped spellings of the same managed peer selected one opaque bucket.
  • Managed WebSocket pre-auth admission used the prepared non-spoofable peer bucket rather than an unverified forwarded address.

Observed positive controls:

  • A clean direct-loopback token request was allowed and reached normal authentication, retaining its configured exemption.
  • Trusted proxy clients retained isolated per-client subjects.
  • Tagged managed Serve traffic remained eligible for explicit shared-secret authentication while tokenless identity stayed unavailable without a verified login.
  • Managed Funnel plugin dispatch received the prepared forwarded client identity while pre-auth admission retained the peer-keyed limiter subject.

Result:

Test Files  10 passed (10)
Tests       161 passed (161)

Live-environment gap: this run did not use a native Tailscale tailnet, Serve/Funnel daemon, or an external nginx/Caddy process because no approved tailnet credentials or prepared live artifact were available in this session. The evidence therefore proves the current-head Gateway boundary through its nearest production adapter, not native network integration.

1 similar comment
@pgondhi987

Copy link
Copy Markdown
Contributor Author

Current-head behavior evidence

Head: 81274beeec5cb4cbb22ee990b361b29764cf7fca

Production boundary exercised: the Gateway's real createGatewayHttpServer request router, readiness authentication, plugin dispatch, WebSocket pre-auth admission, and shared ingress-attribution/rate-limiter implementation through the repository's in-memory HTTP/WebSocket adapter.

Command:

node scripts/run-vitest.mjs src/gateway/ingress-attribution.test.ts src/gateway/server-http.probe.test.ts src/gateway/server.preauth-hardening.test.ts src/gateway/server.auth.modes.test.ts src/gateway/server/ws-connection/auth-context.state.test.ts src/gateway/server.plugin-http-auth.test.ts --reporter verbose

Observed denied/fixed scenarios:

  • Header-bearing untrusted loopback traffic was rejected with configuration guidance before protected HTTP and WebSocket routing.
  • Protected API, plugin, and WebSocket route handlers were not called after that rejection, so no credential-validation or protected-route request reached the downstream sink.
  • Repeated wrong remote readiness credentials locked later detail disclosure.
  • A direct-local success reset did not clear managed-proxy failures.
  • IPv4 and IPv4-mapped spellings of the same managed peer selected one opaque bucket.
  • Managed WebSocket pre-auth admission used the prepared non-spoofable peer bucket rather than an unverified forwarded address.

Observed positive controls:

  • A clean direct-loopback token request was allowed and reached normal authentication, retaining its configured exemption.
  • Trusted proxy clients retained isolated per-client subjects.
  • Tagged managed Serve traffic remained eligible for explicit shared-secret authentication while tokenless identity stayed unavailable without a verified login.
  • Managed Funnel plugin dispatch received the prepared forwarded client identity while pre-auth admission retained the peer-keyed limiter subject.

Result:

Test Files  10 passed (10)
Tests       161 passed (161)

Live-environment gap: this run did not use a native Tailscale tailnet, Serve/Funnel daemon, or an external nginx/Caddy process because no approved tailnet credentials or prepared live artifact were available in this session. The evidence therefore proves the current-head Gateway boundary through its nearest production adapter, not native network integration.

@pgondhi987

pgondhi987 commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor Author

ClawSweeper review

Reviewed August 12, 2026, 7:45 PM UTC.

What this changes

The PR adds canonical Gateway ingress attribution, rejects untrusted forwarded HTTP and WebSocket traffic before authentication, and moves managed Tailscale exposure onto a listener-owned private endpoint with ordered cleanup.

PR surface: production +1139/-575 (net +564); tests/support +1942/-261 (net +1681); docs +88/-24 (net +64).

Merge readiness

Result: needs maintainer review before merge.

Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster

Reviewed head: 0ba43bbd2080

Review scores

  • Overall: 🦞 diamond lobster
  • Proof: 🦞 diamond lobster (sufficient)
  • Patch quality: 🦞 diamond lobster
  • Security: cleared

Verification

Status: sufficient

How this fits together

Gateway ingress attribution sits between incoming HTTP or WebSocket traffic and authentication. It turns socket, trusted-proxy, and managed-Tailscale evidence into a client identity and rate-limit subject, or rejects the request before protected handlers run.

flowchart LR
  A[HTTP or WebSocket request] --> B[Ingress attribution]
  B --> C{Source attributable?}
  C -->|No| D[Actionable 403 rejection]
  C -->|Yes| E[Client identity and limiter subject]
  E --> F[Authentication or plugin-owned auth]
  F --> G[Protected route or connection]
Loading

Decision needed

  • Question: Should Gateway upgrades intentionally reject unconfigured same-host forwarded traffic and make managed Tailscale route setup a prerequisite for ordinary listener startup?
  • Rationale: Source and focused proof establish that the design repairs the limiter/provenance invariant; code cannot decide whether the resulting proxy migration requirement and startup availability tradeoff are the product contract maintainers want.
  • Likely owner: steipete - Their recent history is closest to the Gateway locality and managed-Tailscale policy being decided.
    Options:
  1. Adopt fail-closed attribution (recommended)
    Accept the actionable 403 migration path and the listener-first Tailscale startup contract as the supported security posture.
  2. Preserve a shared fallback
    Keep unconfigured proxy traffic available through a non-exempt shared bucket, accepting ambiguous attribution and cross-client lockout behavior.
  3. Pause the policy change
    Hold both approaches until maintainers define a different proxy attribution and upgrade contract.

Before merge

  • [P1] Existing same-host proxies that send forwarding headers without a narrow gateway.trustedProxies entry will change from credential processing to an actionable 403 after upgrade.
  • [P1] Managed Tailscale route setup or status failure now prevents ordinary Gateway ingress from starting, while abrupt process death can temporarily leave a background route aimed at the prior ephemeral port.
  • [P1] The bug fix is net +564 production lines; the growth has a concrete attribution and listener-lifecycle owner, but remains substantial enough to warrant owner review before landing.
  • Record maintainer acceptance of the remaining decision before merge.
Review details

Best possible solution:

Land one pre-routing attribution owner after the Gateway/security owner explicitly accepts the fail-closed upgrade contract and startup coupling, retaining the existing recovery guidance, plugin-auth exception, and ordered managed-Tailscale cleanup.

Do we have a high-confidence way to reproduce the issue?

Yes. The pre-fix order is source-traceable and was observed as a wrong proxied credential failing to lock the later correct attempt, while exact-head focused and real-nginx evidence show rejection before authentication plus direct-local and trusted-proxy controls.

Is this the best way to solve the issue?

Yes architecturally: preparing one immutable fact at listener ingress is the narrowest maintainable repair and removes downstream rediscovery. The fail-closed compatibility policy, rather than the implementation shape, still requires explicit owner acceptance.

AGENTS.md: found_applied

Codex review notes: model internal, reasoning high; reviewed against 7b73d33.

Label details

Label justifications:

  • P1: This repairs a live Gateway authentication and rate-limiting workflow for proxy and managed-Tailscale deployments, with meaningful upgrade impact.
  • merge-risk: 🚨 compatibility: Unconfigured same-host forwarding proxies and externally preserved Funnel routes can stop reaching Gateway-authenticated paths after upgrade.
  • merge-risk: 🚨 security-boundary: The branch decides which socket, proxy, and Tailscale evidence may influence authentication, credential fallback, and limiter identity.
  • merge-risk: 🚨 availability: Managed Tailscale route setup and status inspection now occur before ordinary ingress and can prevent the Gateway listener from starting.
Evidence reviewed

PR surface: production +1139/-575 (net +564); tests/support +1942/-261 (net +1681); docs +88/-24 (net +64).

  • Current-main manifestation: Before this branch, request context could classify forwarded loopback traffic as non-local while still falling back to the loopback socket address as the rate-limit subject, allowing the configured loopback exemption to survive.
  • Canonical owner boundary: The exact head defines a closed attribution result and caches the first prepared fact on each request, preventing downstream consumers from rediscovering a different identity.
  • HTTP fail-closed gate: The HTTP entry point prepares attribution before routing and rejects unattributable traffic unless the matched path is owned exclusively by plugin authentication; protected node-capability and device-join paths are explicitly rejected.
  • WebSocket fail-closed gate: Upgrade admission rejects unattributable core, worker, and node traffic before connection authentication, and a declined plugin-authenticated upgrade cannot fall through to core authentication.
  • Plugin-auth safeguard: The exception recognizes only existing, well-formed, non-protected paths where every matching plugin route owns authentication, preventing ambiguous route overlaps from gaining the exception.
  • Managed-Tailscale lifecycle: The private loopback listener is bound and the managed route is claimed before ordinary ingress starts; shutdown closes ordinary listeners before restoring or clearing the route.
  • Exact-head focused proof: The supplied exact-head run exercised the production Gateway attribution, auth, plugin, capability, WebSocket, limiter, Tailscale lifecycle, and cleanup paths: 20 focused test files and 1,029 tests passed, including negative paths, benign controls, and protected-sink assertions.
    • file: src/gateway/ingress-attribution.test.ts:1
    • command: pnpm exec vitest run src/gateway/ingress-attribution.test.ts src/gateway/auth-rate-limit.test.ts src/gateway/auth.test.ts src/gateway/control-ui.http.test.ts src/gateway/server.plugin-node-capability-auth.test.ts src/gateway/server.preauth-hardening.test.ts src/gateway/server-runtime-state.tailscale.test.ts src/gateway/server-tailscale.test.ts src/gateway/server/ws-connection/auth-context.test.ts src/infra/tailscale.test.ts
    • sha: 0ba43bbd2080
  • Real proxy behavior proof: A production Gateway run through nginx showed unconfigured forwarded traffic receiving the attribution 403 before authentication, direct-local traffic succeeding, and narrowly trusted forwarded clients retaining independent budgets.
  • Tailscale header contract: The supplied pinned upstream inspection establishes that Serve overwrites forwarded host, protocol, and client headers, removes inbound Tailscale-owned identity markers, and then writes listener-owned Funnel or WhoIs identity evidence.
  • Tailscale concurrent-update contract: The pinned upstream local client reads the Serve configuration ETag and sends it through If-Match, so concurrent mutations fail rather than silently overwriting a newer configuration.
  • Security policy classification: The protected shared-secret limiter is a security-control hardening boundary; public reverse-proxy exposure and hostile code already running on the trusted host are outside the documented vulnerability boundary, while supported Tailscale behavior still requires safe provenance and lifecycle handling.

@openclaw-barnacle openclaw-barnacle Bot closed this Aug 7, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 7, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 7, 2026
@pgondhi987

Copy link
Copy Markdown
Contributor Author

ClawSweeper proof for current head 97f214167367ac393ec21f9f2c608de2b2416b3c

Behavior proved: the production Gateway rejects forwarding-header traffic from an unconfigured nginx peer before authentication, while direct-local traffic and correctly configured per-client proxy budgeting still work.

Environment: AWS Crabbox lease cbx_5e5c392efa12, run run_3c9fd7146a38, nginx 1.28.3, production entry point pnpm openclaw gateway run.

Command/artifact:

Evidence:

  • fixed/denied: a valid credential through unconfigured nginx returned HTTP 403 and proxy_attribution_required; 12/12 wrong-credential attempts were denied. Protected sink/source result: no credential request reached authentication; authentication was not called.
  • positive control: an allowed headerless direct-local network request succeeded with 200_DETAILED; intended behavior: genuine local access still works.
  • control: after narrowly trusting nginx, client A became locked after two failures while client B still returned 200_DETAILED; intended behavior: forwarded clients retain independent budgets.
  • exact output: UNCONFIGURED_PROXY_STATUS=403, UNCONFIGURED_WRONG_ATTEMPTS=12/12_DENIED_BEFORE_AUTH, DIRECT_LOCAL_CONTROL=200_DETAILED, TRUSTED_CLIENT_A_AFTER_LOCKOUT=200_AGGREGATE_ONLY, TRUSTED_CLIENT_B_CONTROL=200_DETAILED, PER_CLIENT_ISOLATION=PASS.

Compatibility/operator note: forwarding-header traffic now requires a narrowly configured trusted proxy that overwrites or safely rebuilds client headers; clean direct-local traffic remains supported.

Live gaps: no native Tailscale daemon or tailnet credentials were available. Managed Serve/Funnel header production and WhoIs behavior are supported by inspected upstream Tailscale source plus focused lifecycle/attribution tests, not a live tailnet run.

pgondhi987 and others added 9 commits August 16, 2026 22:31
Refuse reset-on-exit publication until Tailscale exposes an atomic owner-bound cleanup operation, and migrate legacy configs with Doctor.
Run managed Serve and Funnel routes as foreground claims tied to the Gateway lifecycle. Retire named Service config through Doctor because Tailscale Services cannot run in foreground mode.

Co-authored-by: Pavan Kumar Gondhi <[email protected]>
Remove the retired named-service config from Telegram Mini App URL resolution and register the lifecycle worker as an explicit production entry.

Co-authored-by: Pavan Kumar Gondhi <[email protected]>
Keep Funnel enabled when removing an ignored named-Service setting and accept the legacy positive reset flag as a no-op now that managed routes always follow Gateway lifetime.

Co-authored-by: Pavan Kumar Gondhi <[email protected]>
Prefer the actionable foreground CLI failure captured during timeout cleanup, and cover the original delayed-failure ordering.

Co-authored-by: Pavan Kumar Gondhi <[email protected]>
Preserve current ingress ownership contracts after the rebase, retire the obsolete device-auth migration check, validate route-owner IPC, and move Tailscale auth coverage onto the managed listener.

Co-authored-by: Pavan Kumar Gondhi <[email protected]>
Unify the rebased net imports and let module-reset WebSocket tests prepare attribution through the same fresh module instance as the handler.

Co-authored-by: Pavan Kumar Gondhi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios app: web-ui App: web-ui channel: telegram Channel integration: telegram cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: device-pair gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security Security documentation size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants