ssh: Show approvers the stdin a command runs with
CI / Check (pull_request) Successful in 5m14s
CI / Check (push) Successful in 5m15s

`slop ssh` forwarded stdin only after approval, so a script piped to
`bash -s` reached the box without an approver or the audit log ever
seeing it. `slop` now reads all of stdin (unless it's a terminal)
and sends it with the request. Approvers see it in full, the audit
log keeps it, and the command gets exactly those bytes. Stdin that
isn't UTF-8, or a command and stdin too long to show whole, is
refused.

The command is shown as the line the remote shell runs (the words
joined with spaces, as `ssh` sends them) rather than shell-quoted,
which suggested quoting the remote shell never sees; multi-line
commands are shown as text.

`Operation::Ssh` gains `stdin`, so the protocol version goes to 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #1.
This commit is contained in:
jackos1998andClaude Opus 5.5 committed 2026-11-25 00:51:12 +00:00
1 parent 21c2d4715e
commit 2df7cd3dee
12 files changed
+186 -58

No files matched your search

+10 -1
View File
@@ -101,7 +101,8 @@ and `slop-approve`. How the code does it is in
- The request carries a protocol version, so a mismatched `slop` gets a clear error.
- **One connection per request**, carrying in order:
1. the request;
2. the operation's stdin, only after approval and only for operations that read it;
2. the operation's stdin, only after approval and only for operations that read it (`ssh`
carries its stdin in the request instead, below);
3. its stdout and stderr;
4. a final message with the exit status and any structured result.
@@ -344,6 +345,14 @@ ciphertext they were sent, never values.
accepted, changed ones refused).
- **`slop ssh` always asks.** `ssh` joins its arguments into a string that the remote shell runs,
so a free-form command's text can't be judged as read-only.
- **Approvers see everything that reaches the box.** A script piped to `bash -s` is as much the
command as its arguments, so `slop ssh` sends its whole stdin with the request.
- Approvers see the line the remote shell runs (the words joined with spaces, as `ssh` sends
them) and all of the stdin, and the audit log keeps both.
- The command gets exactly that stdin and nothing more.
- Stdin must be UTF-8 text, and the command and stdin together are limited
([`MAX_SSH_SHOWN`](../src/proto.rs)) so they're always shown whole; anything else is
refused.
- **The queries can be `auto`.** `status`, `logs` and `failed` validate their arguments (unit
names, `--since`, line counts), and the broker builds the quoted remote command. They cover most
of what agents need SSH for without prompting.