Skip to main content
← All vulnerabilities
CVE-2026-1839PYSEC-2026-2288GHSA-69W3-R845-3855

Arbitrary Code Execution via Unsafe torch.load() in Trainer Checkpoint Loading in huggingface/transformers

Published
Last modified
published
Not listed in CISA KEV
Fix
Fixed in v5.0.0rc3, 5.0.0, 5.0.0rc3
None on Exploit-DB, Metasploit or GitHub
  • Exploitation: poc
  • Automatable: no
  • Technical impact: total

Summary

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.

Timeline

  1. CVE published
  2. CISA SSVC assessment

    Exploitation: poc · Automatable: no · Technical impact: total

  3. Record last updated

Affected versions

  • huggingface huggingface/transformers

    fixed in v5.0.0rc3

  • transformersPyPI

    fixed in 5.0.0

  • transformersPyPI

    fixed in 5.0.0rc3

References 2

huntr.com

GitHub · huggingface/transformers