From 4140b3e1a92a6fa552551252c9728f21acfd7782 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Mon, 27 Jul 2026 19:00:51 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[HIGH]=20JS?= =?UTF-8?q?ON=20DoS=20=EC=B7=A8=EC=95=BD=EC=A0=90=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit python/fast_mlsirm/report.py에서 파일 내용을 읽어들여 크기나 깊이에 대한 제한 없이 json.loads()를 수행하는 문제를 수정했습니다. 이를 _load_json_bounded를 사용하도록 대체하여 보안성을 강화했습니다. --- .jules/sentinel.md | 5 +++++ python/fast_mlsirm/report.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index 0b0e3ab9d..c25d8caf9 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -22,3 +22,8 @@ Explicitly defining `allow_pickle=False` is a robust defense-in-depth practice. **Vulnerability:** MD5 hashing in `fast_mlsirm/report.py` triggered a high severity warning by Bandit, because by default it is assumed to be used for security purposes which is unsafe due to weak hashing. **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). + +## 2026-07-23 - [Denial of Service via Unbounded JSON Parsing] +**Vulnerability:** In `fast_mlsirm/report.py`, `json.loads` was used to directly parse the contents of a file without any byte-size or nesting constraints, creating an insecure deserialization path for a DoS attack. +**Learning:** Always use bounds-checking when deserializing JSON. This prevents a maliciously crafted JSON file from exhausting memory or forcing recursive evaluation that crashes the application. +**Prevention:** Use the `_load_json_bounded` utility in `fast_mlsirm.io` instead of direct `json.loads(file.read_text())` for safely processing input JSON files. diff --git a/python/fast_mlsirm/report.py b/python/fast_mlsirm/report.py index 30ee4276b..66d9eab9c 100644 --- a/python/fast_mlsirm/report.py +++ b/python/fast_mlsirm/report.py @@ -1,8 +1,8 @@ from __future__ import annotations import hashlib -import json import math +from .io import _load_json_bounded from html import escape from pathlib import Path from typing import Any @@ -17,7 +17,7 @@ def render_diagnostics_report( """Render saved diagnostics JSON as a standalone HTML report.""" source = Path(diagnostics_path) - payload = json.loads(source.read_text(encoding="utf-8")) + payload = _load_json_bounded(source, source="diagnostics JSON") if not isinstance(payload, dict): raise ValueError("diagnostics JSON must contain an object")