Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion codex-rs/core/src/command_safety/is_safe_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,35 @@ fn is_safe_to_call_with_exec(command: &[String]) -> bool {
{
#[rustfmt::skip]
Some(
"base64" |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to specify an output file for base64 with the -o flag. Would lead to an unintended write, assuming safe commands are supposed to be read-only

e.g. base64 -d -o /tmp/x payload bypasses approval even though it mutates the filesystem

BSD docs: https://ss64.com/mac/base64.html

"cat" |
"cd" |
"cut" |
"echo" |
"env" |
"expr" |
"false" |
"grep" |
"head" |
"id" |
"ls" |
"nl" |
"numfmt" |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this Linux only? I don't see this on my Mac.

"paste" |
"pwd" |
"rev" |
"seq" |
"stat" |
"tac" |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not on Mac.

For the ones that are not natively in [root-owned] /usr/bin on macOS, let's only add them to the list for Linux.

Admittedly, on both Mac or Linux, someone could inject their own version of stat into the $PATH, but the case where it's shadowing something on $PATH is more sus than when it doesn't exist on the $PATH in the first place (e.g., tac).

"tail" |
"tr" |
"true" |
"uname" |
"uniq" |
"wc" |
"which") => {
"which" |
"whoami" |
"yes") => {
true
},

Expand Down
Loading