Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@
**Vulnerability:** CSP ํ•ด์‹œ ๋ถˆ์ผ์น˜๋กœ ์ธํ•œ ์ธ๋ผ์ธ ์Šคํƒ€์ผ ์ฐจ๋‹จ
**Learning:** ๋ธŒ๋ผ์šฐ์ €๋Š” ์ธ๋ผ์ธ ์Šคํฌ๋ฆฝํŠธ์™€ ์Šคํƒ€์ผ์˜ ๋‚ด๋ถ€ ํ…์ŠคํŠธ(๊ณต๋ฐฑ๊ณผ ์ค„๋ฐ”๊ฟˆ ํฌํ•จ)๋ฅผ ์ •ํ™•ํ•˜๊ฒŒ ํ•ด์‹ฑํ•˜์—ฌ Content-Security-Policy(CSP) ํ•ด์‹œ์™€ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค. Kotlin์˜ ๋ฉ€ํ‹ฐ๋ผ์ธ ๋ฌธ์ž์—ด(`"""`)์„ ์‚ฌ์šฉํ•˜์—ฌ ํ…œํ”Œ๋ฆฟ์— ์ฝ˜ํ…์ธ ๋ฅผ ์ฃผ์ž…ํ•  ๋•Œ ์•”๋ฌต์ ์ธ ์—ฌ๋ฐฑ์ด๋‚˜ ์ค„๋ฐ”๊ฟˆ์ด ์ถ”๊ฐ€๋˜๋ฉด ์ตœ์ข… HTML ๋ฌธ์ž์—ด์ด ๋ณ€๊ฒฝ๋˜์–ด CSP ํ•ด์‹œ๊ฐ€ ๋ฌดํšจํ™”๋ฉ๋‹ˆ๋‹ค.
**Prevention:** ์ฝ˜ํ…์ธ ๋ฅผ ํ•ด์‹ฑํ•˜๊ธฐ ์ „์— `.trimIndent()`๋ฅผ ์ ์šฉํ•˜์—ฌ ์›๋ณธ ๋ฌธ์ž์—ด์„ ์ •๊ทœํ™”ํ•˜๊ณ , HTML ํ…œํ”Œ๋ฆฟ์— ์ฃผ์ž…ํ•  ๋•Œ `<style>${exactContent}</style>`์™€ ๊ฐ™์ด ๊ณต๋ฐฑ ์—†์ด ์ฃผ์ž…ํ•˜์—ฌ ํ•ด์‹œ๊ฐ€ ์™„๋ฒฝํ•˜๊ฒŒ ์ผ์น˜ํ•˜๋„๋ก ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

## 2026-08-07 - [MEDIUM] FileSystem getPathMatcher ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ๋ฏธํก์œผ๋กœ ์ธํ•œ DoS
**Vulnerability:** ์‚ฌ์šฉ์ž๊ฐ€ ์กฐ์ž‘ ๊ฐ€๋Šฅํ•œ .html4ignore ๋‚ด์˜ glob ํŒจํ„ด ํŒŒ์‹ฑ ์ค‘ ํŠน์ • ์ž˜๋ชป๋œ ๊ตฌ๋ฌธ(์˜ˆ: ๋นˆ ๋ฌธ์ž์—ด, ํŠน์ • ํŠน์ˆ˜ ๋ฌธ์ž)์œผ๋กœ ์ธํ•ด java.lang.IllegalArgumentException ๋˜๋Š” ๊ธฐํƒ€ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•˜์—ฌ, ์ „์ฒด ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ค‘๋‹จ(DoS)๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
**Learning:** Java NIO์˜ getPathMatcher ๋ฉ”์„œ๋“œ๋Š” PatternSyntaxException ์™ธ์—๋„ IllegalArgumentException๊ณผ ๊ฐ™์€ ๋‹ค๋ฅธ ๋Ÿฐํƒ€์ž„ ์˜ˆ์™ธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์™ธ๋ถ€ ์ž…๋ ฅ์„ ์ฒ˜๋ฆฌํ•  ๋•Œ๋Š” ํฌ๊ด„์ ์ธ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
**Prevention:** glob ํŒจํ„ด ํŒŒ์‹ฑ ๋ฐ getPathMatcher ํ˜ธ์ถœ ์‹œ ํฌ๊ด„์ ์ธ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ๋Ÿฐํƒ€์ž„ ์˜ˆ์™ธ๋กœ ์ธํ•œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ถฉ๋Œ์„ ๋ฐฉ์ง€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
2 changes: 1 addition & 1 deletion src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ fun process_ignore_file(curr_dir: File, dirFilesNames: Array<String>? = null): S
if (pattern.isNotEmpty() && pattern.length <= 100) {
try {
ignored_matchers.add(java.nio.file.FileSystems.getDefault().getPathMatcher("glob:$pattern"))
} catch (_: java.util.regex.PatternSyntaxException) {
} catch (_: Exception) {
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/test/kotlin/html4tree/MainTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,21 @@ class MainTest {
assertTrue(excluded.contains("index.html"))
}

@Test
fun testProcessIgnoreFileIllegalArgumentException() {
val ignoreFile = File(tempDir, ".html4ignore")
// '[' throws PatternSyntaxException, '\0' throws IllegalArgumentException
ignoreFile.writeText("a\u0000b\n\n*.log")

File(tempDir, "test.log").createNewFile()
File(tempDir, "test.txt").createNewFile()

val excluded = process_ignore_file(tempDir, null)
assertTrue(excluded.contains("test.log"))
assertFalse(excluded.contains("test.txt"))
assertTrue(excluded.contains("index.html"))
}

@Test
fun testProcessIgnoreFileDosProtection() {
val ignoreFile = File(tempDir, ".html4ignore")
Expand Down
Loading