monai broken cryptography
Description
F007 — monai/data/utils.py cache uses pickle + MD5 hashing
| ID | securin0days-MONAI-F007 |
| Severity | MEDIUM |
| CVSSv3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H — Base 7.8 |
| CWE | CWE-502 + CWE-327 |
Sinks
monai/data/utils.py:1372,1393,1396 (semgrep flagged):
- L1372 —
hashlib.md5(...)used as a content-addressed cache key (collision risk; not integrity-critical here, but should still be SHA-256). - L1393 —
pickle.loads(...)of cached data. - L1396 — additional pickle path.
monai/data/dataset.py:295-301, 399 (Phase 3 loop walk):
if track_meta and weights_only:
raise ValueError(
"Invalid argument combination: `track_meta=True` cannot be used with `weights_only=True`. "
"To cache and reload MetaTensors, set `track_meta=True` and `weights_only=False`."
)
self.track_meta = track_meta
self.weights_only = weights_only
…
return torch.load(hashfile, weights_only=self.weights_only) # L399PersistentDataset forces the user into weights_only=False to cache MetaTensors (the default tensor type in MONAI ≥1.0). The downstream torch.load(hashfile, weights_only=False) then unpickles whatever is in the cache directory. Combined with a shared cache_dir (HPC scratch, /tmp/monai_cache, etc.), any local user who can write to the cache dir gains code execution in every other user's MONAI process.
Risk
If an attacker can write to the cache directory (often ~/.cache/monai/ or /tmp/), they can drop a malicious pickle that the next pipeline run will deserialize. Combined with shared/world-writable cache dirs (common in HPC clusters), this is a privilege-escalation vector.
Recommended fix
- Replace
hashlib.md5withhashlib.sha256. - Switch cache serialization to
numpy.savez_compressed/torch.save(..., weights_only=True)/ JSON depending on payload. - Enforce permission 0700 on the cache directory at create time.
Regression check
N/A — no git history.
---
Reporter
Submitted via SecurinDisclose. Coordinated-disclosure window: 90 days from 2026-05-29 (public disclosure target 2026-08-27).