๐ก๏ธ Sentinel: [MEDIUM] Fix DoS and resource exhaustion in ignore file processing#77
Conversation
- `.html4ignore` ํ์ผ ์ฒ๋ฆฌ ์ ํ์ผ ํฌ๊ธฐ(1MB ์ ํ) ๋ฐ ํ์ผ ์ฌ๋ถ(isFile)๋ฅผ ๊ฒ์ฆํ์ฌ ๋ฉ๋ชจ๋ฆฌ ๊ณ ๊ฐ ๋ฐ ๋๋ ํ ๋ฆฌ ์ฝ๊ธฐ ์ค๋ฅ(DoS)๋ฅผ ๋ฐฉ์ง - ๋ฃจํธ ๋๋ ํ ๋ฆฌ ๊ฒ์ฆ ์ `canonicalFile` ๋์ `absoluteFile`์ ์ฌ์ฉํ์ฌ ์ฌ๋ณผ๋ฆญ ๋งํฌ ๋๋ ํ ๋ฆฌ๋ฅผ ์ ์์ ์ผ๋ก ์ฐจ๋จํ๋๋ก ์์ - ๊ด๋ จ ๋ณด์ ํ ์คํธ ์ถ๊ฐ ๋ฐ 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. |
There was a problem hiding this comment.
Pull request overview
This PR hardens directory traversal and .html4ignore loading to mitigate local DoS/resource exhaustion and to correctly reject symlinked top directories, with accompanying regression tests and a security note update.
Changes:
- Reject symlinked
topDirby switchinggo()fromcanonicalFiletoabsoluteFilebeforeNOFOLLOW_LINKSdirectory validation. - Add
.html4ignorevalidation (must be a file and โค 1MB) to avoid crashes/OOM on malicious ignore inputs. - Add tests for directory/oversized
.html4ignorecases and document the incident in Sentinel notes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/kotlin/html4tree/main.kt | Tightens top directory validation and adds size/type gating before parsing .html4ignore. |
| src/test/kotlin/html4tree/SentinelTest.kt | Adds regression tests covering malicious ignore-file shapes (directory / too large). |
| .jules/sentinel.md | Documents the DoS scenario and the preventative guidance. |
Comments suppressed due to low confidence (1)
src/main/kotlin/html4tree/main.kt:95
- The new
.html4ignorevalidation still follows symlinks and accepts non-regular files. A malicious user can make.html4ignorea symlink to a special file like/dev/zero(size reported as 0,isFile()true), causingforEachLineto hang indefinitely (DoS). Also, if the ignore file is unreadable or changes between the checks andforEachLine, the code can still throw and crash. UseFiles.isRegularFile(..., NOFOLLOW_LINKS)(reject symlinks/devices) and guard the size/read with a try/catch so ignore-file parsing failures degrade to โno ignoresโ instead of crashing.
if(ignore_file.exists() && ignore_file.isFile() && ignore_file.length() <= 1048576){ // Limit to 1MB
val ignored_regexes = mutableListOf<Regex>()
ignore_file.forEachLine {
val pattern = it.trim()
๐ก Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
OpenCode exhausted the configured model pool without a usable current-head review conclusion. This is not approval evidence, so the PR is blocked until a source-backed review can establish approval sufficiency or identify concrete fixes.
Findings
1. HIGH .jules/sentinel.md:1 - OpenCode could not establish approval sufficiency
- Problem: every configured model path failed to produce a usable current-head control block.
- Root cause: model execution, timeout, export, normalization, or approval-gate validation did not complete after exponential retry across the configured model pool.
- Impact: approving from deterministic check state alone would miss PR-intent mismatches, missing files, edge-case bugs, robustness gaps, UX/DX regressions, security issues, and CodeGraph-backed base/head flow changes.
- Fix: rerun OpenCode after model availability recovers, or update the PR with the missing files, tests, docs, generated artifacts, and verification evidence needed for a source-backed review conclusion.
- Regression test: keep the approval gate posting REQUEST_CHANGES, not APPROVE or check-only failure, when no model produces a valid current-head review.
Summary
- Result: REQUEST_CHANGES
- Reason: coverage-evidence passed and peer GitHub Checks completed without failures, but no model produced a valid review control block.
- Deterministic evidence checked but not used for approval: current-head changed-file evidence (.jules/sentinel.md, src/main/kotlin/html4tree/main.kt, src/test/kotlin/html4tree/SentinelTest.kt); coverage-evidence result success; peer checks from statusCheckRollup excluding this OpenCode check.
- Model outcome: model_pool=exhausted; selected_model=none.
- Head SHA:
8d94de8bb0fad2c19a6b747505f9bc53a20e91e6 - Workflow run: 28562717559
- Workflow attempt: 1
No PR approval was posted because model-output failure is not evidence that the PR has no blockers.
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (3 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (3 files)"]
R1 --> V1["required checks"]
| **Vulnerability:** Defense in Depth (CSP Missing) | ||
| **Learning:** Even when inputs are properly escaped, statically generated HTML that displays file/directory structures should implement a Content Security Policy (CSP) to provide an extra layer of defense against potential XSS bypasses. | ||
| **Prevention:** Include a strict CSP meta tag (e.g., `default-src 'none'; style-src 'unsafe-inline';`) in auto-generated HTML headers when external scripts or resources are not required. | ||
| ## 2024-07-02 - Malicious ignore files cause DoS |
There was a problem hiding this comment.
HIGH OpenCode could not establish approval sufficiency
- Problem: the model pool exhausted without a valid current-head review control block, so this changed line cannot be approved from deterministic check state alone.
- Impact: PR-intent mismatches, missing files, robustness bugs, UX/DX regressions, and CodeGraph-backed flow changes could be missed.
- Fix: rerun OpenCode after model availability recovers, or add the missing source/test/docs/generated verification evidence needed for a source-backed approval.
- Verification: rerun the OpenCode Review workflow and confirm it emits APPROVE or source-backed REQUEST_CHANGES for this head SHA.
OpenCode Review Overview
Pull request overviewOpenCode exhausted the configured model pool without a usable current-head review conclusion. This is not approval evidence, so the PR is blocked until a source-backed review can establish approval sufficiency or identify concrete fixes. Findings1. HIGH .jules/sentinel.md:1 - OpenCode could not establish approval sufficiency
Summary
No PR approval was posted because model-output failure is not evidence that the PR has no blockers. Changed-File Evidence Mapflowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (3 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (3 files)"]
R1 --> V1["required checks"]
|
.html4ignore๋ฅผ ๋๋ ํ ๋ฆฌ๋ก ๋ง๋ค๊ฑฐ๋ ๊ฑฐ๋ํ ํฌ๊ธฐ์ ํ์ผ๋ก ๋ง๋ค์ด ํ๋ก๊ทธ๋จ ํฌ๋์๋ ์์ ๊ณ ๊ฐ์ ์ ๋ํ ์ ์์์ต๋๋ค. ๋ํ ๋ฃจํธ ๋๋ ํ ๋ฆฌ ๊ฒ์ฆ ๋ก์ง์ดcanonicalFile์ ์ฌ์ฉํ์ฌ ์ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ๋ฏธ๋ฆฌ ํด์ํด๋ฒ๋ฆฌ๊ธฐ ๋๋ฌธ์NOFOLLOW_LINKS์ต์ ์ด ๋ฌด์ฉ์ง๋ฌผ์ด ๋๋ ๋ฒ๊ทธ๊ฐ ์์์ต๋๋ค..html4ignore๋ก๋ ์ ์isFile()์ฒดํฌ์length() <= 1048576(1MB ์ ํ) ๊ฒ์ฆ์ ์ถ๊ฐํ์ต๋๋ค. ๋ํgo()ํจ์์์canonicalFile๋์absoluteFile์ ์ฌ์ฉํ์ฌ ์ฌ๋ณผ๋ฆญ ๋งํฌ๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ๊ฑฐ๋ถ๋๋๋ก ํ์์ต๋๋ค. ๊ด๋ จ ๋ณด์ ํ ์คํธ ์ฝ๋๋ฅผ ์ถ๊ฐํ์์ต๋๋ค../gradlew test jacocoTestReport jacocoTestCoverageVerification๋ช ๋ น์ด๋ฅผ ํตํด ๋ชจ๋ ํ ์คํธ ํต๊ณผ ๋ฐ 100% ์ปค๋ฒ๋ฆฌ์ง๋ฅผ ํ์ธํ์ต๋๋ค.PR created automatically by Jules for task 14696572090787836692 started by @seonghobae