T09 · Insecure Skill Coding Practices
- Location
scripts/src/run_analysis.ts:24- Finding
Shell Command Injection Through Unvalidated Task ID
- Content
View full analysis
{ console.log('📂 检测到本地已有任务数据,开始分析...'); try { const { stdout } = await execAsync(`npx ts-node src/analyze_task_data.ts ${taskId}`); console.log(stdout); return true; } catch (error: any) { console.error(`❌ 分析失败:${error.stderr || error.message}`); return false; } } ``` The value reaches this function directly from command-line input: ```ts const args = process.argv.slice(2); if (args.length !== 1) { // ... process.exit(1); } const taskId = args[0]; ``` ### Technical Analysis `taskId` is inserted directly into a command string passed to Node.js `child_process.exec`. The `exec` API invokes a shell, so shell metacharacters, command substitutions, separators, and redirections contained in `taskId` are interpreted by that shell. There is no strict Task ID validation, shell escaping, or use of an argument-array process API. Although normal platform Task IDs appear to be hexadecimal identifiers, the implementation does not enforce that format. Exploitation requires the execution flow to reach `analyzeLocalData`. This happens when a matching local data file exists or after data for a successfully completed task is fetched and saved. ### Attack Path 1. An attacker causes the Skill to invoke `run_analysis.ts` with a malicious Task ID containing shell syntax. 2. The local-data condition is satisfied, for example through a pre-positioned matching data file, or another execution path reaches `analyzeLocalData`. 3. `analyzeLocalData` concatenates the Task ID into: ```sh npx ts-node src/analyze_task_data.ts ``` 4. `exec` passes the string to a shell. 5. The shell interprets the injected syntax and executes the attacker-supplied command. ### ...[truncated 419 chars]- Remediation
View remediation
