Skip to content

fix(permissions): withhold Crush safe commands shadowed by executable-path denies - #3867

Merged
dyoshikawa merged 2 commits into
dyoshikawa:mainfrom
jdotc1:fix/crush-safe-command-path-denies-20261117
Nov 18, 2026
Merged

dyoshikawa merged 2 commits into
dyoshikawa:mainfrom
jdotc1:fix/crush-safe-command-path-denies-20261117

Conversation

@jdotc1

@jdotc1 jdotc1 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Addresses #3822 item 9 (Crush safe-command normalization). Other cases in the umbrella issue remain open.

Security fix

Crush normalizes executable names by removing their directory and lowercasing before comparing safe_commands. As a result, a canonical go build allow could previously survive an explicit /usr/bin/go build deny, potentially auto-approving the denied command. Compare the literal safe command as well as wrapper spellings against restrictions normalized by Crush's own command-name rules, and withhold the unsafe allow.

The change only withholds additional auto-allows; it never grants permissions. An unrelated cargo test allow remains intact.

Verification

  • Regression-first: the new denied-executable-path case failed before the fix and passed afterward.
  • pnpm exec vp test run src/features/permissions --silent=true — 2,870 passed across 59 files.
  • pnpm run typecheck — passed.
  • vp fmt --check and vp lint --max-warnings 0 on the changed files — passed.
  • No dependencies or config changes.

Copilot AI lite review requested due to automatic review settings November 17, 2026 13:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

An active moderate finding remains because lowercasing the entire safe-command line makes case-sensitive arguments affect permission matching incorrectly.

1 open issue
What changed in this PR

This pull request hardens Crush permission generation so executable-path restrictions correctly withhold equivalent safe-command allows, preventing denied commands from being auto-approved.

Changes:

  • Compares literal and wrapper safe-command spellings against Crush-normalized restrictions.
  • Adds regression coverage for /usr/bin/go build denying go build while preserving unrelated commands such as cargo test.
File Description
src/​features/​permissions/​crush-permissions.ts Extends safe-command shadow detection to compare literal and wrapper command spellings against normalized restrictions.
src/​features/​permissions/​crush-permissions.test.ts Adds regression coverage for executable-path denies withholding the corresponding safe command while preserving unrelated safe commands.

Review effort: Lite

uniq([
...withSeparator([line, ...wrapped(line)]).flatMap((spelling) => test(spelling)),
...withSeparator(wrapped(line.toLowerCase())).flatMap((spelling) =>
...withSeparator([line.toLowerCase(), ...wrapped(line.toLowerCase())]).flatMap((spelling) =>
@dyoshikawa
dyoshikawa merged commit 5e8b7b7 into dyoshikawa:main Nov 18, 2026
7 checks passed
@dyoshikawa

Copy link
Copy Markdown
Owner

@jdotc1 Thank you!

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.

3 participants