CVE-2026-1839: Transformers HuggingFace Transformers Allows For Arbitrary Vulnerability

MODERATE
Advisory Identifier: GHSA-69w3-r845-3855
CVSS 6.5
CWE-502
Published
Advisory Summary

CVE-2026-1839 is a MODERATE (CVSS 6.5) huggingface transformers allows for arbitrary vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Transformers libraries in the PyPI ecosystem. The issue involves huggingface transformers allows for arbitrary code execution in the `trainer` class. Remediation is available by upgrading affected packages to version 5.0.0rc3.

CVE-2026-1839 at a Glance

CVE Identifier CVE-2026-1839
GHSA Identifier GHSA-69w3-r845-3855
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Transformers
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:H).

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability High (A:H)

How to Fix CVE-2026-1839

To remediate this vulnerability, upgrade all affected Transformers dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

transformers fixed: 5.0.0rc3
pip install transformers>=5.0.0rc3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show transformers

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-1839, inspect your installed packages using pip:

pip show transformers

Analyze the terminal output to locate any version of Transformers in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.0.0rc3), your application is affected.

Note: The pip show transformers command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Transformers, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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.

CVE-2026-1839 Affected Transformers Versions

1 component(s)
Fixed Versions:
5.0.0rc3
Product / Package Ecosystem Affected Versions Fixed Version
transformers
PyPI
< 5.0.0rc3
5.0.0rc3

References

Frequently Asked Questions

What is CVE-2026-1839?
CVE-2026-1839 is a security vulnerability in Transformers involving HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class under CWE-502: Deserialization of Untrusted Data.
Which Transformers versions are affected?
Affected versions include releases prior to 5.0.0rc3 across affected packages: transformers.
What version fixes CVE-2026-1839?
Upgrading to 5.0.0rc3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is transformers affected?
Yes, transformers is affected in releases prior to 5.0.0rc3. Upgrade your dependency to 5.0.0rc3 or later.
What is the CVSS score of CVE-2026-1839?
CVE-2026-1839 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:H.
What CWE is associated with CVE-2026-1839?
CVE-2026-1839 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check PyPI dependencies for CVE-2026-1839?
Run the dependency tree command: 'pip show transformers'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-69w3-r845-3855",
  "modified" : "2026-04-08T00:17:56Z",
  "published" : "2026-04-07T06:30:28Z",
  "aliases" : [ "CVE-2026-1839" ],
  "summary" : "HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class",
  "details" : "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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:L/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "transformers"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.0.0rc3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-1839"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/transformers/commit/03c8082ba4594c9b8d6fe190ca9bed0e5f8ca396"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/huggingface/transformers"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/transformers/releases/tag/v5.0.0rc3"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.com/bounties/3c77bb97-e493-493d-9a88-c57f5c536485"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-08T00:17:56Z",
    "nvd_published_at" : "2026-04-07T06:16:41Z"
  }
}