What’s Vulnerable › Vulnerabilities
CVE-2026-1839: Arbitrary Code Execution via Unsafe torch.load() in Trainer Checkpoint Loading in huggingface/transformers
- Severity: high (CVSS 7.8 v3.1)
- Exploited in the wild: not listed in CISA KEV
- EPSS: 0.4% probability of exploitation in the next 30 days
- Public exploit or detection template: yes
- Published: 2026-04-07 · updated 2026-10-26
- Weakness: CWE-502
Description
A vulnerability in the HuggingFace Transformers library, specifically in the `Trainer` class, allows for arbitrary code execution. The `_load_rng_state()` method in `src/transformers/trainer.py` at line 3059 calls `torch.load()` without the `weights_only=True` parameter. This issue affects all versions of the library supporting `torch>=2.2` when used with PyTorch versions below 2.6, as the `safe_globals()` context manager provides no protection in these versions. An attacker can exploit this vulnerability by supplying a malicious checkpoint file, such as `rng_state.pth`, which can execute arbitrary code when loaded. The issue is resolved in version v5.0.0rc3.
Affected products
- huggingface/transformers: before 5.0.0; 5.0.0-rc0, 5.0.0-rc1, 5.0.0-rc2 — fixed in 5.0.0
How to fix
Upgrade to a fixed version: huggingface/transformers 5.0.0. Check the vendor advisory for mitigations.
References
- https://github.com/huggingface/transformers/commit/03c8082ba4594c9b8d6fe190ca9bed0e5f8ca396
- https://huntr.com/bounties/3c77bb97-e493-493d-9a88-c57f5c536485
- https://huntr.com/bounties/3c77bb97-e493-493d-9a88-c57f5c536485
Get alerted when CVE-2026-1839 or the next vulnerability affects your stack