T09 · Insecure Skill Coding Practices
- Location
audio-forge.js:175- Finding
Predictable Shared Temporary File Enables Symlink-Based File Overwrite
- Content
View full analysis
`file '${f.replace(/\\/g, "/")}'`).join("\n"); fs.writeFileSync(listFile, content, "utf8"); const args = [ "-f", "concat", "-safe", "0", "-i", `"${listFile}"`, "-c", "copy", `"${output}"` ]; runFFmpeg(args); fs.unlinkSync(listFile); console.log(`\n 合并完成: ${output}`); } ``` ### Technical Analysis Every merge operation uses the same predictable temporary path: `/tmp/xza_merge_list.txt` on Unix-like systems, or the equivalent path beneath the directory specified by `TEMP`. `fs.writeFileSync()` follows symbolic links and opens an existing file for truncation by default. It does not use exclusive creation, verify that the destination is a regular file, or ensure that the file was created inside a private temporary directory. Consequently, another local process can prepare the predictable path as a symbolic link to a file writable by the user running this Skill. The shared filename also creates a race between concurrent Skill invocations. One process can replace, modify, or delete another process's FFmpeg concat list. This is particularly problematic because `runFFmpeg()` starts FFmpeg asynchronously and returns immediately, after which `cmdMerge()` immediately deletes the list file. Although this latter behavior is primarily a reliability defect, it increases the opportunity for race conditions and input manipulation. ### Attack Path 1. The attacker has local access to the same system and can write to the shared temporary directory. 2. The attacker predicts that the Skill will use `/tmp/xza_merge_list.txt`. 3. Before the ...[truncated 1421 chars]- Remediation
View remediation
