Skip to content

fix(init): narrow command validation to actual shell injection vectors#697

Merged
betegon merged 2 commits intomainfrom
fix/relax-command-validation
Apr 9, 2026
Merged

fix(init): narrow command validation to actual shell injection vectors#697
betegon merged 2 commits intomainfrom
fix/relax-command-validation

Conversation

@betegon
Copy link
Copy Markdown
Member

@betegon betegon commented Apr 9, 2026

Summary

validateCommand blocked characters like quotes, braces, globs, $, #, parentheses, and backslashes as "defense-in-depth" shell metacharacters. Since commands run via spawn (no shell), these characters are inert — but blocking them prevented legitimate package specifiers the server might send, such as pip install "sentry-sdk[django]" or version ranges containing *.

This narrows the blocklist to patterns that represent actual shell injection: command chaining (;, &&, ||), piping (|), command substitution (`, $(), redirection (>, <), background (&), and control characters (\n, \r). Everything else is removed since spawn doesn't interpret it.

Test plan

  • Updated validateCommand tests: added cases for now-allowed characters (quoted args, braces, globs, #, parentheses)
  • Kept injection tests for ;, &&, ||, |, `, $(, >, <, &, \n, \r
  • All 50 tests in local-ops.test.ts pass
  • Linter clean

Made with Cursor

Commands run via spawn (no shell), so characters like quotes, braces,
globs, parentheses, and bare $ have no effect. Blocking them prevented
legitimate package specifiers like `pip install sentry-sdk[django]`
wrapped in quotes, or version ranges with `*`.

Keep blocking actual injection patterns: chaining (;, &&, ||), piping
(|), command substitution (`, $(), redirection (>, <), background (&),
and control chars (\n, \r).

Made-with: Cursor
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (commands) Add buildRouteMap wrapper with standard subcommand aliases by BYK in #690

Bug Fixes 🐛

  • (init) Narrow command validation to actual shell injection vectors by betegon in #697
  • (init,feedback) Default to tracing only in feature select and attach user email to feedback by MathurAditya724 in #688

Internal Changes 🔧

  • (eval) Replace OpenAI with Anthropic SDK in init-eval judge by betegon in #683
  • (init) Use markdown pipeline for spinner messages by betegon in #686
  • Regenerate skill files and command docs by github-actions[bot] in 584ec0e0

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/pr-preview/pr-697/

Built to branch gh-pages at 2026-04-09 09:54 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Codecov Results 📊

134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1482 uncovered lines.
✅ Project coverage is 95.44%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.43%    95.44%    +0.01%
==========================================
  Files          224       224         —
  Lines        32538     32527       -11
  Branches         0         0         —
==========================================
+ Hits         31052     31045        -7
- Misses        1486      1482        -4
- Partials         0         0         —

Generated by Codecov Action

@betegon betegon marked this pull request as ready for review April 9, 2026 10:18
@betegon betegon merged commit 07da58d into main Apr 9, 2026
27 checks passed
@betegon betegon deleted the fix/relax-command-validation branch April 9, 2026 10:24
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