T09 · Insecure Skill Coding Practices
- Location
core.mjs:137- Finding
Manifest path traversal allows filesystem moves and writes outside the repository root
- Content
View full analysis
manifest path const remoteToManifest = new Map(); for (const [mPath, info] of Object.entries(manifest.repos)) { if (info.remote) { remoteToManifest.set(info.remote, mPath); } } // For each repo on disk, check if its remote matches a manifest entry at a different path for (const diskPath of diskPaths) { const fullPath = join(reposRoot, diskPath); const gitConfig = join(fullPath, '.git', 'config'); if (!existsSync(gitConfig)) continue; const configText = readFileSync(gitConfig, 'utf8'); const match = configText.match(/url\s*=\s*.*[:/]([^/]+\/[^/\s.]+?)(?:\.git)?\s*$/m); if (!match) continue; const remote = match[1]; const expectedPath = remoteToManifest.get(remote); if (expectedPath && expectedPath !== diskPath) { moves.push({ from: diskPath, to: expectedPath, remote, fromFull: fullPath, toFull: join(reposRoot, expectedPath), }); } } return moves; } export function executeSync(moves, reposRoot) { const results = []; for (const move of moves) { const parentDir = dirname(move.toFull); if (!existsSync(parentDir)) { mkdirSync(parentDir, { recursive: true }); } if (existsSync(move.toFull)) { results.push({ ...move, status: 'skipped', reason: 'target exists' }); continue; } try { renameSync(move.fromFull, move.toFull); results.push({ ...move, status: 'moved' }); } catch (err) { results.push({ ...move, status: 'error' ...[truncated 4448 chars]- Remediation
View remediation
