T09 · Insecure Skill Coding Practices
- Location
index.ts:18- Finding
OS Command Injection Through Unvalidated Skill Input
- Content
View full analysis
{ const { exec } = require("child_process"); exec(`"${scriptPath}" ${args}`, { maxBuffer: 1024 * 1024 }, (error, stdout, stderr) => { if (error) { reject(new Error(stderr || error.message)); return; } try { const result = JSON.parse(stdout); ``` ### Technical Analysis The skill obtains `symbol`, `type`, `start_date`, `end_date`, and `frequency` from its input and interpolates them directly into a command string. It then passes that string to `child_process.exec()`, which executes commands through a system shell. No shell escaping, quoting, schema validation, or strict allowlist is applied before constructing the command. Consequently, shell metacharacters contained in any input field can terminate or alter the intended command and append an arbitrary command. Although the Python CLI defines `argparse` choices for some arguments, those checks occur only after shell interpretation. They therefore cannot prevent command injection in the TypeScript entry point. ### Attack Path 1. An attacker supplies a crafted field such as a symbol containing shell syntax, for example a separator followed by an operating-system command. 2. The value is interpolated into the `args` string without escaping. 3. The full string is supplied to `exec()`. 4. The system shell parses both the i ...[truncated 663 chars]- Remediation
View remediation
