T09 · Insecure Skill Coding Practices
- Location
lib/artifacts.js:34- Finding
Path Traversal Through Unsanitized Run ID Allows Writes Outside the Artifact Directory
- Content
View full analysis
s.trim()); if (key === '--run_id') args.runId = value; if (key === '--timeout_sec') args.timeoutSec = Number(value); if (key === '--poll_interval') args.pollInterval = Number(value); if (key.startsWith('--')) { i += 1; } } ``` The untrusted value is passed into the generation workflow: ```js const result = await runGenerateImage({ prompt: resolvedArgs.prompt, runId: resolvedArgs.runId, skillDir: SKILL_ROOT, model: resolvedArgs.model, resolution: resolvedArgs.resolution, n: resolvedArgs.n, aspectRatio: resolvedArgs.aspectRatio || null, referenceImages: resolvedArgs.referenceImages, timeoutSec: resolvedArgs.timeoutSec, pollInterval: resolvedArgs.pollInterval, }); ``` It is then joined directly to the artifact root: ```js function artifactsRootForSkill(skillDir) { return path.join(skillDir, '.artifacts'); } function artifactsForRun(skillDir, runId) { return new Artifacts(path.join(artifactsRootForSkill(skillDir), runId)); } ``` The resulting path is used for recu ...[truncated 4392 chars]- Remediation
View remediation
