Skip to content

๐Ÿ›ก๏ธ Sentinel: [MEDIUM] Fix DoS and resource exhaustion in ignore file processing#77

Open
seonghobae wants to merge 1 commit into
masterfrom
sentinel/fix-dos-and-symlink-14696572090787836692
Open

๐Ÿ›ก๏ธ Sentinel: [MEDIUM] Fix DoS and resource exhaustion in ignore file processing#77
seonghobae wants to merge 1 commit into
masterfrom
sentinel/fix-dos-and-symlink-14696572090787836692

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator
  • ๐Ÿšจ Severity: MEDIUM
  • ๐Ÿ’ก Vulnerability: ๋กœ์ปฌ DoS (์„œ๋น„์Šค ๊ฑฐ๋ถ€) ๋ฐ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ ์šฐํšŒ ์ทจ์•ฝ์ . ์•…์˜์ ์ธ ์‚ฌ์šฉ์ž๊ฐ€ .html4ignore๋ฅผ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ๋งŒ๋“ค๊ฑฐ๋‚˜ ๊ฑฐ๋Œ€ํ•œ ํฌ๊ธฐ์˜ ํŒŒ์ผ๋กœ ๋งŒ๋“ค์–ด ํ”„๋กœ๊ทธ๋žจ ํฌ๋ž˜์‹œ๋‚˜ ์ž์› ๊ณ ๊ฐˆ์„ ์œ ๋„ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌ ๊ฒ€์ฆ ๋กœ์ง์ด canonicalFile์„ ์‚ฌ์šฉํ•˜์—ฌ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ๋ฏธ๋ฆฌ ํ•ด์„ํ•ด๋ฒ„๋ฆฌ๊ธฐ ๋•Œ๋ฌธ์— NOFOLLOW_LINKS ์˜ต์…˜์ด ๋ฌด์šฉ์ง€๋ฌผ์ด ๋˜๋Š” ๋ฒ„๊ทธ๊ฐ€ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
  • ๐ŸŽฏ Impact: ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ํฌ๋ž˜์‹œ (java.io.FileNotFoundException) ๋˜๋Š” OOM (Out Of Memory) ์ž์› ๊ณ ๊ฐˆ.
  • ๐Ÿ”ง Fix: .html4ignore ๋กœ๋“œ ์ „์— isFile() ์ฒดํฌ์™€ length() <= 1048576 (1MB ์ œํ•œ) ๊ฒ€์ฆ์„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ go() ํ•จ์ˆ˜์—์„œ canonicalFile ๋Œ€์‹  absoluteFile์„ ์‚ฌ์šฉํ•˜์—ฌ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๊ฑฐ๋ถ€๋˜๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๊ด€๋ จ ๋ณด์•ˆ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • โœ… Verification: ./gradlew test jacocoTestReport jacocoTestCoverageVerification ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋ชจ๋“  ํ…Œ์ŠคํŠธ ํ†ต๊ณผ ๋ฐ 100% ์ปค๋ฒ„๋ฆฌ์ง€๋ฅผ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค.

PR created automatically by Jules for task 14696572090787836692 started by @seonghobae

- `.html4ignore` ํŒŒ์ผ ์ฒ˜๋ฆฌ ์‹œ ํŒŒ์ผ ํฌ๊ธฐ(1MB ์ œํ•œ) ๋ฐ ํŒŒ์ผ ์—ฌ๋ถ€(isFile)๋ฅผ ๊ฒ€์ฆํ•˜์—ฌ ๋ฉ”๋ชจ๋ฆฌ ๊ณ ๊ฐˆ ๋ฐ ๋””๋ ‰ํ† ๋ฆฌ ์ฝ๊ธฐ ์˜ค๋ฅ˜(DoS)๋ฅผ ๋ฐฉ์ง€
- ๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌ ๊ฒ€์ฆ ์‹œ `canonicalFile` ๋Œ€์‹  `absoluteFile`์„ ์‚ฌ์šฉํ•˜์—ฌ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์ •์ƒ์ ์œผ๋กœ ์ฐจ๋‹จํ•˜๋„๋ก ์ˆ˜์ •
- ๊ด€๋ จ ๋ณด์•ˆ ํ…Œ์ŠคํŠธ ์ถ”๊ฐ€ ๋ฐ 100% ํ…Œ์ŠคํŠธ ์ปค๋ฒ„๋ฆฌ์ง€ ์œ ์ง€
@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.

Copilot AI review requested due to automatic review settings July 2, 2026 03:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 topDir by switching go() from canonicalFile to absoluteFile before NOFOLLOW_LINKS directory validation.
  • Add .html4ignore validation (must be a file and โ‰ค 1MB) to avoid crashes/OOM on malicious ignore inputs.
  • Add tests for directory/oversized .html4ignore cases 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 .html4ignore validation still follows symlinks and accepts non-regular files. A malicious user can make .html4ignore a symlink to a special file like /dev/zero (size reported as 0, isFile() true), causing forEachLine to hang indefinitely (DoS). Also, if the ignore file is unreadable or changes between the checks and forEachLine, the code can still throw and crash. Use Files.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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"]
Loading

Comment thread .jules/sentinel.md
**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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

OpenCode Review Overview

  • Head SHA: 8d94de8bb0fad2c19a6b747505f9bc53a20e91e6
  • Workflow run: 28562717559
  • Workflow attempt: 1
  • Gate result: REQUEST_CHANGES (approval step)

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"]
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants