fix(core): remove shell: true from spawn() in ralph checks#243
Open
fix(core): remove shell: true from spawn() in ralph checks#243
Conversation
using shell: true unnecessarily expands the attack surface: if any argument or path ever contains shell metacharacters, the shell would interpret them. all commands in runCommand() are hardcoded (npm, npx) with fixed arg arrays, so shell interpretation provides no benefit. removing shell: true eliminates the vector and silences the static analysis warning. on linux/macos npm and npx are directly executable; if windows support is needed in future, callers can pass shell: true explicitly or use spawn's shell option conditionally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
What
Removes
shell: truefrom thespawn()call incore/src/ralph/checks.ts.Why
shell: trueenables shell interpretation of the command string, which creates a shell injection vector. If any argument orcwdvalue ever contained shell metacharacters (;,&&,$(...), etc.), the shell would interpret them.In this specific function, all callers pass hardcoded commands (
npm,npx) with fixed argument arrays, so shell interpretation provides zero benefit while adding unnecessary risk. Static analysis tools (e.g. the ralph security scanner already present in this repo) correctly flag this pattern.Before:
After:
Scope
Single-line change in
core/src/ralph/checks.ts:25. No behaviour change on Linux/macOS wherenpmandnpxare directly executable. If Windows support is needed in future,shell: process.platform === 'win32'is the idiomatic approach.Tested
npm run type-checkpasses (exit 0)npm run lintoutput unchanged🤖 Generated with Claude Code