Skip to content

๐Ÿ›ก๏ธ Sentinel: [MEDIUM] ํŒŒ์ผ ๊ต์ฒด ์‹œ ์›์ž์  ์“ฐ๊ธฐ(Atomic Move) ์ง€์›์„ ํ†ตํ•œ TOCTOU ์™„ํ™” - #326

Open
seonghobae wants to merge 4 commits into
masterfrom
security/atomic-move-index-html-14788499207812561110
Open

๐Ÿ›ก๏ธ Sentinel: [MEDIUM] ํŒŒ์ผ ๊ต์ฒด ์‹œ ์›์ž์  ์“ฐ๊ธฐ(Atomic Move) ์ง€์›์„ ํ†ตํ•œ TOCTOU ์™„ํ™”#326
seonghobae wants to merge 4 commits into
masterfrom
security/atomic-move-index-html-14788499207812561110

Conversation

@seonghobae

@seonghobae seonghobae commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

html4tree CLI๊ฐ€ index.html ํŒŒ์ผ์„ ์ƒ์„ฑ/๊ต์ฒดํ•  ๋•Œ ์›์ž์„ฑ(Atomicity)์„ ๋ณด์žฅํ•˜๊ธฐ ์œ„ํ•œ ๋ณด์•ˆ ๊ฐ•ํ™” ํŒจ์น˜์ž…๋‹ˆ๋‹ค.

๐Ÿ›ก๏ธ Sentinel: ๋ณด์•ˆ ๊ฐ•ํ™”

  • ์ทจ์•ฝ์ : Files.move๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ StandardCopyOption.REPLACE_EXISTING๋งŒ ์ง€์ •ํ•˜๋ฉด, ์šด์˜์ฒด์ œ์™€ ํŒŒ์ผ ์‹œ์Šคํ…œ์— ๋”ฐ๋ผ ๋ฎ์–ด์“ฐ๊ธฐ๊ฐ€ ์›์ž์ ์œผ๋กœ ์ด๋ฃจ์–ด์ง€์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ฐฐ๋‚˜์˜ ์ˆœ๊ฐ„์— ์™ธ๋ถ€ ํ”„๋กœ์„ธ์Šค๋‚˜ ์‚ฌ์šฉ์ž๊ฐ€ ๋ถ€๋ถ„์ ์œผ๋กœ ์ž‘์„ฑ๋œ(corrupted) ํŒŒ์ผ์„ ์ฝ๊ฑฐ๋‚˜, ์•…์˜์ ์ธ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ ์Šค์™‘ ๊ณต๊ฒฉ(TOCTOU)์„ ์‹œ๋„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ํ•ด๊ฒฐ์ฑ…: StandardCopyOption.ATOMIC_MOVE๋ฅผ ์˜ต์…˜ ๋ฐฐ์—ด์— ์ถ”๊ฐ€ํ•˜์—ฌ ํŒŒ์ผ ์ด๋™์ด ์›์ž์ ์œผ๋กœ ์ˆ˜ํ–‰๋˜๋„๋ก ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค.
  • ์•ˆ์ „์žฅ์น˜(Fail Securely): ๋ชจ๋“  ํ™˜๊ฒฝ(์˜ˆ: ์„œ๋กœ ๋‹ค๋ฅธ ํŒŒํ‹ฐ์…˜ ๊ฐ„ ์ด๋™์ด๋‚˜ ํŠน์ • ํŒŒ์ผ ์‹œ์Šคํ…œ)์ด ATOMIC_MOVE๋ฅผ ์ง€์›ํ•˜๋Š” ๊ฒƒ์€ ์•„๋‹™๋‹ˆ๋‹ค. ์ด๋ฅผ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด AtomicMoveNotSupportedException ๋ฐœ์ƒ ์‹œ ๊ธฐ์กด์˜ REPLACE_EXISTING ๋ฐฉ์‹์œผ๋กœ Fallback ํ•˜๋„๋ก try-catch ๋ธ”๋ก์„ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ํ…Œ์ŠคํŠธ์šฉ ๋žŒ๋‹ค ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ Fallback ๋กœ์ง์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ž‘๋™ํ•˜๋Š”์ง€ ๊ฒ€์ฆํ•˜๊ณ  **JaCoCo ํ…Œ์ŠคํŠธ ์ปค๋ฒ„๋ฆฌ์ง€ 100%**๋ฅผ ์œ ์ง€ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • .jules/sentinel.md์— ๊ด€๋ จ๋œ ๋ณด์•ˆ ํ•™์Šต ๋‚ด์šฉ์„ ํ•œ๊ตญ์–ด๋กœ ๊ธฐ๋กํ–ˆ์Šต๋‹ˆ๋‹ค.

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

