PYSEC-2026-4174

See a problem?
Import Source
https://github.com/pypa/advisory-database/blob/main/vulns/transformers/PYSEC-2026-4174.yaml
JSON Data
https://api.osv.dev/v1/vulns/PYSEC-2026-4174
Aliases
Published
2026-10-01T16:38:29Z
Modified
2026-10-01T17:45:18Z
Severity
  • 7.8 (High) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H CVSS Calculator
Summary
Hugging Face Transformers downloads custom generation code before trust consent
Details

A vulnerability in Hugging Face Transformers (versions 4.49.0, <= 5.8.1) allows remote Python files to be written to local disk without user consent when using GenerativePreTrainedModel.load_custom_generate(). The function fetches and caches a remote module file before performing the required trust_remote_code consent check, inverting the security model enforced by other code-loading paths (such as AutoConfig, AutoModel, and AutoTokenizer). As a result, attacker‑controlled Python code from custom_generate/generate.py is copied into the user’s ~/.cache/huggingface/modules directory even if the user declines the trust prompt. Although execution is correctly gated, the file write is not reversible and can persist across sessions. This can lead to persistent, unauthorized files on disk and stale cache collisions where cached attacker code may later be executed during trusted model loads. The issue stems from an unconditional file write in dynamic_module_utils.py prior to any trust verification.

References

Affected packages

PyPI / transformers

Package

Name
transformers
View open source insights on deps.dev
Purl
pkg:pypi/transformers

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.49.0
Last Affected
5.8.1

Affected versions

4.*
4.49.0
4.50.0
4.50.1
4.50.2
4.50.3
4.51.0
4.51.1
4.51.2
4.51.3
4.52.0
4.52.1
4.52.2
4.52.3
4.52.4
4.53.0
4.53.1
4.53.2
4.53.3
4.54.0
4.54.1
4.55.0
4.55.1
4.55.2
4.55.3
4.55.4
4.56.0
4.56.1
4.56.2
4.57.0
4.57.1
4.57.2
4.57.3
4.57.4
4.57.5
4.57.6
5.*
5.0.0rc0
5.0.0rc1
5.0.0rc2
5.0.0rc3
5.0.0
5.1.0
5.2.0
5.3.0
5.4.0
5.5.0
5.5.1
5.5.2
5.5.3
5.5.4
5.6.0
5.6.1
5.6.2
5.7.0
5.8.0
5.8.1

Database specific

source
"https://github.com/pypa/advisory-database/blob/main/vulns/transformers/PYSEC-2026-4174.yaml"