fix(fermata): a shell behind a wrapper and a verb given by path are read; the forms that stay text are named

The bash/sh/zsh/eval unwrap reads the word after the prefix walk, so sudo, env,
timeout, nohup, exec, xargs, busybox and X=1 in front of a shell no longer hide
its command line. A prefix counts by its file name, as a verb already did, so
/bin/bash -c, /usr/bin/env cat and /usr/bin/timeout 5 cat are read.

Named as limits, each with a test in known_limits.rs: dash -c, ksh -c,
bash -c -- x, eval past its first argument, sudo -u root bash -c, and on the read
gate eval cat id_rsa and cat <&3 id_rsa. (re-check I-3, I-4 leftover, I-5's stale line)
This commit is contained in:
2026-11-07 02:11:10 +01:00
parent bfe83165a7
commit 34298c5f9a
6 changed files with 97 additions and 23 deletions
+40
View File
@@ -282,3 +282,43 @@ fn a_command_line_given_to_a_shell_or_eval_is_read() {
assert_eq!(bash(p.path(), command), json!({}), "{command}");
}
}
/// The same behind a wrapper or an assignment, and a shell, a wrapper or a verb given by
/// its path: what counts is the word the prefix walk stops at, by its file name.
#[test]
fn a_shell_behind_a_wrapper_and_a_verb_given_by_path_are_read() {
let p = project(&[(".botignore", ".env\n"), (".env", ENV), ("id_rsa", PEM)]);
for command in [
"sudo bash -c 'cat .env'",
"env bash -c 'cat .env'",
"/usr/bin/env bash -c 'cat .env'",
"/bin/bash -c 'cat .env'",
"timeout 5 bash -c 'cat .env'",
"nohup sh -c 'cat .env'",
"exec sh -c 'cat .env'",
"xargs sh -c 'cat .env'",
"busybox sh -c 'cat .env'",
"X=1 bash -c 'cat .env'",
"env X=1 bash -c 'cat .env'",
"command eval 'cat .env'",
// The read gate, with no rule on the name.
"sudo bash -c 'cat id_rsa'",
"/bin/bash -c 'cat id_rsa'",
"X=1 bash -c 'cat id_rsa'",
"/bin/cat id_rsa",
"/usr/bin/env cat id_rsa",
"/usr/bin/sudo cat id_rsa",
"/usr/bin/timeout 5 cat id_rsa",
] {
assert_eq!(verdict(&bash(p.path(), command)), "deny", "{command}");
}
for command in [
"sudo bash -c 'ls .env'",
"/bin/bash -c 'echo .env'",
"X=1 bash -c 'echo hello'",
"/usr/bin/env ls id_rsa",
"/usr/bin/timeout 5 ls id_rsa",
] {
assert_eq!(bash(p.path(), command), json!({}), "{command}");
}
}