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:
@@ -344,8 +344,10 @@ test [ du which echo printf`, `git status`, `git commit`, ...) meets nothing; ev
|
||||
verb (`source`, `cp`, `rm`, `python`) meets the rules but not the read gate. Only
|
||||
a word that names an existing file, an existing path with a separator, a path with `$`,
|
||||
`*` or `?` in it, or a redirect's target counts; `$(...)`, scripts and a verb off the
|
||||
list that opens the file itself are not seen. The argument of `bash -c` and `eval` is
|
||||
read as a command line. `[policy.write]` is not applied to commands. The forms that
|
||||
list that opens the file itself are not seen. The argument of `bash|sh|zsh -c` and the
|
||||
first argument of `eval` are read as a command line, also behind a wrapper (`sudo bash -c`,
|
||||
`X=1 bash -c`) or given by path (`/bin/bash -c`); another shell (`dash -c`) is not.
|
||||
`[policy.write]` is not applied to commands. The forms that
|
||||
pass, and the harmless commands a rule stops, are in
|
||||
[Layer 3](security-model.md#layer-3-access-control-botignore--botsecrets-policy).
|
||||
|
||||
|
||||
@@ -57,11 +57,12 @@ Reading `.env` is allowed by default, and only Layer 1 stands between its values
|
||||
|
||||
- A substitution that builds the file name (`cat $(printf '.e%s' nv)`), and `echo "$(cat .env)"`: a substitution inside double quotes is one word.
|
||||
- A script that opens the file (`sh run.sh`, `python -c "print(open('.env').read())"`), a heredoc fed to a shell (`bash <<EOF` with `cat .env` in its body), and a printing verb that is not on the list (`dd`, `perl`, `python -c`).
|
||||
- A shell other than `bash`, `sh` and `zsh` (`dash -c 'cat .env'`, `ksh -c`), `bash -c -- 'cat .env'`, `eval` past its first argument (`eval 'true' 'cat .env'`), and a shell behind a wrapper's flag value (`sudo -u root bash -c 'cat .env'`). `sudo bash -c`, `X=1 bash -c`, `timeout 5 bash -c` and `/bin/bash -c` are read.
|
||||
- `find . -name .env -exec cat {} \;`, `curl -d @.env`, `curl -F file=@.env`, `git show HEAD:.env`, `git show :.env` and `cat .{env,x}`: the name is not a word of its own.
|
||||
- `cd ../other && cat .env`, and a command run in one project under another project's rules. A secret file outside every project has no rules at all.
|
||||
- A file a command is about to make (`cp a.txt vendor/new`, `touch vendor/new`) is not there to check. A redirect's target is.
|
||||
|
||||
The read gate also misses `sudo -u root cat id_rsa`, where the flag's value `root` becomes the verb, and `cat */id_rsa` and `cat ./s*/a.key`, a glob over directories, which is no file. A rule on the name still reads the first two.
|
||||
The read gate also misses `sudo -u root cat id_rsa`, where the flag's value `root` becomes the verb; `eval cat id_rsa`, where only the first argument is read as a command line; `cat <&3 id_rsa`, where `<&` ends the segment; and `cat */id_rsa` and `cat ./s*/a.key`, a glob over directories, which is no file. A rule on the file's name still stops each of them.
|
||||
|
||||
**Harmless commands it stops.** Under a rule on `.env`: `grep -A 2 .env a.txt`, `grep -m 1 .env a.txt` and `rg -t py .env`, where a flag's value takes the pattern's place; `grep -r TOKEN --exclude=.env .`, `tar --exclude=.env -cf x.tar .`, `rsync --exclude=.env a b` and `npm test -- --grep=.env`, where the text after `=` counts as a path; and `git --no-pager status .env`, where a flag before `status` loses the metadata class.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user