T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/release_gate.py:329- Finding
Repository Symlinks Can Read Sensitive Files Outside the Audit Target
- Content
View full analysis
Vulnerability Details
File Location:
scripts/release_gate.py:329-333
Vulnerability Type: Path-boundary violation through symbolic-link traversal
Risk Level: MediumVulnerable Code
python fp = Path(base) / rel if not fp.is_file(): continue try: text = fp.read_text(encoding="utf-8", errors="replace") except Exception: continueTechnical Analysis
Paths obtained from the repository are appended to the target directory without resolving the resulting path and verifying that it remains inside the target directory.
Both
Path.is_file()andPath.read_text()follow symbolic links. Consequently, a Git-tracked symbolic link can reference a file outside the repository. When the scanner processes that path, it reads the external file using the privileges of the user or CI worker running the audit.This behavior exceeds the minimum privileges required for repository auditing. The declared functionality only requires reading files within the selected repository and its Git history.
The external file's contents are passed to
scan_text(). If they match a configured pattern, the matching line can be copied into the generated text or JSON report. Reports written to CI logs or retained as artifacts may therefore disclose local secrets.Attack Path
- An attacker prepares a repository containing a tracked symbolic link pointing outside the repository, such as to a user configuration, credential, or private-key file.
- A victim or CI service checks out the repository on a platform that preserves symbolic links.
- The victim runs
release_gate.pyinpublic,worktree, orallmode. scan_paths()constructs the path and follows the symbolic link throughis_file()andread_text().- The scanner reads the external file with the caller's existing filesystem permissions.
- Matching content is included in terminal output, JSON output, CI logs, or retained report a ...[truncated 586 chars]
- Remediation
View remediation
Remediation Suggestions
-
Reject symbolic links before reading files. Use
lstat()orPath.is_symlink()rather than relying onis_file(). -
Resolve each candidate path and verify that it remains below the canonical repository root:
python root = Path(base).resolve() candidate = root / rel if candidate.is_symlink(): continue resolved = candidate.resolve(strict=True) try: resolved.relative_to(root) except ValueError: continue if not resolved.is_file(): continue -
Consider rejecting paths when any component between the repository root and file is a symbolic link, not only when the final component is one.
-
Record rejected out-of-root paths as warnings without reading their targets.
-
Add regression tests for absolute symlinks, relative symlinks containing
.., chained symlinks, broken symlinks, and symlinked directories. -
Run repository audits under a dedicated low-privilege account that cannot read unrelated user or service credentials.
-
