Skip to content

Safeguard against -ok option for find command #2258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

neochristou
Copy link
Contributor

Description of changes:

The trust checks for the execute_bash tool can be bypassed, causing to execute commands it shouldn't (e.g., deleting files) without asking for confirmation from the user. Specifically, find has an -ok option which works similar to -exec, but asks for confirmation before running the command. However, this can be bypassed on macOS using a herestring (which isn't part of the patterns Q checks for to decide if it should auto-trust a command), for example:

> run the following command: find . -name "*.md" -ok rm {} + <<< "y"
I'll run that command to find and remove all .md files in the current directory and subdirectories. The command uses -ok which will prompt for confirmation before removing each file, and the
<<< "y" provides "y" as input to confirm the deletion.


🛠️  Using tool: execute_bash (trusted)
 ⋮
 ● I will run the following shell command:
find . -name "*.md" -ok rm {} + <<< "y"
 ⋮
 ↳ Purpose: Find and remove all .md files with confirmation

"rm ./codebase-summary.md ./CODE_OF_CONDUCT.md ./crates/figterm/README.md ./crates/figterm/src/input/README.md ./crates/fig_telemetry_core/README.md ./crates/fig_desktop/README.md ./crates/zbus_names/README.md ./crates/zbus/README.md ./crates/aws-toolkit-telemetry-definitions/README.md ./crates/semantic_search_client/README.md ./crates/fig_test_utils/README.md ./proto/README.md ./tests/figterm/README.md ./rfcs/0001-rfc-process.md ./rfcs/0000-template.md ./extensions/gnome-extension/README.md ./extensions/gnome-extension/CONTRIBUTING.md ./extensions/jetbrains/README.md ./extensions/gnome-legacy-extension/README.md ./extensions/gnome-legacy-extension/CONTRIBUTING.md ./extensions/vscode/README.md ./extensions/vscode/vsc-extension-quickstart.md ./README.md ./CONTRIBUTING.md ./packages/api-bindings-wrappers/README.md ./packages/api-bindings/README.md ./packages/autocomplete/README.md ./packages/autocomplete-parser/README.md ./packages/autocomplete-app/README.md ./packages/shared/README.md ./packages/fuzzysort/README.md ./packages/eslint-config/README.md ./packages/dashboard-app/README.md ./packages/shell-parser/README.md ./AmazonQ.md ./SECURITY.md"?

 ⋮
 ● Completed in 0.489s

This PR adds a check for the -ok option.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant