Skip to content

πŸ›‘οΈ Sentinel: [HIGH] 인라인 μŠ€νƒ€μΌ 'unsafe-inline' CSP λ³΄μ•ˆ 취약점 μˆ˜μ • 및 Nonce 기반 μ •μ±… 적용#127

Open
seonghobae wants to merge 1 commit into
masterfrom
sentinel/csp-nonce-enhancement-17083573628632093851
Open

πŸ›‘οΈ Sentinel: [HIGH] 인라인 μŠ€νƒ€μΌ 'unsafe-inline' CSP λ³΄μ•ˆ 취약점 μˆ˜μ • 및 Nonce 기반 μ •μ±… 적용#127
seonghobae wants to merge 1 commit into
masterfrom
sentinel/csp-nonce-enhancement-17083573628632093851

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

🚨 λ³΄μ•ˆ 심각도 (Security Severity): HIGH

정적 μ›Ή μƒμ„±κΈ°μ—μ„œ μƒμ„±λœ HTML 결과물은 파일 κ²½λ‘œλ‚˜ 이름 λ“±μ—μ„œ μž…λ ₯λ˜λŠ” μ˜ˆμƒμΉ˜ λͺ»ν•œ μ•…μ˜μ μΈ νŽ˜μ΄λ‘œλ“œμ— λ…ΈμΆœλ  수 μžˆμŠ΅λ‹ˆλ‹€. κΈ°μ‘΄ λ²„μ „μ—μ„œλŠ” style-src 'unsafe-inline' CSP μ§€μ‹œμ–΄κ°€ ν—ˆμš©λ˜μ–΄ 인라인 CSS μΈμ μ…˜μ„ ν†΅ν•œ 잠재적 XSS(Cross-Site Scripting) 우회 곡격이 κ°€λŠ₯ν–ˆμŠ΅λ‹ˆλ‹€.

πŸ’‘ 취약점 (Vulnerability)

html4tree의 μƒμ„±λœ index.html 파일 λ‚΄λΆ€μ—λŠ” λ””μžμΈ λ Œλ”λ§μ„ μœ„ν•΄ CSS 인라인 μŠ€νƒ€μΌ 블둝(<style>)이 ν¬ν•¨λ˜μ–΄ 있으며, style="display:block; width:100%" λ“±μ˜ 인라인 μŠ€νƒ€μΌ 속성이 HTML νƒœκ·Έμ— 직접 μ§€μ •λ˜μ–΄ μžˆμ—ˆμŠ΅λ‹ˆλ‹€. 이 λ•Œλ¬Έμ— 기쑴의 Content-Security-Policy 메타 νƒœκ·Έκ°€ 'unsafe-inline'을 κ°•μ œλ‘œ ν—ˆμš©ν•˜κ³  μžˆμ—ˆμŠ΅λ‹ˆλ‹€.

🎯 μž„νŒ©νŠΈ (Impact)

λ§Œμ•½ μ–΄λ–€ 경둜λ₯Ό 톡해 μ•…μ„± μ‚¬μš©μžκ°€ 이 λ„κ΅¬μ˜ μž…λ ₯(예: μ•…μ˜μ μΈ 파일 및 폴더 이름 생성 λ“±)을 λ³€μ‘°ν•  수 μžˆλ‹€λ©΄, 인라인 μŠ€νƒ€μΌ ν—ˆμš© μ •μ±…(unsafe-inline)을 μ΄μš©ν•΄ μ•…μ„± CSS λ˜λŠ” 우회된 μžλ°”μŠ€ν¬λ¦½νŠΈλ₯Ό λ‘œλ“œν•˜λ„λ‘ μ‘°μž‘ν•  μœ„ν—˜μ΄ μ‘΄μž¬ν•©λ‹ˆλ‹€.

πŸ”§ ν•΄κ²° λ°©μ•ˆ (Fix)

