Skip to content

πŸ›‘οΈ Sentinel: [MEDIUM] Fix DoS vulnerability in render_diagnostics_report - #264

Closed
seonghobae wants to merge 1 commit into
mainfrom
sentinel-json-dos-fix-7868236832688815057
Closed

πŸ›‘οΈ Sentinel: [MEDIUM] Fix DoS vulnerability in render_diagnostics_report#264
seonghobae wants to merge 1 commit into
mainfrom
sentinel-json-dos-fix-7868236832688815057

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

🚨 Severity: MEDIUM

πŸ’‘ Vulnerability: python/fast_mlsirm/report.py의 render_diagnostics_report ν•¨μˆ˜κ°€ 진단 κ²°κ³Ό JSON νŒŒμΌμ„ νŒŒμ‹±ν•  λ•Œ ν¬κΈ°λ‚˜ 쀑첩 κΉŠμ΄μ— μ œν•œμ΄ μ—†λŠ” λ‚΄μž₯ json.loads와 Path.read_text()λ₯Ό μ‚¬μš©ν•˜κ³  μžˆμ—ˆμŠ΅λ‹ˆλ‹€.

🎯 Impact: μ•…μ˜μ μœΌλ‘œ μ‘°μž‘λœ 깊게 μ€‘μ²©λœ JSON λ°°μ—΄/객체 λ˜λŠ” 맀우 큰 크기의 JSON νŒŒμΌμ„ 전달받을 경우 RecursionErrorκ°€ λ°œμƒν•˜κ±°λ‚˜ OOM(Out of Memory)으둜 인해 ν”„λ‘œμ„ΈμŠ€κ°€ κ°•μ œ μ’…λ£Œλ˜λŠ” μ„œλΉ„μŠ€ κ±°λΆ€(DoS) 곡격에 μ·¨μ•½ν–ˆμŠ΅λ‹ˆλ‹€.

πŸ”§ Fix: json.loads(source.read_text()) ν˜ΈμΆœμ„ ν”„λ‘œμ νŠΈ λ‚΄μ˜ μ•ˆμ „ν•œ μœ ν‹Έλ¦¬ν‹°μΈ _load_json_bounded(source, source='diagnostics JSON') 호좜둜 κ΅μ²΄ν•˜μ—¬ μž…λ ₯ λ°”μ΄νŠΈ μ œν•œκ³Ό 쀑첩 깊이 μ œν•œμ„ κ°•μ œν–ˆμŠ΅λ‹ˆλ‹€. 이 κ³Όμ •μ—μ„œ μ‚¬μš©λ˜μ§€ μ•Šκ²Œ 된 json importλ₯Ό μ œκ±°ν•˜κ³  μ½”λ“œ μ„œμ‹μ„ ν¬λ§·νŒ…ν–ˆμŠ΅λ‹ˆλ‹€.

βœ… Verification:

  • ν¬λ§·νŒ…(ruff format) 및 정적 뢄석(ruff check)을 μˆ˜ν–‰ν–ˆμŠ΅λ‹ˆλ‹€.
  • Python ν…ŒμŠ€νŠΈ(uv run pytest tests)λ₯Ό λͺ¨λ‘ ν†΅κ³Όν–ˆμŠ΅λ‹ˆλ‹€.
  • json.loads λŒ€μ‹  _load_json_boundedλ₯Ό μ‚¬μš©ν•˜μ—¬ 깊게 μ€‘μ²©λœ 배열을 μž…λ ₯ν–ˆμ„ λ•Œ, ValueError (exceeds the maximum JSON nesting depth) λ“± 사전에 μ„€κ³„λœ μ œμ–΄λœ μ—λŸ¬λ‘œ μ²˜λ¦¬λ¨μ„ μˆ˜λ™ 검증 슀크립트둜 ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€.

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

Switched from `json.loads` to `_load_json_bounded` to prevent
Denial of Service attacks from deeply nested or overly large JSON files.
@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 25, 2026 19:20

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 render_diagnostics_report against JSON parsing DoS by replacing unbounded file reads and json.loads with the project’s bounded JSON loader, aligning report rendering with existing defensive IO utilities.

Changes:

  • Replaced json.loads(Path.read_text()) with _load_json_bounded(...) to enforce input byte limits and JSON nesting depth limits.
  • Removed the now-unused json import and adjusted imports accordingly.
  • Documented the JSON parsing DoS learning/prevention in .jules/sentinel.md.

Reviewed changes

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

File Description
python/fast_mlsirm/report.py Switches diagnostics JSON loading to _load_json_bounded to prevent memory/recursion DoS during report rendering.
.jules/sentinel.md Adds a Sentinel entry documenting the JSON parsing DoS vector and the preferred bounded loader.

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

Comment thread .jules/sentinel.md
**Learning:** For non-security purposes like generating unique dom ids, `hashlib.md5()` triggers a vulnerability warning unless `usedforsecurity=False` is passed. This allows bypassing FIPS compliance limitations as well as suppressing false positive warnings.
**Prevention:** Always add `usedforsecurity=False` parameter to `hashlib.md5` and other weak hashing functions unless they are genuinely used for secure cryptography (which they shouldn't be).

## 2024-07-25 - [JSON Parsing DoS via Unbounded Recursion/Memory Allocation]
@seonghobae
seonghobae enabled auto-merge (squash) July 26, 2026 09:07
@opencode-agent
opencode-agent Bot disabled auto-merge July 26, 2026 09:44

Copy link
Copy Markdown
Contributor Author

쀑볡 정리: render_diagnostics_report의 λ¬΄μ œν•œ JSON λ‘œλ”© DoS 취약점 μˆ˜μ •μœΌλ‘œ, 리뷰 λŒ€κΈ° 쀑인 #203(16 MiB μ†ŒμŠ€ λ°”μš΄λ“œ + ν–‰/μ§€ν‘œ materialization μ œν•œ, Strix vuln-0001 λŒ€μ‘)κ³Ό 동일 λŒ€μƒΒ·λ™μΌ μ·¨μ§€μž…λ‹ˆλ‹€. #203 을 λŒ€ν‘œλ‘œ 남기고 λ‹«μŠ΅λ‹ˆλ‹€. ν•„μš” μ‹œ μž¬μ˜€ν”ˆ κ°€λŠ₯ν•©λ‹ˆλ‹€.


Generated by Claude Code

@google-labs-jules

Copy link
Copy Markdown

쀑볡 정리: render_diagnostics_report의 λ¬΄μ œν•œ JSON λ‘œλ”© DoS 취약점 μˆ˜μ •μœΌλ‘œ, 리뷰 λŒ€κΈ° 쀑인 #203(16 MiB μ†ŒμŠ€ λ°”μš΄λ“œ + ν–‰/μ§€ν‘œ materialization μ œν•œ, Strix vuln-0001 λŒ€μ‘)κ³Ό 동일 λŒ€μƒΒ·λ™μΌ μ·¨μ§€μž…λ‹ˆλ‹€. #203 을 λŒ€ν‘œλ‘œ 남기고 λ‹«μŠ΅λ‹ˆλ‹€. ν•„μš” μ‹œ μž¬μ˜€ν”ˆ κ°€λŠ₯ν•©λ‹ˆλ‹€.


Generated by Claude Code

Understood. Acknowledging that this work is a duplicate of PR #203 and stopping work on this task.

@seonghobae seonghobae closed this Jul 29, 2026
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