Skip to content

fleet proxy serve: auto-spawned broker inherits the caller ambient proxy env and silently breaks tailnet tunnels #12555

Closed

Description

@dezren39

Problem

Any fleet client that finds no proxy broker running auto-spawns fleet proxy serve with the caller's ambient environment. From an agent shell in the muse sandbox, that means the broker inherits the sandbox egress proxy (HTTPS_PROXY pointing at hatch-egress-proxy:3128) instead of tailscaled's local CONNECT proxy (127.0.0.1:3130, recorded in fleet-proxy.env).

The broker process looks alive — it holds its socket and pid file — but every tunnel it opens goes to the wrong proxy, so the queue and shell legs to the laptop fail (proxy closed during CONNECT to 100.99.113.103:4801/4799) while the bridge and GitHub legs stay green. Nothing logs the mismatch; the seat presents as "laptop unreachable" when the laptop is fine.

Reproduction (2026-11-22, muse sandbox seat)

  1. Seat healthy, then the proxy broker died at some point (stale socket/pid file left behind).
  2. A plain ~/tools/fleet agent doctor --agent felix at ~13:07 UTC auto-spawned a new broker (pid 48122).
  3. The new broker's live environment (/proc/48122/environ) held HTTPS_PROXY = the sandbox egress proxy, not http://127.0.0.1:3130.
  4. Doctor then reported the shell leg broken on a seat the keeper had verified healthy minutes earlier — the diagnostic command itself re-broke the seat.

The same failure class caused the 2026-11-22 05:40 CST outage window: the broker had been started while tailscaled was dead and kept the wrong proxy env, so queue/shell stayed down after the tailnet recovered until the broker was manually restarted with the correct env.

Workaround in place

The sandbox ensure layer now polices the invariant externally: ~/tools/fleet-proxy-ensure.sh (run by the seat keeper and the init prelude) compares the broker's live /proc/<pid>/environ HTTPS_PROXY against fleet-proxy.env and respawns the broker with the correct env on mismatch or death. This corrects the seat within about a minute, but it is a watchdog around the defect, not a fix.

Suggested durable fix

At broker spawn, fleet should not trust the ambient env for the tailnet proxy:

  • source fleet-proxy.env (the file tailscaled's bootstrap writes next to its state) when constructing the broker's environment, or
  • refuse the sandbox egress proxy for tailnet targets (100.64.0.0/10 destinations must go via tailscaled's CONNECT proxy or direct, never via the egress proxy).

Either removes the failure class for every fleet client, not just seats with an external ensure watching.

Activity

  1. developing-today commented on Nov 22, 2026

    @developing-today
    Contributor
  2. added 2 commits that reference this issue on Nov 22, 2026
  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Pointer from the #12426 lane: the Python-side remainder of this failure class landed in PR #13071 (merged 382dc9bd4283) — laptop-agent.py and laptop-agent-broker.py now resolve the seat's recorded fleet-proxy.env ahead of the ambient HTTPS_PROXY for tailnet CONNECTs, mirroring the Rust rule from #12645. With both broker implementations self-correcting at CONNECT time, the external ensure watchdog named in the workaround section is a redundancy question for the primary seat rather than a correctness gap. Full record: #12426 (comment)

  4. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Agent note — Lane LJ: closing #12555 as completed on the two-PR evidence chain.

    This issue's defect — an auto-spawned broker inheriting the caller's ambient proxy env and silently breaking tailnet tunnels — is removed at both points where the inherited env could steer a tunnel:

    1. PR fleet: tailnet tunnels use the seat's recorded tailnet proxy (#12555) #12645 (merged 2026-11-22): tailnet tunnel construction (egress_from_env in fleet-proxy/src/tunnel.rs) prefers the seat's recorded tailnet proxy (fleet_config::tailnet_https_proxy(), reading fleet-proxy.env) over the ambient HTTPS_PROXY; bootstrap removes a stale env file in kernel mode.
    2. PR #13080 (merged just now, 647dd8013cda, for fleet proxy serve inherits the sandbox egress HTTPS_PROXY in userspace mode; queue/shell legs fail until it is restarted with tailscaled's CONNECT proxy #12426): the broker no longer caches that resolution from startup — both tailnet opens re-resolve per tunnel open (Broker::tailnet_egress / resolve_tailnet_egress, three oracle tests; cargo test -p fleet-proxy 113/113 + 14/14, re-verified after rebase). This covers the startup-cache half fleet: tailnet tunnels use the seat's recorded tailnet proxy (#12555) #12645 left: a broker born while tailscaled was down no longer keeps the wrong value after the tailnet recovers.

    With both landed, a broker's /proc environment no longer determines its tailnet routing at any point in its life, so the external fleet-proxy-ensure.sh watchdog described above is policing an invariant the binary now keeps itself; retiring that watchdog is a seat-keeping call, not a code remainder here. The Cloudflare leg intentionally still rides the ambient platform egress (its correct source).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions