T09 · Insecure Skill Coding Practices
Error
- Location
- run.js:93
- Finding
- Shell Command Injection Through the Target Identifier<![CDATA[ ## Vulnerability Details **File Location**: `run.js:93-95` **Vulnerability Type**: OS command injection **Risk Level**: High ### Vulnerable Code ```js if (targetId && !isPreview) { console.log(`🚀 [Anima] Uploading and sending to ${targetId}...`); try { // Pass targetId and video path to send_video_pro.js execSync(`node "${SEND_SCRIPT}" "${targetId}" "${FINAL_VIDEO}"`, { stdio: 'inherit' }); ``` ### Technical Analysis The user-controlled `--target` argument is interpolated into a command string passed to `execSync()`. Because `execSync()` executes the string through a system shell, enclosing the value in double quotes does not safely isolate it. A target containing a quote followed by shell syntax can terminate the intended argument and inject additional commands. No validation restricts the target to a legitimate Feishu identifier format. ### Attack Path 1. An attacker supplies a malicious value through `--target`. 2. Argument parsing stores the value in `targetId`. 3. The value is concatenated into the command at line 95. 4. An embedded quote escapes the quoted argument. 5. The shell interprets the remaining content as commands. 6. The commands execute with the privileges of the Node.js process. For example, a target shaped like `" ; <command> ; #` could escape the argument context and execute an additional command. ### Impact Assessment Successful exploitation provides arbitrary command execution under the account running the Skill. The attacker could read or modify accessible files, obtain API credentials from the local environment or `.env` file, alter generated media, install additional payloads, or access other resources available to that account. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Replace shell-based execution with `execFileSync()` or `spawnSync()` and an argument array: ```js const { execFileSync } = require('child_process'); execFileSync( process.execPath, [SEND_SCRIPT, targetId, FINAL_VIDEO], { stdio: 'inherit' } ); ``` - Validate `targetId` against the exact Feishu identifier grammar and reject unexpected quotes, whitespace, control characters, or shell metacharacters. - Apply length limits to command-line values. - Avoid logging untrusted values without sanitizing control characters. - Run the Skill under a dedicated, minimally privileged operating-system account. ]]>
