Skip to content

[1/9] Harden code-execution command allowlists#62

Open
hi-michael-li wants to merge 3 commits into
mainfrom
michael-li/stirrup-01-command-allowlist
Open

[1/9] Harden code-execution command allowlists#62
hi-michael-li wants to merge 3 commits into
mainfrom
michael-li/stirrup-01-command-allowlist

Conversation

@hi-michael-li

@hi-michael-li hi-michael-li commented Jul 13, 2026

Copy link
Copy Markdown

Why

Command allowlists could be bypassed through shell chaining, substitutions, redirections, assignments, and quoted executable text. A command that looked allowed could therefore execute an unapproved program.

What

  • Scan shell words with quote-aware handling, including ANSI-C quoting.
  • Reject control operators, active expansion, redirection, and leading assignments.
  • Validate the executable at the command boundary before execution.

Testing

  • Focused command-allowlist coverage: 38 passed, 1 skipped.
  • Final stack: 419 passed, 2 skipped.
  • Ruff, format, type checks, strict docs, and package build pass.

Stack

Part 1 of 9. Next: #63.

@hi-michael-li hi-michael-li force-pushed the michael-li/stirrup-01-command-allowlist branch from 183e5cd to 302c59a Compare July 14, 2026 06:27
@hi-michael-li hi-michael-li force-pushed the michael-li/stirrup-01-command-allowlist branch from 302c59a to f7ca694 Compare July 14, 2026 13:24
@hi-michael-li hi-michael-li marked this pull request as ready for review July 15, 2026 04:41
hi-michael-li and others added 2 commits July 15, 2026 15:01
- Reject subshells `( )` and command-prefixing keywords (time/coproc/!)
  so a permissive pattern cannot smuggle a different command
- Fail closed on unterminated quotes rather than relying on Bash
- Return a typed rejection reason with reason-specific advice and a
  debug log, replacing the always-"no pattern match" message; share the
  result builder across the local/docker/e2b backends
- Expand docstrings and the code-execution guide (arithmetic expansion,
  double-quote expansions, start-anchoring, .search->.match migration)
- Add tests for process substitution, `+=`, subshell/keyword prefixes,
  unterminated quotes, anchoring, and reason-specific advice

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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