CVE-2026-5241: huggingface/transformers: Arbitrary Code Execution During Model Initialization in the LightGlue Model Loading Path
In huggingface/transformers 5.2.0, loading a LightGlue model from an attacker-controlled repository can run the attacker's Python code, even when you pass `trust_remote_code=False`. The LightGlue config trusts a flag inside the repository's own `config.json`. The advisory lists versions before 5.5.0 as vulnerable and 5.5.0 as the fix.
Published Jun 3, 2026 · Updated Jul 21, 2026 · Analysis Oct 26, 2026
What an attacker can do
trust_remote_code=False is the guard that stops a model repo from running its own Python. In the LightGlue path it fails. LightGlueConfig reads a trust_remote_code value from the untrusted config.json and passes it into nested AutoConfig.from_pretrained() calls. A repo that sets it to true gets its Python modules loaded and run during AutoModel.from_pretrained() (CWE-829).
The attacker needs the victim to load a model from a repository the attacker controls. That is the user interaction in the CVSS vector. High attack complexity reflects that need. Nothing else is required, and the victim does not opt in to remote code.
The advisory names API inference servers, research notebooks, CI/CD pipelines and model evaluation workers as high-risk places. Code runs with the loader's privileges, so the outcomes it lists are credential theft, lateral movement and persistence or backdoors. Pipelines that pull community models by name and rely on trust_remote_code=False as their safety check are the most exposed.
Who is affected
The transformers package on PyPI. The description names 5.2.0; the package data marks everything before 5.5.0 as vulnerable. The flaw is in the LightGlue loading path, so it matters when you load LightGlue models or models from untrusted repos. Check your version:
pip show transformersSearch your code and pipelines for from_pretrained calls that take a model name from user input or an untrusted list.
transformers
- Ecosystem
- PyPI
- Affected
- < 5.5.0
- Fixed in
- 5.5.0
- Check
pip show transformers
How to fix it
Upgrade to transformers 5.5.0:
pip install --upgrade 'transformers>=5.5.0'The fix is commit 676559d, "Remove remote code execution". It removes the trust_remote_code field from LightGlueConfig. The config now always builds the keypoint detector config from CONFIG_MAPPING, so a detector type that is not registered fails at the lookup instead of loading remote code. The commit also adds lint rule TRF014 to flag trust_remote_code in native model integrations.
The sources give no workaround. Until you upgrade, load models only from repositories you trust and pin the revision.
How to tell if you were hit
The sources give no indicators. Review which model repositories your jobs loaded, especially LightGlue repos or any you do not own. Inspect their config.json for a trust_remote_code key set to true, and look for Python files in the repo that the loader could import. Look for unexpected child processes or outbound connections from inference servers, notebooks and CI workers right after a model load.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
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.
Questions
- Does trust_remote_code=False protect me on 5.2.0?
Not in the LightGlue path. The config reads the flag from the repository's
config.jsonand passes it to nestedAutoConfig.from_pretrained()calls, overriding your setting.- Which version fixes CVE-2026-5241?
transformers 5.5.0. The package data lists all versions before it as vulnerable.
- Is user interaction needed?
Yes. Someone or something has to load a model from the attacker's repository, for example a notebook or pipeline that takes a model name from outside.
- Is it exploited in the wild?
The sources do not say so, and there is no CISA KEV flag. The EPSS score is 0.006.
References
Read for this analysis:
- https://github.com/advisories/GHSA-fgcw-684q-jj6r
- https://github.com/huggingface/transformers/commit/676559d5022b74aaa0cee1cee0842b7f27c5320e
- https://nvd.nist.gov/vuln/detail/CVE-2026-5241
- https://huntr.com/bounties/ceb3ce1a-4c45-497a-b25e-cb9a7685e619
- https://access.redhat.com/security/cve/CVE-2026-5241
- https://bugzilla.redhat.com/show_bug.cgi?id=2484384
- https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-5241.json
- https://access.redhat.com/errata/RHSA-2026:34456
- https://access.redhat.com/errata/RHSA-2026:37275
- https://github.com/pypa/advisory-database/tree/main/vulns/transformers/PYSEC-2026-2290.yaml
- https://access.redhat.com/errata/RHSA-2026:42644
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Transformers vulnerabilities
All Transformers entriesCVE-2026-80047
Hugging Face Transformers downloads custom generation code before trust consent
high7.8No fixSep 1, 2026CVE-2026-9856
Transformers save_pretrained path traversal allows arbitrary file writes through chat template names
high7.1Aug 2, 2026CVE-2026-4372
HuggingFace transformers vulnerable to remote code execution
high7.8May 26, 2026CVE-2026-1839
HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class
medium6.5Apr 7, 2026CVE-2025-6921
Hugging Face Transformers vulnerable to Regular Expression Denial of Service (ReDoS) in the AdamWeightDecay optimizer
medium5.3Sep 23, 2025CVE-2025-6051
Hugging Face Transformers library has Regular Expression Denial of Service
medium5.3Sep 14, 2025
