fix(policy): fail closed on invalid .html4ignore states - #697
seonghobae wants to merge 1 commit into
Conversation
🚨 Severity: HIGH 💡 Vulnerability: `.html4ignore` 파일을 읽을 때 발생하는 TOCTOU (Time-of-Check to Time-of-Use) 취약점. 파일이 심볼릭 링크나 디렉토리로 변경되거나 권한 오류로 읽지 못할 경우, 기존 로직은 정책 파일을 무시하고 디렉토리를 그대로 스캔(fail-open)하여 숨겨야 할 파일들이 노출될 위험이 있었습니다. 🎯 Impact: 공격자가 악의적으로 정책 파일을 조작하여 권한 우회를 시도하거나, 시스템 오류 시 민감한 파일 목록이 그대로 인덱스에 포함되어 정보 유출(Information Exposure)이 발생할 수 있습니다. 🔧 Fix: 정책 파일 검사 시 일반 파일 여부, 심볼릭 링크 여부, 읽기 권한을 확인하고 이를 통과하지 못하면 `IgnoreFileReadException`을 던져 fail-closed 방식으로 디렉토리 처리를 안전하게 건너뛰도록 수정했습니다. ✅ Verification: 단위 테스트(`testIgnoreFileIsDirectory`, `testIgnoreFileIsSymlink`, `testIgnoreFileReadExceptionCaughtInCrawl`)를 통해 예외가 정상적으로 발생하고 자식 디렉토리 스캔이 차단되는지 확인했습니다. Gradle jacocoTestCoverageVerification (100%)을 통과했습니다.
|
👋 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. |
|
Warning Review limit reachedNext included review available in 47 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
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. Comment |
|
Current-head repair finding for
GREEN acceptance: (a) dangling-symlink RED → GREEN, (b) policy entry is opened without following links through a race-resistant directory-relative handle where supported, with explicit fail-closed behavior when that guarantee cannot be provided, (c) size/line/pattern limits are enforced on the opened object rather than a pre-open path snapshot, and (d) PR/security notes stop claiming TOCTOU is fixed until those invariants are demonstrated. No gate weakening or exception swallowing. |
|
@jules 현재 head
|
.html4ignore가 디렉터리·심볼릭 링크·읽기 불가·크기 초과이거나 읽기 중 I/O 오류가 발생할 때 빈 정책으로 계속 진행하지 않고 해당 디렉터리 처리를 건너뛰도록IgnoreFileReadException경계를 추가합니다.현재 구현으로 확인된 범위:
crawl_directories()가IgnoreFileReadException발생 디렉터리를 렌더링·하위 enqueue하지 않음아직 해결되지 않은 finding이 있어 Draft를 유지합니다.
File.exists()는 symlink target을 따라가므로 dangling.html4ignoresymlink를 “정책 없음”으로 오인하고 fail open할 수 있습니다.Files.exists(path, NOFOLLOW_LINKS)기반 regression이 필요합니다.isFile/isSymbolicLink/canRead/length()를 검사한 뒤 나중에useLines로 다시 여는 구조는 path-check와 open 사이의 TOCTOU를 제거하지 않습니다. 이 PR은 현재 상태에서 “TOCTOU fixed”라고 주장할 수 없습니다.SecureDirectoryStream등 directory-relative no-follow open을 사용하고, 지원하지 않는 provider에서는 명시적으로 fail closed하는 설계가 필요합니다. 크기 제한도 pre-open path snapshot이 아니라 열린 객체에 연결되어야 합니다.Exact head:
868be4cba8fdfe77fafb5bbf30420c0f34f681b1Merge acceptance:
Official API basis: Java
Files.exists는 security-sensitive use에서 결과가 즉시 stale할 수 있음을 명시하고,SecureDirectoryStream은 race-free file operations를 지원하도록 정의되어 있습니다.PR created automatically by Jules for task 15791401563307863241 started by @seonghobae