T09 · Insecure Skill Coding Practices
- Location
scripts/trash.sh:173- Finding
Manifest Path Traversal Allows Out-of-Scope File Relocation
- Content
View full analysis
= m.length) { idx = m.findIndex(e => e.trashName === target || e.trashName.replace(/^\d+_/, "") === target); } if (idx === -1 || idx >= m.length) { console.log("❌ Not found in trash: " + target); process.exit(1); } const entry = m[idx]; const trashPath = path.join(trashDir, entry.trashName); const origDir = path.dirname(entry.originalPath); // Ensure original directory exists fs.mkdirSync(origDir, { recursive: true }); // Check if original location is occupied if (fs.existsSync(entry.originalPath)) { console.log("⚠️ Original location occupied: " + entry.originalPath); console.log(" Rename or remove it first, then retry."); process.exit(1); } // Use spawnSync to avoid shell interpretation of filenames const { spawnSync } = require("child_process"); // Try mv first, fall back to cp+rm for cross-filesystem let result = spawnSync("mv", ["--", trashPath, entry.originalPath], { stdio: "pipe" }); if (result.status !== 0) { result = spawnSync("cp", ["-a", "--", trashPath, entry.originalPath], { stdio: "pipe" }); if (result.status !== 0) { console.log("❌ Failed to restore: cp failed with status " + result.status); process.exit(1); } const rmResult = spawnSync("rm", ["-rf", "--", trashPath], { stdio: "pipe" }); if (rmResult.status ...[truncated 3151 chars]- Remediation
View remediation
