Last seen April 7, 2026

PyTorch Remote Code Execution Vulnerability

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.

Technical Severity
Medium severity
Lifecycle Status

RESOLVED

What Happened

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.

Why This Matters

Publisher reporting describes a security event affecting line. BugSkan could not yet bind a CVE or affected version, so treat the source details as the current record.

Recommended Action

resolved in version v5.0.0rc3 Confirm whether PyTorch is present in your environment and review the affected configuration.

Exposure

My Interests Exposure

Exposure unknown

Recommended Response
Last Seen

Apr 07, 2026 12:00

Exposure reason: This incident does not currently match a technology in My Interests.

Exploitation status: THEORETICAL

Primary entities:

HuggingFacePyTorchtransformersRemote Code ExecutionvulnerabilityHuggingFace Transformers

Timeline

  • Incident first seen
    Apr 07, 2026 12:00

    BugSkan first recorded this incident.

  • HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class
    Apr 07, 2026 12:00

    GitHub Advisory Database ยท Vulnerability

  • HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class
    Apr 07, 2026 12:00

    OSV.dev ยท Vulnerability

Sources

HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class

GitHub Advisory Database ยท Apr 07, 2026 12:00

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.

Open publisher source
HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class

OSV.dev ยท Apr 07, 2026 12:00

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.

Open publisher source

Other BugSkan incidents that share identifiers, products, or vendors with this report.

My Interests Match

Want personalized relevance?

Create an account to see which incidents overlap with your interests.

โ† Back to incident intelligence