-
Notifications
You must be signed in to change notification settings - Fork 6.9k
fix: deny bash commands with arguments when command name matches rule #9257
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
base: dev
Are you sure you want to change the base?
fix: deny bash commands with arguments when command name matches rule #9257
Conversation
…ile.list Resolves a critical vulnerability where symlinks could be used to access files outside the project directory. Implemented `fs.promises.realpath` validation to ensure the actual target path is within the allowed scope. Added regression test in `packages/opencode/test/security/symlink.test.ts`.
…ile.list Resolves a critical vulnerability where symlinks could be used to access files outside the project directory. Implemented `fs.promises.realpath` validation to ensure the actual target path is within the allowed scope. Added regression test in `packages/opencode/test/security/symlink.test.ts`. Fixes anomalyco#101
fix(security): prevent path traversal via symlinks
…lyco#4997) - Fix Ctrl+C behavior on Windows: copies selection if present, otherwise clears/exits. - Resolve Ctrl+A conflict: move `model_provider_list` to `ctrl+alt+m`. - Fix Navigation: map `ctrl+n`/`ctrl+p` to move down/up and history next/prev. - Fix Multiline: ensure `shift+return` is mapped to newline. - Fix Word Navigation: ensure `ctrl+left`/`ctrl+right` are mapped. - Fix Word Deletion: ensure `alt+d` and `option+delete` are mapped.
fix(tui): resolve keybind conflicts and missing defaults
Fixes anomalyco#7063 When evaluating bash permissions, the system now checks both: 1. The full command pattern (e.g., 'yarn test') 2. The command name (first word, e.g., 'yarn') This ensures that when a user configures 'yarn: deny', commands like 'yarn test', 'yarn install', etc. are correctly denied, not just the exact 'yarn' command. The fix modifies the evaluate() function to extract the first word of bash commands and check if it matches any deny rules, preventing permission bypass via command arguments.
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: Related PR FoundPR #6737: "fix: handle redirected_statement treesitter node in bash permissions"
All other results either returned the current PR #9257 itself or unrelated PRs about GitHub actions and other features. The searches did not uncover any other open PRs specifically addressing the issue where denied bash commands with arguments are being incorrectly executed, so this appears to be the first comprehensive fix for issue #7063. |
Summary
Fixes #7063 - Permission system allows explicitly denied bash commands to execute
Problem
Commands configured with 'deny' in opencode.json permissions were being executed anyway. Specifically, package managers (yarn, npm, pnpm, npx, pnpx) ran despite being explicitly denied.
Root Cause: When a user configures
"yarn": "deny", this creates a rule with pattern"yarn". However, the bash tool sends patterns like"yarn test"or"yarn install", which don't match the exact pattern"yarn"viaWildcard.match().Solution
Modified the
evaluate()function inpackages/opencode/src/permission/next.tsto add special handling for bash permissions:This ensures that when a user configures
yarn: deny, commands likeyarn test,yarn install, etc. are correctly denied.Changes
packages/opencode/src/permission/next.ts: Added bash-specific command name matching inevaluate()packages/opencode/test/permission/next.test.ts: Added 10 new tests for bash command name matchingTesting
All 92 permission tests pass, including 10 new tests specifically for this fix:
yarn testwithyarn: deny→ now correctly deniesnpm installwithnpm: deny→ now correctly deniespnpm run buildwithpnpm: deny→ now correctly deniesnpx create-react-appwithnpx: deny→ now correctly deniesExample Configuration That Now Works
{ "permissions": { "bash": { "yarn": "deny", "npm": "deny" } } }With this fix,
yarn test,yarn install,npm run build, etc. will all be correctly denied.