T09 · Insecure Skill Coding Practices
- Location
scripts/system_cmd_v4.js:372- Finding
Shell Command Injection Bypasses High-Risk Command Confirmation
- Content
View full analysis
1000) { throw new Error(`Command is too long`); } let fullCommand; if (isCmdSpecificCommand(userCommand)) { fullCommand = `cmd /c "chcp 65001 >nul && ${userCommand}"`; } else { fullCommand = `powershell -Command "& {chcp 65001 > $null; ${userCommand}}"`; } const options = { maxBuffer: 1024 * 1024 * 5, encoding: 'utf8', timeout: isHighRisk ? 30000 : 15000 }; const { stdout, stderr } = await execAsync(fullCommand, options); } ``` ### Technical Analysis User-controlled command text is interpolated directly into a CMD or PowerShell command string and passed to `child_process.exec`, which executes through a shell. The high-risk check does not parse the command into executable and argument boundaries. Instead, `isHighRiskCommand` checks whether the entire normalized input starts with one of several known dangerous strings. Active version 4 does not reject shell control operators such as: - PowerShell statement separator: `;` - CMD command operators: `&` and `&&` - Pipelines - Subexpressions and variable expansion - Nested shell invocations - Destructive commands not included in the blacklist Consequently, an input can begin with a command that is not classified as high risk and append a destructive command. The complete string is subsequently evaluated by a shell. The `--yes` confirmation ...[truncated 2096 chars]- Remediation
View remediation