λ³Έ μˆ˜μ • μ‚¬ν•­μ—μ„œλŠ” Nonce 기반의 CSPλ₯Ό λ„μž…ν•˜μ—¬ λ°©μ–΄ 심측(Defense in Depth) λ³΄μ•ˆμ„ κ°•ν™”ν–ˆμŠ΅λ‹ˆλ‹€.

  1. java.security.SecureRandom을 ν™œμš©ν•˜μ—¬ 디렉토리가 처리될 λ•Œλ§ˆλ‹€ 16λ°”μ΄νŠΈ 길이의 동적인 랜덀 Nonce 값을 μƒμ„±ν•˜κ³ , Base64둜 μΈμ½”λ”©ν•©λ‹ˆλ‹€.
  2. <style> νƒœκ·Έμ— nonce="${nonce}" 속성을 μΆ”κ°€ν•˜μ—¬ ν•΄λ‹Ή μŠ€νƒ€μΌ 블둝이 μ•ˆμ „ν•¨μ„ μ„ μ–Έν•©λ‹ˆλ‹€.
  3. κΈ°μ‘΄ HTML μš”μ†Œ λ‚΄λΆ€μ˜ 인라인 style 속성듀을 μ œκ±°ν•˜κ³  .dir-link, .empty-dir 같은 CSS 클래슀둜 λŒ€μ²΄ν•˜μ—¬ 인라인 μŠ€νƒ€μΌ μ‚¬μš©μ„ μ›μ²œ μ°¨λ‹¨ν–ˆμŠ΅λ‹ˆλ‹€.
  4. Content-Security-Policy 메타 νƒœκ·Έμ˜ 섀정을 λ³€κ²½ν•˜μ—¬ 'unsafe-inline'을 μ œκ±°ν•˜κ³ , λ™μ μœΌλ‘œ μƒμ„±λœ 'nonce-...' κ°’λ§Œμ„ ν—ˆμš©ν•˜λ„λ‘ μˆ˜μ •ν–ˆμŠ΅λ‹ˆλ‹€.

βœ… 검증 μ™„λ£Œ (Verification)

  • Jacocoλ₯Ό μ΄μš©ν•œ ν…ŒμŠ€νŠΈ 컀버리지가 **100%**λ₯Ό μœ μ§€ν•˜λŠ”μ§€ 검증 μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€. (MainTest.kt ν…ŒμŠ€νŠΈ μ½”λ“œ λ‚΄ CSP κΈ°λŒ€ λ¬Έμžμ—΄ λ³€κ²½ μ™„λ£Œ)
  • Playwrightλ₯Ό μ‚¬μš©ν•΄ λ³€κ²½ ν›„ μƒμ„±λœ HTML UIκ°€ μ‹œκ°μ μœΌλ‘œ κΉ¨μ§€μ§€ μ•Šκ³  정상 λ Œλ”λ§ 됨을 μŠ€ν¬λ¦°μƒ·κ³Ό λΉ„λ””μ˜€λ₯Ό 톡해 κ²€μ¦ν•˜μ˜€μŠ΅λ‹ˆλ‹€.
  • Sentinel λ³΄μ•ˆ 저널(.jules/sentinel.md)에 ν•΄λ‹Ή 사항이 κΈ°λ‘λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

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

- μƒμ„±λœ `index.html` λ‚΄μ˜ 인라인 `style` 속성을 μ™ΈλΆ€ 클래슀(`.dir-link`, `.empty-dir`)둜 뢄리함
- `java.security.SecureRandom` 및 `Base64`λ₯Ό μ‚¬μš©ν•˜μ—¬ 16λ°”μ΄νŠΈ 동적 Nonceλ₯Ό μƒμ„±ν•˜κ³  `Content-Security-Policy` 헀더와 `<style>` νƒœκ·Έμ— μ μš©ν•¨
- 잠재적인 XSS 곡격 λ²‘ν„°λ‘œ μ•…μš©λ  수 μžˆλŠ” `style-src 'unsafe-inline'` 정책을 μ œκ±°ν•˜μ—¬ 정적 HTML λ Œλ”λ§ λ³΄μ•ˆμ„ 강화함
- κ΄€λ ¨ μœ λ‹› ν…ŒμŠ€νŠΈ(`MainTest.kt`)λ₯Ό μˆ˜μ •ν•˜μ—¬ λ³€κ²½λœ CSP κ·œμΉ™μ΄ 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.

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