security: bind .html4ignore read to NOFOLLOW_LINKS at open time - #632
security: bind .html4ignore read to NOFOLLOW_LINKS at open time#632seonghobae wants to merge 9 commits into
Conversation
This commit addresses a Time-of-Check-Time-of-Use (TOCTOU) symlink swapping vulnerability by explicitly preventing `Files.newInputStream` from following symbolic links when reading `.html4ignore` files.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This commit addresses a Time-of-Check-Time-of-Use (TOCTOU) symlink swapping vulnerability by explicitly preventing `Files.newInputStream` from following symbolic links when reading `.html4ignore` files. It also adds a unit test to guarantee this behavior.
This commit addresses a Time-of-Check-Time-of-Use (TOCTOU) symlink swapping vulnerability by explicitly preventing `Files.newInputStream` from following symbolic links when reading `.html4ignore` files. It also adds a unit test to guarantee this behavior.
This commit addresses a Time-of-Check-Time-of-Use (TOCTOU) symlink swapping vulnerability by explicitly preventing `Files.newInputStream` from following symbolic links when reading `.html4ignore` files. It also adds a unit test to guarantee this behavior.
This commit addresses a Time-of-Check-Time-of-Use (TOCTOU) symlink swapping vulnerability by explicitly preventing `Files.newInputStream` from following symbolic links when reading `.html4ignore` files. It also adds a unit test to guarantee this behavior.
This commit addresses a Time-of-Check-Time-of-Use (TOCTOU) symlink swapping vulnerability by explicitly preventing `Files.newInputStream` from following symbolic links when reading `.html4ignore` files. It also adds a unit test to guarantee this behavior.
This commit addresses a Time-of-Check-Time-of-Use (TOCTOU) symlink swapping vulnerability by explicitly preventing `Files.newInputStream` from following symbolic links when reading `.html4ignore` files. It also adds a unit test to guarantee this behavior.
This commit addresses a Time-of-Check-Time-of-Use (TOCTOU) symlink swapping vulnerability by explicitly preventing `Files.newInputStream` from following symbolic links when reading `.html4ignore` files. It also adds a unit test to guarantee this behavior.
Current exact authority
master@728f0f33323e43573d6664209891099502827d5d5c29d6c8d48504720a0add35136ceee26a6b5f57mastersrc/main/kotlin/html4tree/main.ktonly.jules/sentinel.mddoctrine was restored byte-for-byte to protected authorityValid finding
The protected implementation checks
isFile,isSymbolicLink, readability, and size before later callingFile.useLines. A final-component path can change after those checks. This branch changes the time-of-use open toFiles.newInputStream(path, READ, NOFOLLOW_LINKS), so a final-component symlink is not followed by that open. Java NIO definesLinkOption.NOFOLLOW_LINKSas anOpenOptionwhose contract is not to follow symbolic links.The original PR overclaimed full TOCTOU closure and verified security without a deterministic swap case. No branch test currently proves a replacement between pre-check and open, and an open-time
IOExceptioncurrently escapesprocess_ignore_file/crawl_directories, which is fail-closed for publication but can terminate the wider crawl instead of applying a bounded per-directory policy failure.Sibling #629 owns a complementary delta: a declared-but-invalid policy becomes
IgnoreFileReadException, the crawler skips publication of that directory, and current successor466c214dd7b358e77d411514165ad72562871bcfincludes a deterministic propagation test. #629, however, still usesFile.useLinesafter the pre-check and therefore does not by itself bind the actual open toNOFOLLOW_LINKS. Neither PR fully supersedes the other yet; do not close either as a duplicate.GREEN acceptance
Produce one normal descendant/successor that preserves both valid semantic deltas: (1) a time-of-use open that cannot follow a final-component symlink, and (2) typed fail-closed policy-read handling that prevents publication/child traversal for the affected directory without silently treating policy failure as no policy. Add deterministic seams/fixtures for open failure and replacement semantics rather than a timing-dependent background race. Preserve the existing size/line/pattern limits and default-sensitive exclusions. Then run one unchanged exact head through CI/security/SAST/CodeQL. Only after byte/semantic/test inheritance is verified may one sibling be closed as fully superseded.
Fresh current-head workflows are non-terminal: CI
33992368306, Security Scan33992368293, SAST Semgrep33992368415, and CodeQL PR33992368282are queued/pending. Predecessor results do not transfer.No force-push, destructive rebase, self-approval, suppression, or security-severity inflation. Keep Draft until the combined causal boundary and exact-head evidence exist.