CVE-2026-68770: Improper Control of Generation of Code ('Code Injection') in Hugging Face sentence-transformers
A critical code injection vulnerability exists in the Hugging Face sentence-transformers library due to improper control in the import_module_class helper. This flaw allows attackers to bypass the trust_remote_code=False security setting by exploiting a logic condition that trusts any existing local model path. Malicious Python files placed in a model directory can be executed during model loading, leading to arbitrary code execution. No patch or official remediation guidance is currently provided.
AI Analysis
Technical Summary
CVE-2026-68770 describes a security control bypass vulnerability in the Hugging Face sentence-transformers library. The issue arises from a logic flaw in the import_module_class helper function within sentence_transformers/util/misc.py. Specifically, the guard condition includes an 'or os.path.exists(model_name_or_path)' clause that causes the trust gate to be satisfied whenever the supplied model path exists locally, regardless of the trust_remote_code=False argument. Attackers who can influence the contents of a local model directory can place malicious Python files (e.g., modeling_*.py referenced via modules.json) that are imported and executed during model loading. This results in arbitrary code execution within the context of the application loading the model, violating the intended security restrictions.
Potential Impact
Successful exploitation allows an attacker with the ability to control or influence files in a local model directory to execute arbitrary Python code during model loading. This bypasses the documented security control that should prevent remote code execution when trust_remote_code is set to false. The vulnerability has a CVSS 4.0 score of 9.3 (critical), indicating high impact with network attack vector, no privileges required, and no user interaction needed.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until an official fix is released, users should avoid loading models from untrusted or user-controlled local directories with trust_remote_code set to false, as this setting is bypassed by the vulnerability. Monitor official Hugging Face communications for updates and apply any forthcoming patches promptly.
CVE-2026-68770: Improper Control of Generation of Code ('Code Injection') in Hugging Face sentence-transformers
Description
A critical code injection vulnerability exists in the Hugging Face sentence-transformers library due to improper control in the import_module_class helper. This flaw allows attackers to bypass the trust_remote_code=False security setting by exploiting a logic condition that trusts any existing local model path. Malicious Python files placed in a model directory can be executed during model loading, leading to arbitrary code execution. No patch or official remediation guidance is currently provided.
CVSS v4.0
Score 9.3critical
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
CVE-2026-68770 describes a security control bypass vulnerability in the Hugging Face sentence-transformers library. The issue arises from a logic flaw in the import_module_class helper function within sentence_transformers/util/misc.py. Specifically, the guard condition includes an 'or os.path.exists(model_name_or_path)' clause that causes the trust gate to be satisfied whenever the supplied model path exists locally, regardless of the trust_remote_code=False argument. Attackers who can influence the contents of a local model directory can place malicious Python files (e.g., modeling_*.py referenced via modules.json) that are imported and executed during model loading. This results in arbitrary code execution within the context of the application loading the model, violating the intended security restrictions.
Potential Impact
Successful exploitation allows an attacker with the ability to control or influence files in a local model directory to execute arbitrary Python code during model loading. This bypasses the documented security control that should prevent remote code execution when trust_remote_code is set to false. The vulnerability has a CVSS 4.0 score of 9.3 (critical), indicating high impact with network attack vector, no privileges required, and no user interaction needed.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until an official fix is released, users should avoid loading models from untrusted or user-controlled local directories with trust_remote_code set to false, as this setting is bypassed by the vulnerability. Monitor official Hugging Face communications for updates and apply any forthcoming patches promptly.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- VulnCheck
- Date Reserved
- 2026-07-31T16:10:55.448Z
- Cvss Version
- 4.0
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 6a6d131bbf32cb7a3452db5b
Added to database: 07/31/2026, 21:26:51 UTC
Last enriched: 07/31/2026, 21:33:41 UTC
Last updated: 07/31/2026, 21:57:04 UTC
Views: 3
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.