Summary by CodeRabbit

  • ๋ฒ„๊ทธ ์ˆ˜์ •

    • index.html ์ƒ์„ฑ ๊ณผ์ •์˜ ํŒŒ์ผ ๊ต์ฒด ์•ˆ์ •์„ฑ์ด ํ–ฅ์ƒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
    • ์›์ž์  ํŒŒ์ผ ์ด๋™์„ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ํ™˜๊ฒฝ์—์„œ๋„ ํŒŒ์ผ์ด ์ •์ƒ์ ์œผ๋กœ ์ƒ์„ฑ๋˜๋„๋ก ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.
  • ํ…Œ์ŠคํŠธ

    • ์›์ž์  ์ด๋™์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ํ™˜๊ฒฝ์—์„œ์˜ ํŒŒ์ผ ์ƒ์„ฑ ๋™์ž‘์„ ๊ฒ€์ฆํ•˜๋Š” ํ…Œ์ŠคํŠธ๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

ํŒŒ์ผ ๊ต์ฒด ์‹œ ๋ฐœ์ƒํ•˜๋Š” TOCTOU(Time-of-Check to Time-of-Use) ์ทจ์•ฝ์  ๋ฐ
ํŒŒ์ผ ์ฐข์–ด์ง(File Tearing) ํ˜„์ƒ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด StandardCopyOption.ATOMIC_MOVE๋ฅผ
์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ํŒŒ์ผ ์‹œ์Šคํ…œ์ด ์ด๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•ด
AtomicMoveNotSupportedException์„ ์•ˆ์ „ํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ•˜๋Š” Fallback ๋กœ์ง๋„ ํ•จ๊ป˜
์ถ”๊ฐ€ํ•˜๊ณ , ํ…Œ์ŠคํŠธ ์ปค๋ฒ„๋ฆฌ์ง€ 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.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
โš™๏ธ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d0d78130-3307-4010-b3dc-3d556b617384

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 8bb38fc and dc4de39.

๐Ÿ“’ Files selected for processing (5)
  • .jules/palette.md
  • AGENTS.md
  • build.gradle
  • src/main/kotlin/html4tree/main.kt
  • src/test/kotlin/html4tree/MainTest.kt
๐Ÿ“ Walkthrough

Walkthrough

write_index_file์ด ์ž„์‹œ ํŒŒ์ผ์„ ์›์ž์ ์œผ๋กœ ๊ต์ฒดํ•ฉ๋‹ˆ๋‹ค. ์›์ž์  ์ด๋™์„ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ํŒŒ์ผ ์‹œ์Šคํ…œ์—์„œ๋Š” REPLACE_EXISTING ์ด๋™์œผ๋กœ ๋Œ€์ฒดํ•ฉ๋‹ˆ๋‹ค. ํ…Œ์ŠคํŠธ๋Š” ๋Œ€์ฒด ๊ฒฝ๋กœ์™€ ์ƒ์„ฑ๋œ index.html ๋‚ด์šฉ์„ ๊ฒ€์ฆํ•ฉ๋‹ˆ๋‹ค.

Changes

์›์ž์  index.html ํŒŒ์ผ ์“ฐ๊ธฐ

