T09 · Insecure Skill Coding Practices
- Location
skill.js:68- Finding
Shell Command Injection Through an Unescaped Installation Path
- Content
View full analysis
`file '${f}'`).join("\n")); const final = path.join(epDir, "final_video.mp4"); execSync(`ffmpeg -f concat -safe 0 -i "${list}" -i "${voice}" -c:v libx264 -c:a aac -y "${final}"`, { stdio: 'ignore' }); ``` ### Technical Analysis The skill constructs an FFmpeg command as a string and passes it to `execSync`. By default, `execSync` invokes a system shell. The `list`, `voice`, and `final` variables contain paths derived from `__dirname` through `rootOut` and `epDir`. Double quotes around these values do not make shell interpolation safe. If an attacker can influence the directory where the skill is installed or extracted, a directory name containing a double quote followed by shell syntax can terminate the quoted argument and append another command. No shell escaping or path-character validation is performed. The vulnerability is triggered when episode generation reaches the FFmpeg composition step. ### Attack Path 1. An attacker causes the skill package to be installed, extracted, or executed from a directory whose name contains shell metacharacters. 2. The malicious directory becomes part of `__dirname`. 3. `rootOut`, `epDir`, `list`, `voice`, and `final` inherit the malicious path. 4. The path is interpolated directly into the FFmpeg command string. 5. `execSync` passes the resulting string to the operating-system shell. 6. The shell interprets the injected syntax and executes the attacker's command when video composition begins. This path requires influence over the installation or execution directory. It is not directly exploitable through the novel text, `type`, or `style` parameters. ### Impact Assessment Successful exploitation provides arbitrary command execution ...[truncated 413 chars]- Remediation
View remediation
