T09 · Insecure Skill Coding Practices
- Location
index.ts:8- Finding
Shell Command Injection Through Untrusted Tool Arguments
- Content
View full analysis
- Remediation
View remediation
= {}, ) { if (!ALLOWED_TOOLS.has(toolName)) { throw new Error('Unsupported Baozi MCP tool'); } const { stdout, stderr } = await execFileAsync( process.execPath, [ require.resolve('@baozi.bet/mcp-server/dist/index.js'), '--tool', toolName, '--args', JSON.stringify(args), ], { shell: false, timeout: 30_000, maxBuffer: 1024 * 1024, }, ); if (stderr) { console.error('Baozi MCP stderr:', stderr); } return JSON.parse(stdout); } ``` 2. Prefer importing a reviewed package API directly instead of starting a subprocess. 3. Enforce strict schemas at runtime. Reject unknown properties, invalid Solana addresses, non-finite amounts, oversized strings, and malformed market identifiers. 4. Keep `toolName` restricted to a fixed internal allowlist, even if it is not currently exposed directly to users. 5. Run the skill with least privilege and without unnecessary filesystem, credential, or network access. 6. Add regression tests containing quotes, semicolons, command substitutions, newlines, and other shell metacharacters. ]]>
