T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/check_path_boundary.py:56- Finding
Symlink Following Allows Reads Outside the Audited Skill Boundary
- Content
View full analysis
Vulnerability Details
File Location:
scripts/check_path_boundary.py, lines 56–64
Vulnerability Type: Filesystem boundary violation through symlink traversal
Risk Level: MediumVulnerable Code
python for f in sorted(skill_path.rglob("*")): if f.suffix not in EXTS or not f.is_file(): continue if SKIP_DIRS & set(f.parts): continue try: lines = f.read_text(encoding="utf-8", errors="ignore").splitlines() except OSError as e: print(f"WARN: could not read, skipping: {f} - {e}", file=sys.stderr) continueTechnical Analysis
The scanner recursively enumerates files beneath the supplied skill directory but does not reject symbolic links. Both
Path.is_file()andPath.read_text()follow symbolic links.Consequently, an untrusted skill can contain a path such as
scripts/external.pythat is a symbolic link to a file outside the audited directory. The scanner will treat the link as an ordinary Python file and read its target using the auditor process's filesystem privileges.The filename filter does not prevent exploitation because it evaluates the symlink's path suffix. A link named
external.pycan point to a target with any filename or extension. If the external content matches a path-chain expression recognized by the scanner, part of that content may also be included in a finding.Attack Path
- An attacker prepares a skill directory containing a symbolic link named with a
.pysuffix. - The link points to a file outside the supplied skill root that is readable by the auditing process.
- A user or Agent runs
check_path_boundary.pyagainst the malicious skill. rglob()discovers the symlink andis_file()follows it.read_text()reads the external target.- Matching content may influence scan results or be partially printed in the finding output.
Impact Assessment
This violates the scan ...[truncated 629 chars]
- An attacker prepares a skill directory containing a symbolic link named with a
- Remediation
View remediation
Remediation Suggestions
Reject symbolic links and verify the resolved location of every candidate before opening it:
python skill_path = skill_path.resolve() for f in sorted(skill_path.rglob("*")): if f.is_symlink(): continue if f.suffix not in EXTS or not f.is_file(): continue try: resolved = f.resolve(strict=True) resolved.relative_to(skill_path) except (OSError, ValueError): print( f"ERROR: file escapes or cannot be resolved: {f}", file=sys.stderr, ) scan_failed = True continue try: with resolved.open("r", encoding="utf-8", errors="ignore") as source: lines = source.read().splitlines() except OSError as e: print(f"ERROR: could not read: {resolved} - {e}", file=sys.stderr) scan_failed = True continueIn addition:
- Treat detected symlinks as an explicit finding or inconclusive scan rather than silently following them.
- Perform the containment check immediately before opening the file.
- Where supported, use no-follow filesystem semantics to reduce time-of-check/time-of-use risk.
- Run audits of untrusted packages in a sandbox whose filesystem view contains only the package and required runtime files.
