T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/audit-skill-dir.mjs:28- Finding
Symbolic Link Following Allows Reads Outside the Selected Audit Directory
- Content
View full analysis
{ for (const rule of rules) { if (rule.re.test(line)) { findings.push({ level: rule.level, label: rule.label, file, line: i + 1, excerpt: line.trim().slice(0, 200) }); } } }); } ``` ### Technical Analysis The directory auditor assumes that every file discovered beneath the selected directory is physically contained within that directory. However, it does not use `lstatSync` to identify symbolic links and does not compare each file's canonical path against the canonical audit root. For a symbolic link, `Dirent.isDirectory()` is false, so a link whose name has an accepted extension can reach `scanFile`. `fs.readFileSync` then follows the symbolic link and reads its external target. The scanner does not print entire files, but any external line matching a detection rule can be included in the JSON output as a finding excerpt. Large or unsuitable linked files may also cause resource consumption or scanner failure. ### Attack Path 1. An attacker prepares a skill directory containing a symbolic link with an accepted filename, such as `external.md`. 2. The symbolic link points to a file outside the skill directory that is readable b ...[truncated 812 chars]- Remediation
View remediation
