CVE-2026-5241: huggingface/transformers Arbitrary Code Execution During Model Vulnerability
HIGHCVE-2026-5241 is a HIGH (CVSS 8.0) arbitrary code execution during model vulnerability (CWE-829: Inclusion of Functionality from Untrusted Control Sphere) affecting huggingface/transformers libraries in the PyPI ecosystem. The issue involves arbitrary code execution during model initialization in the lightglue model loading path. Remediation is available by upgrading affected packages to version 5.5.0.
CVE-2026-5241 at a Glance
Security Impact
CVSS: 8.0
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:N).
How to Fix CVE-2026-5241
To remediate this vulnerability, upgrade all affected huggingface/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.
pip install transformers>=5.5.0
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-5241, inspect your installed packages using pip:
pip show transformers
Analyze the terminal output to locate any version of huggingface/transformers in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.5.0), 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-829: Inclusion of Functionality from Untrusted Control Sphere, where the product imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere. In huggingface/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
CVE-2026-5241 Affected huggingface/transformers Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
transformers
|
PyPI |
< 5.5.0
|
5.5.0
|
References
Frequently Asked Questions
What is CVE-2026-5241?
Which huggingface/transformers versions are affected?
What version fixes CVE-2026-5241?
Is transformers affected?
What is the CVSS score of CVE-2026-5241?
What CWE is associated with CVE-2026-5241?
How can I check PyPI dependencies for CVE-2026-5241?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-fgcw-684q-jj6r",
"modified" : "2026-07-21T12:33:26Z",
"published" : "2026-06-03T15:30:43Z",
"aliases" : [ "CVE-2026-5241" ],
"summary" : "huggingface/transformers: Arbitrary Code Execution During Model Initialization in the LightGlue Model Loading Path",
"details" : "A vulnerability in the LightGlue model loading path of huggingface/transformers version 5.2.0 allows an attacker-controlled model repository to execute arbitrary code during model initialization. The issue arises because the `trust_remote_code` parameter, intended to prevent remote code execution, is overridden by untrusted serialized configuration data in a nested code path. Specifically, when loading a LightGlue model using `AutoModel.from_pretrained()` with `trust_remote_code=False`, the `LightGlueConfig` reads the `trust_remote_code` value from the untrusted `config.json` file and propagates it into nested `AutoConfig.from_pretrained()` calls. This results in the execution of attacker-provided Python modules, even when the victim explicitly disables remote code execution. The vulnerability poses a high risk for environments such as API inference servers, research notebooks, CI/CD pipelines, and model evaluation workers, potentially leading to credential theft, lateral movement, or persistence/backdoor deployment.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.0/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "transformers"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "5.5.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-5241"
}, {
"type" : "WEB",
"url" : "https://github.com/huggingface/transformers/commit/676559d5022b74aaa0cee1cee0842b7f27c5320e"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/errata/RHSA-2026:34456"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/errata/RHSA-2026:37275"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/errata/RHSA-2026:42644"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/security/cve/CVE-2026-5241"
}, {
"type" : "WEB",
"url" : "https://bugzilla.redhat.com/show_bug.cgi?id=2484384"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/huggingface/transformers"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/transformers/PYSEC-2026-2290.yaml"
}, {
"type" : "WEB",
"url" : "https://huntr.com/bounties/ceb3ce1a-4c45-497a-b25e-cb9a7685e619"
}, {
"type" : "WEB",
"url" : "https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-5241.json"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-829" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-07-13T17:25:18Z",
"nvd_published_at" : "2026-06-03T14:16:46Z"
}
}