T05 · Unauthorized Access and Privilege Escalation
- Location
vet.ts:11- Finding
Undocumented Whole-System File Scanning Exceeds Least-Privilege Boundaries
- Content
View full analysis
{ const results: ScanResult[] = [] const scannedFiles = new Set() const maxFiles = 10000 const scanableExtensions = [".js", ".ts", ".tsx", ".jsx", ".bat", ".cmd", ".ps1", ".vbs", ".py", ".rb", ".sh", ".bash"] const excludeSet = new Set([ "node_modules", ".git", "Windows", "Program Files", "Program Files (x86)", "AppData/Local/Temp", "AppData/Local/Microsoft/Windows", "$Recycle.Bin", "System Volume Information", ".cache", ".npm", ".yarn" ]) async function scanDir(dirPath: string, depth: number = 0) { if (depth > 5 || results.filter(r => r.status === "danger").length >= 10) return if (scannedFiles.size >= maxFiles) return try { const entries = await readdirAsync(dirPath, { withFileTypes: true }) for (const entry of entries) { if (scannedFiles.size >= maxFiles) break if (excludeSet.has(entry.name)) continue const fullPath = join(dirPath, entry.name) if (entry.isDirectory()) { await scanDir(fullPath, depth + 1) } else if (entry.isFile()) { const ext = extname(entry.name).toLowerCase() if (SUSPICIOUS_EXTENSIONS.includes(ext)) { try { const content = await readFileAsync(fullPath, "utf-8") const issues = await scanFileContent(fullPath, content) if (issues.length > 0) { const highCount = issues.filter(i => i.severity === "high").length const score = Math.max(0, 100 - highCount * 30) results.push({ name: entry.name, path: fullPat ...[truncated 2362 chars]- Remediation
View remediation
