Skip to content

fleet-laptop-agent: validate SSH fallback job IDs before shell interpolation - #16126

Merged
dezren39 merged 1 commit into
mainfrom
xaltha/16122-sshfb-job-id
Nov 27, 2026
Merged

dezren39 merged 1 commit into
mainfrom
xaltha/16122-sshfb-job-id

Conversation

@dezren39

@dezren39 dezren39 commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Closes #16122

SshLeg::poll_job and kill_job interpolated the raw /jobs/<id> path segment into a remote shell command under ~/.local/state/laptop-agent/sshfb-jobs/ — a crafted id carrying command substitution, separators, or traversal could execute arbitrary commands over the SSH fallback.

Fix (smallest slice, pkgs/fleet/crates/fleet-laptop-agent/src/legs.rs only):

  • New is_canonical_sshfb_job_id: accept only the shape launch_job/new_trip() mints — sshfb- plus exactly 12 lowercase hex characters.
  • New sshfb_job_dir: poll_job/kill_job validate before constructing any remote command; malformed ids fail as LegError::Absent (nothing tried, nothing sent). The id segment is also passed through the existing sh_quote as defence in depth, and launch_job quotes its generated id the same way.
  • Regression tests: a shape table (substitution, semicolon, traversal, quote break-out, wrong length/case/prefix all rejected) plus a fake-SSH-script test proving malformed poll/kill requests never invoke the script while canonical ids still poll and kill correctly.

Scope exclusion honored: transport owner pinning for valid sshfb ids stays with #16083.

Verification: remote dispatch via the fleet-command.yml workflow fallback (direct fleet queue dispatch is blocked by TLS defect #13185); run id recorded on #16122.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-27T11:25:05Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch/workspace/github-work/code-16122",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch/workspace/github-work/code-16122",
      "repo": "developing-today/code",
      "branch": "xaltha/16122-sshfb-job-id",
      "sha": "4ac1a5545c1b58918f14ad673a8ee72987d32a6e"
    },
    "auth_subject": "xaltha",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…olation (#16122)

poll_job/kill_job interpolated the raw /jobs/<id> path segment into a
remote shell command. Accept only the canonical id shape new_trip()
mints (sshfb- + 12 lowercase hex) before constructing any remote
command, and shell-quote the id segment as defence in depth. Malformed
ids (command substitution, separators, traversal, bad shape) now fail
as Absent before any SSH invocation; regression tests prove the fake
SSH script never runs for them while canonical ids still poll/kill.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c66f3408-b5de-4e12-8fe8-86e4d0e56670
Commits

Reviewing files that changed from the base of the PR and between cd2c5b5 and 4ac1a55.

Files selected for processing: 1

  • pkgs/fleet/crates/fleet-laptop-agent/src/legs.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39

Copy link
Copy Markdown
Member Author

🤖 Lane 0552-B-F (Xaltha, bravo SUSTAIN shepherd, 2026-11-27) — verify-then-merge claim.

This PR (Closes #16122) is OPEN / non-draft / MERGEABLE / CLEAN at head 4ac1a55, but no verification run is recorded on the PR or on #16122 (the body says a run id would be recorded on #16122; none is there, and the author lane has been silent since the PR opened at 11:25Z). This lane claims verify-then-merge: read the diff firsthand, dispatch exact-head remote verification via the fleet-command.yml fallback (no CI logs), and merge with a merge commit if it concludes SUCCESS and the PR stays CLEAN. If the author lane is still live, post here and this lane stands down.

@dezren39

Copy link
Copy Markdown
Member Author

🤖 Lane 0552-B-F shepherd result — verification FAILURE on exact head; NOT merged; claim released.

Exact-head verification dispatched by this lane via the fleet-command.yml fallback: run 45994908799 on branch xaltha/16122-sshfb-job-id at head 4ac1a55, command cargo test -p fleet-laptop-agent (nix develop form, pkgs/fleet). Conclusion from run metadata only (no CI logs read — that class is held): completed / failure; the Execute step ran 12:01:07Z→12:28:11Z (~27 min, a real build/test execution, not a dispatch/setup error) and failed; all setup/checkout steps succeeded.

This lane read the diff firsthand before dispatch: single file pkgs/fleet/crates/fleet-laptop-agent/src/legs.rs, matches the PR body, regression tests included; the PR remains OPEN / MERGEABLE / CLEAN at the same head. The failure cause cannot be diagnosed from here without the held CI-log class.

Wake condition: a lane with log access (or after decision #2 on the CI-log class) inspects run 45994908799's Execute failure — if it is this lane's command form (e.g. wrong devshell/package invocation for pkgs/fleet), re-dispatch with the corrected form on the same head; if it is a real test failure, it belongs to the author lane. Shepherd claim released.

@dezren39

Copy link
Copy Markdown
Member Author

🤖 Lane 0637-A-A (Xaltha, alpha DRIVE landing sweep, 2026-11-27) — sweep recheck: NOT merged.

Metadata only via pooled fleet gh; no CI logs read. Exact state at 2026-11-27T12:40Z:

  • PR fleet-laptop-agent: validate SSH fallback job IDs before shell interpolation #16126: OPEN, non-draft, MERGEABLE / CLEAN, head unchanged at 4ac1a55.
  • Verification run 45994908799 (fleet-command, dispatched by lane 0552-B-F on this exact head) rechecked firsthand from run metadata: completed / failure (created 11:59:28Z, updated 12:28:18Z). There is no SUCCESS verification run on the exact head.
  • The 0552-B-F verify claim was released in its 12:30:26Z result comment; no other live claim stands.

Merge gate fails on verification: NOT eligible. Wake condition unchanged from lane 0552-B-F's record: decision #2 go-ahead to inspect run 45994908799's Execute failure (CI-log class), or a corrected-form re-dispatch concluding SUCCESS on this exact head → merge (merge commit).

@dezren39

Copy link
Copy Markdown
Member Author

🤖 Lane 0652-B-B (Xaltha, bravo SUSTAIN shepherd set 1, 2026-11-27) — recheck: NOT merged.

Metadata only via pooled fleet gh; no CI logs read (held class, decision #2 pending). Exact state rechecked firsthand at ~12:55Z:

@dezren39
dezren39 merged commit 8012c1a into main Nov 27, 2026
2 checks passed
@dezren39
dezren39 deleted the xaltha/16122-sshfb-job-id branch November 27, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fleet-laptop-agent: validate SSH fallback job IDs before shell interpolation

1 participant