Layer / File(s) Summary
์›์ž์  ํŒŒ์ผ ์ด๋™ ๊ตฌํ˜„
.jules/sentinel.md, src/main/kotlin/html4tree/main.kt
write_index_file์ด ์ž„์‹œ ํŒŒ์ผ์„ ATOMIC_MOVE์™€ REPLACE_EXISTING์œผ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค. AtomicMoveNotSupportedException ๋ฐœ์ƒ ์‹œ ์ผ๋ฐ˜ ๊ต์ฒด ์ด๋™์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
์›์ž์  ์ด๋™ ๋Œ€์ฒด ๊ฒฝ๋กœ ๊ฒ€์ฆ
src/test/kotlin/html4tree/MainTest.kt
์ด๋™ ์ฝœ๋ฐฑ์ด ์›์ž์  ์ด๋™์„ ๊ฑฐ๋ถ€ํ•  ๋•Œ ๋Œ€์ฒด ์ด๋™์ด ์‹คํ–‰๋˜๊ณ  ์ตœ์ข… index.html ๋‚ด์šฉ์ด ์œ ์ง€๋˜๋Š”์ง€ ๊ฒ€์ฆํ•ฉ๋‹ˆ๋‹ค.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • ContextualWisdomLab/html4tree#296: write_index_file์˜ ์›์ž์  ๊ต์ฒด ๋ฐ ๋ฏธ์ง€์› ํŒŒ์ผ ์‹œ์Šคํ…œ ๋Œ€์ฒด ๊ฒฝ๋กœ์™€ ํ…Œ์ŠคํŠธ๋ฅผ ํ•จ๊ป˜ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.
  • ContextualWisdomLab/html4tree#305: ATOMIC_MOVE์™€ REPLACE_EXISTING ๋Œ€์ฒด ๊ฒฝ๋กœ ๋ฐ ๊ด€๋ จ ํ…Œ์ŠคํŠธ๋ฅผ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.

Suggested reviewers: copilot

๐Ÿšฅ Pre-merge checks | โœ… 5
โœ… Passed checks (5 passed)
Check name Status Explanation
Description Check โœ… Passed Check skipped - CodeRabbitโ€™s high-level summary is enabled.
Title check โœ… Passed ์ œ๋ชฉ์€ ํŒŒ์ผ ๊ต์ฒด์— ์›์ž์  ์ด๋™์„ ์ง€์›ํ•˜์—ฌ TOCTOU ์œ„ํ—˜์„ ์™„ํ™”ํ•˜๋Š” ์ฃผ์š” ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ •ํ™•ํ•˜๊ฒŒ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.
Docstring Coverage โœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check โœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check โœ… Passed Check skipped because no linked issues were found for this pull request.
โœจ Finishing Touches
๐Ÿ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
๐Ÿงช Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch security/atomic-move-index-html-14788499207812561110

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

