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
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@
**Vulnerability:** `File(path).canonicalFile`λ₯Ό μ‚¬μš©ν•˜μ—¬ 심볼릭 링크 μ—¬λΆ€λ₯Ό κ²€μ‚¬ν•˜λ©΄, `canonicalFile` ν•¨μˆ˜ λ‚΄λΆ€μ—μ„œ 심볼릭 링크λ₯Ό 이미 λŒ€μƒ(target) 파일의 μ‹€μ œ 경둜둜 해석(resolve)ν•΄ 버리기 λ•Œλ¬Έμ—, 이후에 μ§„ν–‰λ˜λŠ” `Files.isDirectory(..., LinkOption.NOFOLLOW_LINKS)` λ“±μ˜ 심볼릭 링크 μ œν•œ 검사가 μ™„μ „νžˆ 무λ ₯ν™”λ˜λŠ” 취약점이 λ°œκ²¬λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
**Learning:** `canonicalFile`은 λ³΄μ•ˆ 검사(경둜 μ‘°μž‘ λ“±)λ₯Ό μœ„ν•΄ μ ˆλŒ€ 경둜λ₯Ό 얻을 λ•Œ μœ μš©ν•  수 μžˆμ§€λ§Œ, 심볼릭 링크 자체의 νŠΉμ„±(심볼릭 링크인지 μ•„λ‹Œμ§€)을 보쑴해야 ν•˜λŠ” λ§₯λ½μ—μ„œλŠ” μ‚¬μš©ν•˜λ©΄ μ•ˆ λ©λ‹ˆλ‹€.
**Prevention:** 심볼릭 링크 μ—¬λΆ€λ₯Ό 검사해야 ν•˜κ±°λ‚˜ 심볼릭 링크 자체λ₯Ό μ œν•œν•΄μ•Ό ν•˜λŠ” κ²½μš°μ—λŠ” `canonicalFile` λŒ€μ‹  `absoluteFile.toPath().normalize().toFile()`κ³Ό 같이 심볼릭 링크λ₯Ό ν•΄μ„ν•˜μ§€ μ•Šκ³  경둜만 μ •κ·œν™”ν•˜λŠ” 방식을 μ‚¬μš©ν•΄μ•Ό ν•©λ‹ˆλ‹€.
## 2024-05-18 - Prevent Sensitive Information Disclosure
**Vulnerability:** The application lists all files in a directory, including hidden files (those starting with `.`), which could inadvertently expose sensitive information like `.env`, `.git`, or `.ssh` directories.
**Learning:** Default directory listing implementations without hidden file filtering can lead to information disclosure vulnerabilities when serving directories containing configuration or sensitive files.
**Prevention:** Automatically exclude hidden files (files starting with `.`) from the generated directory listing by default.
7 changes: 7 additions & 0 deletions src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ fun process_ignore_file(curr_dir: File): Set<String> {
if ("index.html" !in files_to_exclude)
files_to_exclude.add("index.html")

// λ³΄μ•ˆ ν–₯상: .env, .git λ“± λ―Όκ°ν•œ 정보가 포함될 수 μžˆλŠ” μˆ¨κΉ€ νŒŒμΌμ„ 기본적으둜 λ…ΈμΆœν•˜μ§€ μ•Šλ„λ‘ μ œμ™Έ (정보 λ…ΈμΆœ λ°©μ§€)
curr_dir.list()?.forEach {
if (it.startsWith(".")) {
files_to_exclude.add(it)
}
}

return files_to_exclude
}

Expand Down
11 changes: 11 additions & 0 deletions src/test/kotlin/html4tree/MainTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,15 @@ class MainTest {
assertTrue(excluded.contains("test.txt"))
}

@Test
fun testProcessIgnoreFileHiddenFiles() {
File(tempDir, ".env").createNewFile()
File(tempDir, ".git").mkdir()
File(tempDir, "test.txt").createNewFile()

val excluded = process_ignore_file(tempDir)
assertTrue(excluded.contains(".env"))
assertTrue(excluded.contains(".git"))
assertFalse(excluded.contains("test.txt"))
}
}
Loading