Skip to content

Conversation

@Ashwinhegde19
Copy link

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" via Wildcard.match().

Solution

Modified the evaluate() function in packages/opencode/src/permission/next.ts to add special handling for bash permissions:

  1. First checks if the full command pattern matches any rule (existing behavior)
  2. For bash permissions only: also extracts the command name (first word) and checks if it matches any rule

This ensures that when a user configures yarn: deny, commands like yarn test, yarn install, etc. are correctly denied.

Changes

  • packages/opencode/src/permission/next.ts: Added bash-specific command name matching in evaluate()
  • packages/opencode/test/permission/next.test.ts: Added 10 new tests for bash command name matching

Testing

All 92 permission tests pass, including 10 new tests specifically for this fix:

  • yarn test with yarn: deny → now correctly denies
  • npm install with npm: deny → now correctly denies
  • pnpm run build with pnpm: deny → now correctly denies
  • npx create-react-app with npx: deny → now correctly denies
  • Existing wildcard behavior preserved
  • Non-bash permissions unaffected

Example 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.

google-labs-jules bot and others added 12 commits January 15, 2026 18:49
…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.
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

Related PR Found

PR #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.

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.

Permission denied, yet command is executed regardless

1 participant