Repository navigation
fix: command injection in runCommand (CVSS 7.8) - #167
Merged
Merged
Conversation
Fixes a HIGH severity command injection vulnerability where validated
arguments differed from executed command, allowing shell metacharacter
injection via newlines and quote manipulation.
Security improvements:
- Replace execSync with execFileSync for proper argv array execution
- Add pre-tokenization check for \r\n in raw command string
- Execute validated argv array instead of raw command string
- Add \r to injection character validation regex
- Enforce allowedArgs allowlists (previously dead code)
- Minimize shell usage (only Windows .cmd/yo when required)
Changes:
- src/utils.ts:
- runCommand: Changed from execSync(command) to execFileSync(baseCommand, args)
- Added /[\r\n]/ check on raw command before tokenization
- validateCommandArgs: Added \r to denylist, implemented allowedArgs enforcement
- Only enables shell for Windows .cmd/yo files via shell:true option
Attack scenario prevented:
Before: command="yo\nmalicious" → tokenized as ["yo", "malicious"] →
validation passed → execSync executed "yo\nmalicious" with shell
After: command="yo\nmalicious" → rejected at raw string check →
error thrown before execution
Impact: Prevents arbitrary command execution via newline/CR injection
and quote manipulation in any attacker-influenced command segment.
Testing: All 117 tests passing (0 failures)
CVSS: 7.8 HIGH - CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
PSS Violations: SEC-100
thomaszang
force-pushed
the
fix/path-traversal-vulnerability
branch
from
November 18, 2026 06:52
04acc05 to
52f0ee6
Compare
yaosheng79
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.