Skip to content

fix(security): harden shell command evaluation and fix test isolation#763

Open
pg-adm1n wants to merge 2 commits into
mksglu:nextfrom
pg-adm1n:fix/hardened-command-security
Open

fix(security): harden shell command evaluation and fix test isolation#763
pg-adm1n wants to merge 2 commits into
mksglu:nextfrom
pg-adm1n:fix/hardened-command-security

Conversation

@pg-adm1n
Copy link
Copy Markdown

@pg-adm1n pg-adm1n commented Jun 2, 2026

This PR hardens the context-mode security policy engine to resolve three major logical bypasses in shell command screening:

  1. Command Separator Bypass (Newlines/Ampersands): Multi-line command scripts and backgrounded ampersand executions (which are treated as separate statements by shell) are now correctly split by splitChainedCommands.
  2. Nested Subshell Execution Bypass: Nested commands inside $() and \...`are now recursively extracted viaextractSubshellCommands` and evaluated against the security policy.
  3. Allow-List Piggybacking Bypass: evaluateCommand now enforces segment-wise allow-list checking. Chained command elements must all be explicitly allowed. Unallowed/ask segments can no longer piggyback on an allowed segment prefix.
  4. macOS Case-Insensitivity Default: Darwin platform now defaults to caseInsensitive: true.
  5. Strict integration test isolation: Override codexHome to isolate test execution from developer's real ~/.codex logs.

All 4080 unit and integration tests pass successfully.

- Harden splitChainedCommands to split on newlines and single ampersands
- Implement recursive subshell command extraction for `` and `\`...\``
- Refactor evaluateCommand to validate allowed commands segment-by-segment
- Update caseInsensitive default to true on macOS (darwin)
- Add codexHome isolation override to project-dir-strict integration test
- Rebuild CLI, server, and security bundles with the security fixes
@pg-adm1n pg-adm1n force-pushed the fix/hardened-command-security branch from 222c212 to 7568ae3 Compare June 2, 2026 00:34
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