CVE Vulnerabilities

CVE-2026-1839

Deserialization of Untrusted Data

Published: Apr 07, 2026 | Modified: Apr 28, 2026
CVSS 3.x
7.8
HIGH
Source:
NVD
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
CVSS 2.x
RedHat/V2
RedHat/V3
6.7 MODERATE
CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H
Ubuntu
root.io logo minimus.io logo echo.ai logo

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.

Weakness

The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.

Affected Software

NameVendorStart VersionEnd Version
TransformersHuggingface*5.0.0 (excluding)
TransformersHuggingface5.0.0-rc0 (including)5.0.0-rc0 (including)
TransformersHuggingface5.0.0-rc1 (including)5.0.0-rc1 (including)
TransformersHuggingface5.0.0-rc2 (including)5.0.0-rc2 (including)

Potential Mitigations

  • Make fields transient to protect them from deserialization.
  • An attempt to serialize and then deserialize a class containing transient fields will result in NULLs where the transient data should be. This is an excellent way to prevent time, environment-based, or sensitive variables from being carried over and used improperly.

References