T09 · Insecure Skill Coding Practices
- Location
scripts/dancetech_post.js:360- Finding
Externally Generated File Paths Permit Writes Outside the Repository
- Content
View full analysis
{ const fullPath = path.join(repoDir, filePath); fs.mkdirSync(path.dirname(fullPath), { recursive: true }); fs.writeFileSync(fullPath, content, 'utf8'); }); ``` ### Technical Analysis The file map returned by an external language model is accepted without schema or path validation. Each model-controlled object key is treated as a relative file path and joined to `repoDir`. `path.join()` normalizes traversal segments but does not guarantee that the result remains below the intended base directory. A key such as `../../scripts/start_all.js` can therefore resolve outside the generated repository and overwrite another writable project file. The security railcard runs only after the files have been written. It scans for secret patterns, not path traversal or unauthorized file changes, so it does not prevent this vulnerability. ### Attack Path 1. The scheduled script submits a code-generation prompt to OpenRouter. 2. A compromis ...[truncated 1057 chars]- Remediation
View remediation
