Skip to content

Windows junctions get past the symlink guards and can loop the link-checker walk #108

Closed

Description

@drevendev

Reader problem

guides/repository-audit.md:76-77 says directory symlinks in .github or docs are not traversed. On Windows, an NTFS junction gets past that guard, and a junction loop can hang the link checkers. Git checkouts can't create junctions, so this matters for local directories, unpacked archives and working trees prepared by other tools rather than for a hostile clone.

Evidence

Observed on 2026-10-23 at master 1114ffe (Python 3.14, Windows 11).

  • tools/repo_audit.py:41 and :78 only check is_symlink(), which is False for a junction. After mklink /J docs ..\outside, python -I tools/repo_audit.py <fixture> --format json lists docs/README.md in read_files, so it read a file outside the root.
  • os.walk in tools/docs_links.py:808 follows junctions. With two junctions that point back at their parents, docs_links.py didn't finish and was killed after 30 s.
  • Markdown sources reached through a junction are still reported as escaping the root, so the escape check itself holds.

Acceptance

  • Junctions are treated like directory symlinks. Path.is_junction() exists from Python 3.12. Python 3.11 needs a fallback, for example the reparse-point attribute from os.lstat() or a comparison of resolved paths.
  • The directory walk prunes junctions and symlinked directories, and can't loop.
  • Windows-only tests create junctions and run in the existing Windows CI job.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions