Skip to content
Closed
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
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@
**Vulnerability:** CSP ํ•ด์‹œ ๋ถˆ์ผ์น˜๋กœ ์ธํ•œ ์ธ๋ผ์ธ ์Šคํƒ€์ผ ์ฐจ๋‹จ
**Learning:** ๋ธŒ๋ผ์šฐ์ €๋Š” ์ธ๋ผ์ธ ์Šคํฌ๋ฆฝํŠธ์™€ ์Šคํƒ€์ผ์˜ ๋‚ด๋ถ€ ํ…์ŠคํŠธ(๊ณต๋ฐฑ๊ณผ ์ค„๋ฐ”๊ฟˆ ํฌํ•จ)๋ฅผ ์ •ํ™•ํ•˜๊ฒŒ ํ•ด์‹ฑํ•˜์—ฌ Content-Security-Policy(CSP) ํ•ด์‹œ์™€ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค. Kotlin์˜ ๋ฉ€ํ‹ฐ๋ผ์ธ ๋ฌธ์ž์—ด(`"""`)์„ ์‚ฌ์šฉํ•˜์—ฌ ํ…œํ”Œ๋ฆฟ์— ์ฝ˜ํ…์ธ ๋ฅผ ์ฃผ์ž…ํ•  ๋•Œ ์•”๋ฌต์ ์ธ ์—ฌ๋ฐฑ์ด๋‚˜ ์ค„๋ฐ”๊ฟˆ์ด ์ถ”๊ฐ€๋˜๋ฉด ์ตœ์ข… HTML ๋ฌธ์ž์—ด์ด ๋ณ€๊ฒฝ๋˜์–ด CSP ํ•ด์‹œ๊ฐ€ ๋ฌดํšจํ™”๋ฉ๋‹ˆ๋‹ค.
**Prevention:** ์ฝ˜ํ…์ธ ๋ฅผ ํ•ด์‹ฑํ•˜๊ธฐ ์ „์— `.trimIndent()`๋ฅผ ์ ์šฉํ•˜์—ฌ ์›๋ณธ ๋ฌธ์ž์—ด์„ ์ •๊ทœํ™”ํ•˜๊ณ , HTML ํ…œํ”Œ๋ฆฟ์— ์ฃผ์ž…ํ•  ๋•Œ `<style>${exactContent}</style>`์™€ ๊ฐ™์ด ๊ณต๋ฐฑ ์—†์ด ์ฃผ์ž…ํ•˜์—ฌ ํ•ด์‹œ๊ฐ€ ์™„๋ฒฝํ•˜๊ฒŒ ์ผ์น˜ํ•˜๋„๋ก ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
## 2024-08-10 - glob ํŒจํ„ด ๊ตฌ๋ฌธ ์˜ค๋ฅ˜๋กœ ์ธํ•œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ํฌ๋ž˜์‹œ(DoS) ๋ฐฉ์ง€
**Vulnerability:** ํŒŒ์ผ ํ•„ํ„ฐ๋ง ๋กœ์ง์—์„œ `getPathMatcher` ์‚ฌ์šฉ ์‹œ ํŠน์ • ๊ตฌ๋ฌธ ์˜ค๋ฅ˜์— ๋Œ€ํ•ด `java.util.regex.PatternSyntaxException`๋งŒ ์˜ˆ์™ธ ์ฒ˜๋ฆฌํ•˜์—ฌ, ๊ทธ ์™ธ์˜ `IllegalArgumentException` ๋ฐœ์ƒ ์‹œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ํฌ๋ž˜์‹œ๋˜๋Š” DoS ์ทจ์•ฝ์ ์ด ์กด์žฌํ–ˆ์Šต๋‹ˆ๋‹ค.
**Learning:** `java.nio.file.FileSystems.getDefault().getPathMatcher()`๋Š” ์ธ์ž๊ฐ€ ์œ ํšจํ•˜์ง€ ์•Š์„ ๋•Œ `IllegalArgumentException`์„ ๋˜์ง€๋ฉฐ, `PatternSyntaxException`์€ ์ด์˜ ํ•˜์œ„ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ํŒจํ„ด ์˜ค๋ฅ˜๋ฅผ ํฌ๊ด„์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ƒ์œ„ ํด๋ž˜์Šค์ธ `IllegalArgumentException`์„ ์žก๋Š” ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ์•ˆ์ „ํ•ฉ๋‹ˆ๋‹ค.
**Prevention:** ์™ธ๋ถ€ ์ž…๋ ฅ(ํŒจํ„ด)์„ ํŒŒ์‹ฑํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ•จ์ˆ˜ ํ˜ธ์ถœ ์‹œ, ๊ณต์‹ ๋ฌธ์„œ์— ๋ช…์‹œ๋œ ๋ชจ๋“  ๋ฐœ์ƒ ๊ฐ€๋Šฅํ•œ ์˜ˆ์™ธ(ํŠนํžˆ `IllegalArgumentException`๊ณผ ๊ฐ™์€ ํฌ๊ด„์  ์˜ˆ์™ธ)๋ฅผ ๋ฐฉ์–ด์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜์—ฌ ์˜ˆ๊ธฐ์น˜ ์•Š์€ ํฌ๋ž˜์‹œ๋ฅผ ๋ฐฉ์ง€ํ•ฉ๋‹ˆ๋‹ค.
2 changes: 1 addition & 1 deletion src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,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 (_: IllegalArgumentException) {
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/kotlin/html4tree/MainTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -717,4 +717,12 @@ class MainTest {
assertFalse(processed, "fileKey mismatch should skip directory processing")
assertFalse(listed, "fileKey mismatch should skip child listing")
}

@Test
fun testProcessIgnoreFileIllegalArgumentException() {
val ignoreFile = File(tempDir, ".html4ignore")
ignoreFile.writeText("[\n")
val excluded = process_ignore_file(tempDir, null)
assertTrue(excluded.contains("index.html"))
}
}
Loading