Skip to content

๐Ÿ›ก๏ธ Sentinel: [MEDIUM] CSP Hash ์ ์šฉ ๋ฐฉ์‹ ๋ณด์•ˆ ๊ฐ•ํ™” - #274

Closed
seonghobae wants to merge 1 commit into
masterfrom
sentinel-csp-hash-fix-12596847652619187529
Closed

๐Ÿ›ก๏ธ Sentinel: [MEDIUM] CSP Hash ์ ์šฉ ๋ฐฉ์‹ ๋ณด์•ˆ ๊ฐ•ํ™”#274
seonghobae wants to merge 1 commit into
masterfrom
sentinel-csp-hash-fix-12596847652619187529

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

๐Ÿšจ Severity: MEDIUM
๐Ÿ’ก Vulnerability: ์ •์  ๋ฆฌ์†Œ์Šค์šฉ CSP ์ƒ์„ฑ ์‹œ ํ•ด์‹œ ๋ถˆ์ผ์น˜
๐ŸŽฏ Impact: ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์Šคํƒ€์ผ์„ ์ฐจ๋‹จํ•˜์—ฌ ํ™”๋ฉด์ด ๊นจ์ง€๊ฑฐ๋‚˜ CSP ์šฐํšŒ๊ฐ€ ๊ฐ€๋Šฅํ•ด์ง
๐Ÿ”ง Fix: <style> ํƒœ๊ทธ ๋‚ด๋ถ€ ๋‚ด์šฉ์„ ์ •ํ™•ํ•˜๊ฒŒ ๋งž์ถ”๊ธฐ ์œ„ํ•ด trimIndent()๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ๊ณต๋ฐฑ ์—†์ด ์ฃผ์ž…ํ•จ
โœ… Verification: ./gradlew test ํ†ต๊ณผ ๋ฐ ์ƒ์„ฑ๋œ HTML ๋‚ด์˜ ์Šคํƒ€์ผ๊ณผ ํ•ด์‹œ๊ฐ€ ์ •ํ™•ํžˆ ์ผ์น˜ํ•จ


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

@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 26, 2026 03:30

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 html4treeโ€™s generated index.html Content Security Policy (CSP) by ensuring the style-src SHA-256 hash is computed from the exact inline <style> content that is emitted into the HTML, preventing browser style blocking and avoiding hash/markup mismatches.

Changes:

  • Normalize the CSS multiline string with trimIndent() and compute the CSP sha256-... hash from that normalized value.
  • Emit the <style> tag as a single string (<style>${content}</style>) to avoid template-introduced whitespace differences.
  • Document the CSP hash mismatch lesson/prevention guidance in the Jules Sentinel log.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/kotlin/html4tree/main.kt Aligns CSP hash input with emitted <style> text by normalizing and injecting the exact same string.
.jules/sentinel.md Records the security learning/prevention note related to CSP hash mismatches from multiline string injection.

๐Ÿ’ก Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +313 to +316
val exactStyleContent = cssContent.trimIndent()
val styleHash = "sha256-" + Base64.getEncoder().encodeToString(MessageDigest.getInstance("SHA-256").digest(exactStyleContent.toByteArray(Charsets.UTF_8)))

val css = """
<style>
${cssContent} </style>
"""
val css = "<style>${exactStyleContent}</style>"
Comment thread .jules/sentinel.md
Comment on lines +89 to +90
**Learning:** Kotlin์—์„œ ๋‹ค์ค‘ ์ค„ ๋ฌธ์ž์—ด(multiline string)๋กœ ๊ตฌ์„ฑ๋œ ์ฝ˜ํ…์ธ (์˜ˆ: CSS)๋ฅผ HTML ํ…œํ”Œ๋ฆฟ์˜ `<style>` ํƒœ๊ทธ์™€ ๊ฒฐํ•ฉํ•  ๋•Œ, ์–‘ ์˜†์— ์‚ฝ์ž…๋œ ๊ณต๋ฐฑ๊ณผ ์ค„๋ฐ”๊ฟˆ์€ CSP ํ•ด์‹œ ์—ฐ์‚ฐ ์‹œ ์ œ์™ธ๋˜์ง€๋งŒ ์‹ค์ œ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ํŒŒ์‹ฑํ•˜๋Š” ํ…์ŠคํŠธ์—๋Š” ํฌํ•จ๋˜์–ด ํ•ด์‹œ ๋ถˆ์ผ์น˜๋ฅผ ์•ผ๊ธฐํ•ฉ๋‹ˆ๋‹ค.
**Prevention:** ํ…œํ”Œ๋ฆฟ์— ์‚ฝ์ž…ํ•  ์ฝ˜ํ…์ธ ์—๋Š” ํ•ญ์ƒ `.trimIndent()`๋ฅผ ์ ์šฉํ•˜์—ฌ ์„ ํ–‰/ํ›„ํ–‰ ๊ณต๋ฐฑ ๋ฐ ์ค„๋ฐ”๊ฟˆ์„ ์™„๋ฒฝํžˆ ์ œ๊ฑฐํ•˜๊ณ , ์ฃผ์ž… ์‹œ `<style>${content}</style>`์™€ ๊ฐ™์ด ์ถ”๊ฐ€ ๊ณต๋ฐฑ ์—†์ด ๊ฒฐํ•ฉํ•˜์—ฌ ํ•ด์‹œ์˜ ์›๋ณธ ์ฝ˜ํ…์ธ ์™€ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ๋ณด๋Š” ํ…์ŠคํŠธ๋ฅผ ์ •ํ™•ํ•˜๊ฒŒ ๋™๊ธฐํ™”ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by canonical #363. Both repair the inline-style CSP hash mismatch, but #363 additionally verifies the exact emitted UTF-8 style bytes from a real generated page, hoists the immutable source and hash, adds APA 7 doctoring and changelog, and has fresh current-head CI/JaCoCo/Security/Semgrep evidence. No result from this duplicate head is reused.

@seonghobae seonghobae closed this Aug 5, 2026
@google-labs-jules

Copy link
Copy Markdown

Closing as superseded by canonical #363. Both repair the inline-style CSP hash mismatch, but #363 additionally verifies the exact emitted UTF-8 style bytes from a real generated page, hoists the immutable source and hash, adds APA 7 doctoring and changelog, and has fresh current-head CI/JaCoCo/Security/Semgrep evidence. No result from this duplicate head is reused.

Understood. Acknowledging that this work is now obsolete and superseded by canonical #363, and stopping work on this task.

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