seonghobae and others added 2 commits July 31, 2026 22:05
ํŒŒ์ผ ๊ต์ฒด ์‹œ ๋ฐœ์ƒํ•˜๋Š” TOCTOU(Time-of-Check to Time-of-Use) ์ทจ์•ฝ์  ๋ฐ
ํŒŒ์ผ ์ฐข์–ด์ง(File Tearing) ํ˜„์ƒ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด StandardCopyOption.ATOMIC_MOVE๋ฅผ
์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ํŒŒ์ผ ์‹œ์Šคํ…œ์ด ์ด๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•ด
AtomicMoveNotSupportedException์„ ์•ˆ์ „ํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ•˜๋Š” Fallback ๋กœ์ง๋„ ํ•จ๊ป˜
์ถ”๊ฐ€ํ•˜๊ณ , ํ…Œ์ŠคํŠธ ์ปค๋ฒ„๋ฆฌ์ง€ 100%๋ฅผ ๋‹ฌ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/test/kotlin/html4tree/MainTest.kt`:
- Around line 438-444: Update the write_index_file fallback callback in MainTest
so it verifies the replacement move options exactly: require one option and
ensure it is StandardCopyOption.REPLACE_EXISTING before setting fallbackCalled
and performing Files.move. Keep the existing AtomicMoveNotSupportedException
path and final content assertions unchanged.
๐Ÿช„ Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

โ„น๏ธ Review info
โš™๏ธ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e3a332c2-e56b-458d-a2aa-d18fab0ca346

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between a32b065 and 8bb38fc.

๐Ÿ“’ Files selected for processing (3)
  • .jules/sentinel.md
  • src/main/kotlin/html4tree/main.kt
  • src/test/kotlin/html4tree/MainTest.kt

Comment on lines +438 to +444
write_index_file(tempDir, content) { src, dest, options ->
if (options.contains(StandardCopyOption.ATOMIC_MOVE)) {
throw AtomicMoveNotSupportedException(src.toString(), dest.toString(), "Mocked exception")
} else {
fallbackCalled = true
Files.move(src, dest, *options)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐ŸŽฏ Functional Correctness | ๐ŸŸก Minor | โšก Quick win

๋Œ€์ฒด ์ด๋™ ์˜ต์…˜์„ ์ •ํ™•ํžˆ ๊ฒ€์ฆํ•˜์„ธ์š”.

ํ˜„์žฌ ํ…Œ์ŠคํŠธ๋Š” ATOMIC_MOVE๊ฐ€ ์—†์œผ๋ฉด ๋ชจ๋“  ์˜ต์…˜์„ ๋Œ€์ฒด ๊ฒฝ๋กœ๋กœ ์ธ์ •ํ•ฉ๋‹ˆ๋‹ค. REPLACE_EXISTING์„ ๋ˆ„๋ฝํ•ด๋„ fallbackCalled์™€ ์ตœ์ข… ๋‚ด์šฉ ๊ฒ€์ฆ๋งŒ์œผ๋กœ ํ…Œ์ŠคํŠธ๊ฐ€ ํ†ต๊ณผํ•ฉ๋‹ˆ๋‹ค. ์˜ต์…˜ ๋ฐฐ์—ด์˜ ํฌ๊ธฐ์™€ options[0] == StandardCopyOption.REPLACE_EXISTING์„ ๊ฒ€์ฆํ•˜์„ธ์š”.

์ˆ˜์ • ์˜ˆ์‹œ
             } else {
                 fallbackCalled = true
+                assertEquals(1, options.size)
+                assertEquals(StandardCopyOption.REPLACE_EXISTING, options[0])
                 Files.move(src, dest, *options)
             }
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
write_index_file(tempDir, content) { src, dest, options ->
if (options.contains(StandardCopyOption.ATOMIC_MOVE)) {
throw AtomicMoveNotSupportedException(src.toString(), dest.toString(), "Mocked exception")
} else {
fallbackCalled = true
Files.move(src, dest, *options)
}
write_index_file(tempDir, content) { src, dest, options ->
if (options.contains(StandardCopyOption.ATOMIC_MOVE)) {
throw AtomicMoveNotSupportedException(src.toString(), dest.toString(), "Mocked exception")
} else {
fallbackCalled = true
assertEquals(1, options.size)
assertEquals(StandardCopyOption.REPLACE_EXISTING, options[0])
Files.move(src, dest, *options)
}
๐Ÿค– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/kotlin/html4tree/MainTest.kt` around lines 438 - 444, Update the
write_index_file fallback callback in MainTest so it verifies the replacement
move options exactly: require one option and ensure it is
StandardCopyOption.REPLACE_EXISTING before setting fallbackCalled and performing
Files.move. Keep the existing AtomicMoveNotSupportedException path and final
content assertions unchanged.

ํŒŒ์ผ ๊ต์ฒด ์‹œ ๋ฐœ์ƒํ•˜๋Š” TOCTOU(Time-of-Check to Time-of-Use) ์ทจ์•ฝ์  ๋ฐ
ํŒŒ์ผ ์ฐข์–ด์ง(File Tearing) ํ˜„์ƒ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด StandardCopyOption.ATOMIC_MOVE๋ฅผ
์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ํŒŒ์ผ ์‹œ์Šคํ…œ์ด ์ด๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•ด
AtomicMoveNotSupportedException์„ ์•ˆ์ „ํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ•˜๋Š” Fallback ๋กœ์ง๋„ ํ•จ๊ป˜
์ถ”๊ฐ€ํ•˜๊ณ , ํ…Œ์ŠคํŠธ ์ปค๋ฒ„๋ฆฌ์ง€ 100%๋ฅผ ๋‹ฌ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.
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.

1 participant