Skip to content

fix(ignore): harden final .html4ignore open against symlink traversal - #623

Draft
seonghobae wants to merge 1 commit into
masterfrom
sentinel-toctou-fix-12252579142849172774
Draft

fix(ignore): harden final .html4ignore open against symlink traversal#623
seonghobae wants to merge 1 commit into
masterfrom
sentinel-toctou-fix-12252579142849172774

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Fleet review

  • base: master@728f0f33323e43573d6664209891099502827d5d
  • exact head: 62fc79b9391f918f9feeafcd39a68039dcbedf8e
  • state: Draft / mechanically mergeable

현재 source delta는 .html4ignore를 실제 open하는 지점에서 Files.newInputStream(..., LinkOption.NOFOLLOW_LINKS)를 사용하므로 final path component가 open 직전에 symlink로 바뀌는 경우의 traversal을 줄이는 defense-in-depth로는 유효합니다.

다만 기존 설명의 “TOCTOU 취약점 해결”은 현재 evidence보다 넓습니다. isFile, Files.isSymbolicLink, canRead, length 검사는 여전히 open과 분리되어 있고, opened file identity/size를 동일 descriptor에 결박하지 않습니다. 다른 regular file로의 교체나 ancestor-path mutation까지 이 한 줄이 해결한다고 주장할 수 없습니다.

또한 ./gradlew test jacocoTestReport와 100% coverage는 이 race/security contract의 GREEN이 아닙니다. current tests에는 validation→open 사이에서 .html4ignore를 실제로 교체해 predecessor File.useLines가 sensitive target을 읽고 hardened open이 이를 거부하는 deterministic RED/GREEN fixture가 없습니다. 정적인 symlink fixture만 추가하면 protected base의 기존 !Files.isSymbolicLink(...) pre-check에서도 통과하므로 causal test가 아닙니다.

Required before Ready

  1. validation과 open 사이의 mutation을 deterministic하게 재현하는 seam/fixture를 최소 범위로 설계합니다. production-only test hook이나 flaky timing race는 사용하지 않습니다.
  2. RED는 predecessor가 replacement symlink의 target contents를 소비함을 증명하고, GREEN은 final open에서 symlink traversal을 거부하되 정상 regular .html4ignore parsing contract를 보존해야 합니다.
  3. opened descriptor의 identity/size와 현재 pre-open checks 사이 남는 TOCTOU 범위를 문서화하고, 필요하면 SecureDirectoryStream/descriptor-bound attributes 등 대안을 평가합니다.
  4. .jules/sentinel.md의 repository-wide “TOCTOU 해결” 교리는 위 GREEN이 성립하기 전 protected-base 내용으로 복원하거나 final-component hardening 범위로 좁혀야 합니다.

Self-approval, admin bypass, gate weakening, force push, destructive rebase, no-op retrigger는 사용하지 않습니다.

* `File.useLines` internally resolves symbolic links. We need to prevent following symlinks when reading `.html4ignore`.
* Replaced `ignore_file.useLines` with `Files.newInputStream(ignore_file.toPath(), StandardOpenOption.READ, LinkOption.NOFOLLOW_LINKS).bufferedReader().useLines`.
* Appended findings to `.jules/sentinel.md` journal.
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: b2cd4ef1-022e-4175-9d8b-99e50f57d471

📥 Commits

Reviewing files that changed from the base of the PR and between 728f0f3 and 62fc79b.

📒 Files selected for processing (2)
  • .jules/sentinel.md
  • src/main/kotlin/html4tree/main.kt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae marked this pull request as draft September 4, 2026 21:26
@seonghobae seonghobae changed the title 🛡️ Sentinel: [HIGH] Fix TOCTOU vulnerability in file reading fix(ignore): harden final .html4ignore open against symlink traversal Sep 4, 2026
@seonghobae seonghobae added bug Something isn't working priority: medium Normal-priority or P2 work type: bug Defect or incorrect behavior labels Sep 7, 2026 — with ChatGPT Codex Connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: medium Normal-priority or P2 work type: bug Defect or incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant