Skip to content

fix(auto-reply): resolve scp from path for media staging#79202

Merged
steipete merged 1 commit into
mainfrom
fix/sandbox-media-scp-path
May 8, 2026
Merged

fix(auto-reply): resolve scp from path for media staging#79202
steipete merged 1 commit into
mainfrom
fix/sandbox-media-scp-path

Conversation

@steipete

@steipete steipete commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Problem: sandbox media staging hardcoded /usr/bin/scp.
  • Why it matters: installs where OpenSSH is elsewhere on PATH could fail media copy even though scp is available.
  • What changed: staging now spawns scp by command name so the runtime PATH decides.
  • What did NOT change: the existing batch mode, timeout, and remote path arguments stay the same.

Verification

  • git diff --check origin/main..HEAD
  • pnpm test src/auto-reply/reply.stage-sandbox-media.scp-remote-path.test.ts — 2 passed
  • command -v scp/usr/bin/scp in the live local environment

Real behavior proof

  • Behavior or issue addressed: sandbox media staging now resolves scp from PATH instead of hardcoding /usr/bin/scp.
  • Real environment tested: local macOS checkout with system OpenSSH available on PATH.
  • Exact steps or command run after this patch: command -v scp
  • Evidence after fix: terminal output: /usr/bin/scp
  • Observed result after fix: the live environment resolves scp by command name, and the regression test verifies the production spawn call uses scp.
  • What was not tested: a remote SSH host copy, because the bug is command resolution before SSH connection setup.

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? Yes — uses PATH resolution for the same scp command.
  • Data access scope changed? No

Risks and Mitigations

  • Risk: PATH could prefer a different scp binary.
    • Mitigation: this matches normal shell/runtime command resolution and preserves all existing scp arguments.

Linked Issue

Closes #79242

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels May 8, 2026
@clawsweeper

clawsweeper Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR changes remote sandbox media staging to spawn scp via PATH, adds a regression assertion, and adds a changelog fix entry.

Reproducibility: yes. The current-main source unconditionally spawns /usr/bin/scp, so a host with scp available elsewhere on PATH but not at /usr/bin/scp has a clear failing path before SSH connection setup; I did not live-reproduce that exact host layout because this runner has /usr/bin/scp.

Real behavior proof
Not applicable: The PR is protected with the maintainer label, so the external-contributor real-behavior proof gate is not applied here; the body still lists targeted test and command -v scp output.

Next step before merge
Protected maintainer label and no concrete repair finding; maintainer review should decide whether to accept PATH-based scp lookup and then merge through normal checks.

Security
Cleared: The diff changes executable resolution to PATH but does not add a shell, widen remote host/path inputs, change secrets handling, or introduce new dependencies.

Review details

Best possible solution:

Land the narrow PATH-resolution change with the existing validation, regression assertion, and changelog if maintainers accept process PATH as the intended scp lookup contract.

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

Yes. The current-main source unconditionally spawns /usr/bin/scp, so a host with scp available elsewhere on PATH but not at /usr/bin/scp has a clear failing path before SSH connection setup; I did not live-reproduce that exact host layout because this runner has /usr/bin/scp.

Is this the best way to solve the issue?

Yes. Spawning scp by command name while preserving spawn without a shell, the existing arguments, and host/path validation is the narrowest fix for PATH-based OpenSSH installs; a new config option would be heavier than the reported portability bug requires.

What I checked:

  • Current main hardcodes scp path: Current main calls spawn("/usr/bin/scp", ...) in the remote media staging helper, so installs with scp elsewhere on PATH remain affected on main. (src/auto-reply/reply/stage-sandbox-media.ts:321, df069f7b0222)
  • Remote staging path is scoped: Remote media staging only reaches scpFile after MediaRemoteHost is present and the source path passes the channel remote attachment root check. (src/auto-reply/reply/stage-sandbox-media.ts:94, df069f7b0222)
  • Argument validation remains in place: normalizeScpRemoteHost rejects whitespace/options and normalizeScpRemotePath rejects shell metacharacters/control characters before spawning scp. (src/infra/scp-host.ts:18, df069f7b0222)
  • Documented behavior uses SCP for remote attachments: The iMessage docs say remote attachment paths can be fetched via SCP when remoteHost is set and that strict host-key checking is used. Public docs: docs/channels/imessage.md. (docs/channels/imessage.md:406, df069f7b0222)
  • PATH resolution behavior checked: A local Node spawnSync("scp", ...) check spawned when PATH included /usr/bin:/bin and returned ENOENT when PATH was set to a nonexistent directory, confirming the proposed command-name lookup depends on PATH.
  • PR diff scope: The provided PR diff changes only the scp executable string, adds an assertion that the spawned program is scp, and adds a changelog line. (src/auto-reply/reply/stage-sandbox-media.ts:321, 56c2e20b6fdb)

Likely related people:

  • amknight: Local blame attributes the current stageSandboxMedia helper and scpFile implementation, including the hardcoded /usr/bin/scp call, to this current-main history. (role: current-main line owner; confidence: medium; commits: 6a8b4e422e82; files: src/auto-reply/reply/stage-sandbox-media.ts, src/auto-reply/reply.stage-sandbox-media.scp-remote-path.test.ts)
  • Omar Shahine: Recent current-main commits touched the iMessage surface that provides remoteHost and remote attachment roots feeding this staging path. (role: recent adjacent owner; confidence: medium; commits: df069f7b0222, e259751ec9c9; files: extensions/imessage/src/monitor/monitor-provider.ts, extensions/imessage/src/media-contract.ts, docs/channels/imessage.md)
  • steipete: Besides proposing this PR, local history shows recent current-main commits by Peter Steinberger in nearby auto-reply/plugin runtime helper areas, making him a plausible maintainer route for this small behavior change. (role: adjacent maintainer and PR proposer; confidence: medium; commits: 6a4069dead0f, 830a72d2eeea; files: src/auto-reply, extensions/imessage)

Remaining risk / open question:

  • PATH-based lookup intentionally executes whichever scp the OpenClaw service environment resolves; this is a maintainable portability tradeoff but should be accepted explicitly by the maintainer handling the PR.

Codex review notes: model gpt-5.5, reasoning high; reviewed against df069f7b0222.

@steipete
steipete force-pushed the fix/sandbox-media-scp-path branch 3 times, most recently from 948fe23 to e51d6c5 Compare May 8, 2026 05:10
@steipete
steipete force-pushed the fix/sandbox-media-scp-path branch from e51d6c5 to 02900a2 Compare May 8, 2026 05:15
@steipete
steipete merged commit 41c5990 into main May 8, 2026
110 checks passed
@steipete
steipete deleted the fix/sandbox-media-scp-path branch May 8, 2026 05:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
rogerdigital pushed a commit to rogerdigital/openclaw that referenced this pull request May 9, 2026
lykeion-dev pushed a commit to lykeion-dev/openclaw--rev that referenced this pull request May 14, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandbox media staging hardcodes /usr/bin/scp

1 participant