Arbitrary Code Execution via Unsafe torch.load() in Trainer Checkpoint Loading in huggingface/transformers
Summary
| CVE | CVE-2026-1839 |
|---|---|
| State | PUBLISHED |
| Assigner | @huntr_ai |
| Source Priority | CVE Program / NVD first with legacy fallback |
| Published | 2026-04-07 06:16:41 UTC |
| Updated | 2026-04-07 14:16:18 UTC |
| 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. |
Risk And Classification
Primary CVSS: v3.0 6.5 MEDIUM from [email protected]
CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:H
EPSS: 0.000200000 probability, percentile 0.052420000 (date 2026-04-07)
Problem Types: CWE-502 | CWE-502 CWE-502 Deserialization of Untrusted Data
| Version | Source | Type | Score | Severity | Vector |
|---|---|---|---|---|---|
| 3.0 | [email protected] | Secondary | 6.5 | MEDIUM | CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:H |
| 3.0 | CNA | DECLARED | 6.5 | MEDIUM | CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:H |
CVSS v3.0 Breakdown
Attack Vector
LocalAttack Complexity
HighPrivileges Required
NoneUser Interaction
RequiredScope
UnchangedConfidentiality
HighIntegrity
LowAvailability
HighCVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:H
Vendor Declared Affected Products
| Source | Vendor | Product | Version | Platforms |
|---|---|---|---|---|
| CNA | Huggingface | Huggingface/transformers | affected unspecified v5.0.0rc3 custom | Not specified |
References
| Reference | Source | Link | Tags |
|---|---|---|---|
| github.com/huggingface/transformers/commit/03c8082ba4594c9b8d6fe190ca9be... | [email protected] | github.com | |
| huntr.com/bounties/3c77bb97-e493-493d-9a88-c57f5c536485 | 134c704f-9b21-4f2e-91b3-4a467353bcc0 | huntr.com | |
| CVE Program record | CVE.ORG | www.cve.org | canonical |
| NVD vulnerability detail | NVD | nvd.nist.gov | canonical, analysis |
No vendor comments have been submitted for this CVE.
There are currently no legacy QID mappings associated with this CVE.