Skip to content

fleet-search(client): home_dir() falls back to a literal "~" when HOME is unset (and to the CWD when HOME is empty) — a planted ./~/.config/atlas-search/client.json token is loaded and submitted, and a planted service.json marker flips seat routing to standalone #5918

Closed

Description

@dezren39

fleet-search(client): home_dir() falls back to a literal "" when HOME is unset (and to the CWD when HOME is empty) — a planted .//.config/atlas-search/client.json token is loaded and submitted, and a planted service.json marker flips seat routing to standalone

Evidence

pkgs/fleet/crates/fleet-search/src/client.rs:53-57 (laptop primary @ 102bfa6):

fn home_dir() -> PathBuf {
    std::env::var_os("HOME")
        .map(PathBuf::from)
        .unwrap_or_else(|| PathBuf::from("~"))
}

PathBuf::from("~") is a relative path — nothing expands a tilde — and an empty HOME maps to PathBuf::from(""), whose joins are plain CWD-relative. Every consumer of home_dir() therefore resolves under the process's current working directory when HOME is unset or empty:

  • client_token() — client.rs:84-87: reads the bearer token from ~/.config/atlas-search/client.json (unset) or .config/atlas-search/client.json (empty).
  • serving_host_marker() — client.rs:65-69, used by resolve_route (src/lib.rs:323): existence of ~/.local/state/atlas-search/service.json is the seat signal that routes searches standalone instead of via-service.
  • ensure_sandbox_forward() — client.rs:163: probes ~/tools/laptop-ssh.sh under the same bogus root.

Verified this run on the laptop with the installed fleet binary (behaviour matches the code above; scratch dirs under /tmp/probe-search-home/):

  • HOME unset, clean CWD: fleet search probequery --via-service → no service client token (set ATLAS_SEARCH_TOKEN or create ~/.config/atlas-search/client.json) — the error names a literal-~ relative path.
  • HOME unset, planted ./~/.config/atlas-search/client.json containing {"token": "PROBE-PLANTED-TOKEN"}: the token was loaded and submitted to the live service — service at http://127.0.0.1:18760 rejected the job submit: HTTP 401 (unauthorized: invalid client token). A file planted in the working directory became the client's bearer credential.
  • HOME empty (HOME=), clean CWD: the token error names .config/atlas-search/client.json (plain CWD-relative); with that file planted (PROBE-PLANTED-TOKEN2) it was likewise loaded and submitted (401 from the service).
  • HOME unset, planted ./~/.local/state/atlas-search/service.json, no routing flag: the search went straight to standalone (no via-service token attempt at all), while the identical run in a clean CWD (control) attempted via-service first. A planted empty file flips the Q3 seat routing.

Why it matters

fleet search is run from arbitrary working directories (agent sessions, scripts, shells inside checked-out repos). When HOME is unset or empty — cron/systemd-style environments, env -i, scrubbed agent shells — whoever controls the CWD controls (a) which bearer token the client presents to the search service: a planted token is a credential-substitution / confused-deputy path, and a planted valid token file (e.g. dropped into a shared checkout) would be silently used; and (b) the seat routing, via a zero-byte marker file. The sibling fallbacks were already ruled wrong in this codebase — fleet-config's "." fallback (#5737, open) and fleet-queue's empty-string home() (#5673, open) — but fleet-search's literal-"~" variant is a third, distinct mechanism in a third crate, and it is the only one whose fallback file is a credential that gets transmitted.

Acceptance criteria

Related

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    on Nov 5, 2026
  2. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  3. added
    queue/queuedHas a queued task in the Supabase agent queue
    app/fleetpkgs/fleet multicall binary + platform crates
    on Nov 5, 2026
  4. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: filed

  5. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 5, 2026
  6. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: done

  7. added and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 5, 2026
  8. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  9. added
    queue/queuedHas a queued task in the Supabase agent queue
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 5, 2026
  10. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/fleetpkgs/fleet multicall binary + platform crateskind/bugSomething isn't working (prefixed form of the classic bug label)meta/duplicateDuplicate of another issuepriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus/duplicateAlready tracked elsewherestatus:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions