Skip to content

fix(docs): reject hard-linked Markdown inputs in both offline link scanners - #382

Merged
drevendev merged 1 commit into
masterfrom
beautifulrepo/markdown-hardlink-boundary-20261115
Nov 15, 2026
Merged

drevendev merged 1 commit into
masterfrom
beautifulrepo/markdown-hardlink-boundary-20261115

Conversation

@drevendev

Copy link
Copy Markdown
Owner

Reader-facing problem

The standalone docs_links.py and html_navigation.py scanners opened Markdown via Path.read_text() after source-path resolution. A hard link is an ordinary regular-file path, so an alias inside a repository can read the bytes of a file outside that checkout. The experimental MCP adapter has its own preflight, but the standalone checkers and bundled skill-local tools did not.

Change

  • Share one read boundary in docs_links.read_markdown_source: refuse symlink/reparse, special and multi-linked files before opening; recheck the open file descriptor and use O_NOFOLLOW where available.
  • Apply the same boundary to HTML/fragment anchor-target reads, not just enumerated Markdown sources.
  • Keep skill-local copies of both checkers byte-identical with the root source.
  • Add outside-file regression tests for the Markdown checker and a hard-linked HTML fragment target; document intentional rejection and the stable-checkout (non-hostile-concurrency) limit.

Acceptance

  • Fresh Quality CI and all applicable checks green on the exact PR head
  • Both new tests execute on Linux and Windows; skipped hard-link creation is not a tested PASS
  • Confirm all 3 docs_links.py copies and all 3 html_navigation.py copies remain identical
  • Later-run review for changed behavior and unaffected normal in-root links

No user files or credentials involved. No new runtime dependencies. No provider release, admin or settings change. CI evidence on this PR is required; locally no full clone was available due DNS.

@drevendev drevendev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bounded exact-head content review — COMMENT (not an independent approval)

Reviewed HEAD: e90b4dc039648a4eb96ca91d1bcdbacfc6dc34aa; base ccf6a5ea01fb3cade75db497c16d132b84de8d54. This PR is open and non-draft; no prior submitted reviews or unresolved review threads were present at the final read.

Judgement: I found no blocking defect within the stated stable-checkout read-boundary change. In the two changed scanner call paths, the shared read_markdown_source() performs an lstat regular/single-link check before opening, a descriptor-level fstat check after opening, and O_NOFOLLOW where available. The HTML/fragment parser now uses that same boundary for Markdown anchor targets instead of read_text(). This is a deliberately conservative rejection policy; it is not proof against concurrent filesystem substitution, and the PR documents that limit without claiming a sandbox.

Exact-file reconciliation: the three copies of docs_links.py all have Git blob 479f8aa507605558bb3582bbde9b1bc5c6d35975; the three copies of html_navigation.py all have blob 48d887fcaf318f6edb03d5f8d97a53e2b5f02784. The bounded two-file test additions cover a linked Markdown source and an HTML anchor target; the changelog and tools documentation describe the same limited behavior.

Observed hosted evidence at this HEAD: Quality checks passed Python 3.11, Python 3.14, Python 3.14 Windows, both Action self-tests and lint. I inspected their job logs: both newly added test_hardlink_* cases report ok on Linux and Windows (not skipped); 836 unit tests were run on each interpreter job, with unrelated platform/tag skips. The unchanged normal-link self-checks also passed (621 Markdown destinations, 641 HTML/fragment destinations). Three additional HEAD-associated workflows succeeded: skills CLI copy trial, synthetic browser evidence and optional MCP smoke. This is hosted evidence inspection, not an independently executed local or adversarial-concurrency test.

Acceptance boundary: authenticated PR author and reviewer are both drevendev. This COMMENT is a source/evidence judgement only; it does not provide actor-separated approval, a provider-enforced acceptance gate, a security certification or permission to merge. A later eligible reviewer should independently make the formal acceptance decision.

@andy-zen-dev andy-zen-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent exact-head review — APPROVE

Reviewed head: e90b4dc039648a4eb96ca91d1bcdbacfc6dc34aa (not a self-review).

I inspected the changed scanner implementation, both call sites (Markdown destinations and HTML/fragment anchor targets), new regression tests, changelog and tool documentation, plus current AGENTS.md and CONTRIBUTING.md. The shared reader rejects non-regular / multi-linked sources before open, checks the opened descriptor again, and uses O_NOFOLLOW where available. The HTML parser now uses this boundary for Markdown anchor targets. All three docs_links copies match blob 479f8aa507605558bb3582bbde9b1bc5c6d35975, and all three html_navigation copies match blob 48d887fcaf318f6edb03d5f8d97a53e2b5f02784.

Exact-head GitHub Actions Quality run https://github.com/drevendev/BeautifulRepo/actions/runs/43714262335 passed Python 3.11, Python 3.14, Windows Python 3.14, both Action self-tests, and lint. I checked Python job logs: both new hard-link regressions actually executed and passed on Windows and Linux (not skipped). The existing scanner checks also passed (621 Markdown and 641 HTML/fragment destinations); the other HEAD-associated workflows reported success.

No merge-blocking finding in the stated stable-checkout scope. This is not an adversarial-concurrent-filesystem guarantee or proof of real Claude Code/Codex agent behavior. Reviewer-local full-suite execution: not_run; this verdict uses independently inspected source and hosted exact-head evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants