security(ignore): preserve all-or-nothing ignore policy on read failure - #595
security(ignore): preserve all-or-nothing ignore policy on read failure#595seonghobae wants to merge 3 commits into
Conversation
🚨 Severity: MEDIUM 💡 Vulnerability: .html4ignore 파일을 파싱할 때 canRead()로 사전 검사 후 useLines()로 읽어들이는 사이 파일 시스템 상태가 변경(삭제 혹은 권한 박탈)될 수 있는 TOCTOU 취약점. 🎯 Impact: 해당 조건에서 발생하는 처리되지 않은 java.io.IOException으로 인해 전체 디렉토리 크롤러가 충돌하여 서비스 거부(DoS)가 발생할 수 있습니다. 🔧 Fix: useLines() 블록을 try-catch 구문으로 감싸 IOException을 잡아내고, 파일 접근 불가 시 남은 크롤링 작업을 안전하게 계속 진행(Fail Securely)하도록 수정했습니다. ✅ Verification: 코드 리뷰 확인 및 자동화된 테스트 커버리지를 통과.
|
👋 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 48 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: Team 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 |
| var covered = false | ||
| val start = System.currentTimeMillis() | ||
| val t = kotlin.concurrent.thread { | ||
| while (!covered && !Thread.currentThread().isInterrupted) { | ||
| ignoreFile.writeText("pattern") | ||
| ignoreFile.setReadable(false) | ||
| ignoreFile.delete() | ||
| } | ||
| } | ||
| while (!covered && System.currentTimeMillis() - start < 1000) { | ||
| process_ignore_file(testDir) | ||
| } |
There was a problem hiding this comment.
🚨 Severity: MEDIUM 💡 Vulnerability: .html4ignore 파일을 파싱할 때 canRead()로 사전 검사 후 useLines()로 읽어들이는 사이 파일 시스템 상태가 변경(삭제 혹은 권한 박탈)될 수 있는 TOCTOU 취약점. 🎯 Impact: 해당 조건에서 발생하는 처리되지 않은 java.io.IOException으로 인해 전체 디렉토리 크롤러가 충돌하여 서비스 거부(DoS)가 발생할 수 있습니다. 🔧 Fix: useLines() 블록을 try-catch 구문으로 감싸 IOException을 잡아내고, 파일 접근 불가 시 남은 크롤링 작업을 안전하게 계속 진행(Fail Securely)하도록 수정했습니다. ✅ Verification: 코드 리뷰 확인 및 자동화된 테스트 커버리지를 통과.
🚨 Severity: MEDIUM 💡 Vulnerability: .html4ignore 파일을 파싱할 때 canRead()로 사전 검사 후 useLines()로 읽어들이는 사이 파일 시스템 상태가 변경(삭제 혹은 권한 박탈)될 수 있는 TOCTOU 취약점. 🎯 Impact: 해당 조건에서 발생하는 처리되지 않은 java.io.IOException으로 인해 전체 디렉토리 크롤러가 충돌하여 서비스 거부(DoS)가 발생할 수 있으며, 읽기 실패 시 이전에 파싱된 규칙이 적용되어 파일이 노출될 수 있습니다. 🔧 Fix: useLines() 블록을 try-catch 구문으로 감싸 IOException을 잡아내고, 예외 발생 시 적용 중이던 matchers를 초기화하여 Fail Securely 하도록 수정했습니다. ✅ Verification: 의존성 주입을 통한 테스트 추가 및 자동화된 테스트 커버리지를 통과.
| } | ||
| t.interrupt() | ||
| t.join(1000) | ||
| testDir.deleteRecursively() |
| } | ||
|
|
||
| fun process_ignore_file(curr_dir: File, dirFilesNames: Array<String>? = null): Set<String> { | ||
| fun process_ignore_file(curr_dir: File, dirFilesNames: Array<String>? = null, readIgnoreFile: (File) -> Sequence<String> = { it.useLines { lines -> lines.toList().asSequence() } }): Set<String> { |
Valid finding retained, canonical owner moved to #594
This PR remains open as Draft because its useful semantic delta is being retired only through verified succession, not by duplicate cleanup.
Current branch head:
16239da7c52097426e36a64fb1c9ba1006a34978.Canonical repair lane: #594 @
e7722b203ff9cbfc5217f7cd4ff2ef12d8295ba1.Valid delta and current successor state
The useful contract in this branch is all-or-nothing user-policy loading. If the reader yields a valid pattern and then fails, previously parsed matchers from that failed read must be discarded rather than applied as a partial policy.
#594 now carries both sides of that contract. Its deterministic
IgnoreFilePartialReadFailureTest.ktinjects aBufferedReaderthat returns*.secretand then throwsIOException; its new production descendant accumulates matchers in a local list and publishes them only after the complete bounded read returns successfully. AnyIOExceptionyields an empty user matcher list while mandatory defaults remain active.Why this branch is not canonical
This branch changes the public
process_ignore_filesignature to inject aSequence<String>reader, contains a timing-dependent background mutation loop, and includes generated journal text with a literal shell$(date ...). None is required for the product invariant. #594 has the narrower package-internal point-of-use opener seam,NOFOLLOW_LINKS, deterministic validation→open race evidence, ordinary-file positive behavior, narrowIOExceptioncontainment, and now the transactional matcher-publication GREEN.Successor acceptance
Do not close this PR yet. The semantic/test succession is now implemented in #594, but verified closure additionally requires #594 exact head
e7722b203...to pass focused tests/JaCoCo plus CI/Security/SAST/OSV/Scorecard and current review/thread admission. Those exact-head hosted runs are currently non-terminal.After that fresh verification, close this PR as a verified successor rather than merging its broader public-signature/timing/journal changes.
Do not carry the public-signature change, broad policy generalization, timing race, shell-templated journal text, force rewrite, no-op retrigger, or gate weakening into the successor.