← Back to PRs

#21733: security(exec): platform-aware allowlist matching and restricted safe-bin trust

by Esubaalew open 2026-02-20 09:07 View on GitHub →
docs size: S
## Summary - Allowlist glob matching follows host filesystem case semantics: case-insensitive on Windows and macOS (where the default filesystem is case-insensitive), case-sensitive on Linux (ext4/btrfs/etc. are case-sensitive). Previously it was always case-insensitive on all platforms, which meant a differently-cased path could bypass an allowlist entry on Linux. - Safe-bin trusted directories now default to hardcoded system paths only (/bin, /usr/bin, /usr/local/bin, /opt/homebrew/bin, /opt/local/bin, /snap/bin, /run/current-system/sw/bin). PATH entries are no longer implicitly trusted. Callers can opt in with `includePathEnv: true` if needed. This prevents a manipulated PATH from getting arbitrary binaries auto-approved as safe bins. ## Test plan - [x] Existing allowlist matching tests pass (72 tests) - [x] New test: mismatched-case pattern rejected on Linux, accepted on Windows/macOS - [x] Existing safe-bin trust tests updated for new default (5 tests) - [x] New test: PATH entries excluded by default, included only with opt-in - [ ] Verify on Linux that a differently-cased allowlist pattern correctly fails to match <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR implements two critical security improvements to exec approval logic: **Platform-aware allowlist matching**: Allowlist glob patterns now follow filesystem case semantics - case-insensitive on Windows/macOS (matching their default case-insensitive filesystems) and case-sensitive on Linux (matching ext4/btrfs behavior). This prevents attackers from bypassing allowlist entries on Linux by using differently-cased paths. **Restricted safe-bin trust**: Safe-bin trusted directories now default to hardcoded system paths only (`/bin`, `/usr/bin`, `/usr/local/bin`, `/opt/homebrew/bin`, `/opt/local/bin`, `/snap/bin`, `/run/current-system/sw/bin`). PATH entries are excluded by default to prevent PATH manipulation attacks. Callers can opt in with `includePathEnv: true` when needed. Both changes close real security vulnerabilities: - The case-sensitivity issue allowed bypass on Linux systems - The PATH trust issue allowed attackers to manipulate PATH to get arbitrary binaries approved as safe bins Test coverage includes platform-conditional tests for case sensitivity and explicit tests for the new PATH exclusion behavior. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with high confidence - it strengthens security without breaking functionality - This PR fixes legitimate security vulnerabilities with careful implementation. The changes are well-tested (73+ tests pass), backward-compatible (existing functionality preserved via opt-in flag), and focused on hardening security. The case-sensitivity fix prevents allowlist bypass on Linux, and the PATH restriction prevents manipulation attacks. All test updates properly reflect the new secure-by-default behavior. - No files require special attention <sub>Last reviewed commit: 5799945</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs