CVE-2026-68770: Improper Control of Generation of Code ('Code Injection') in Hugging Face sentence-transformers
sentence-transformers contains a security control bypass vulnerability that allows attackers to achieve arbitrary code execution by exploiting a logic flaw in the import_module_class helper within sentence_transformers/util/misc.py, where the guard condition includes an 'or os.path.exists(model_name_or_path)' clause that satisfies the trust gate whenever the supplied path exists on the local filesystem, regardless of the trust_remote_code=False argument. Attackers who can control or influence the contents of a model directory on disk can place malicious Python files such as modeling_*.py referenced via modules.json, causing the code to execute at import time when an application loads the model with SentenceTransformer(path, trust_remote_code=False), bypassing the documented security contract and achieving code execution within the loading process.
AI Analysis
Technical Summary
CVE-2026-68770 is a critical security control bypass vulnerability in the sentence-transformers library by Hugging Face. The vulnerability arises from a logic flaw in the import_module_class helper within sentence_transformers/util/misc.py. The guard condition improperly trusts any existing local path due to an 'or os.path.exists(model_name_or_path)' clause, ignoring the trust_remote_code=False argument. Consequently, attackers who can control or influence the contents of a model directory on disk can place malicious Python files (e.g., modeling_*.py referenced via modules.json). These files execute at import time when the application loads the model with SentenceTransformer(path, trust_remote_code=False), leading to arbitrary code execution and bypassing the documented security contract.
Potential Impact
An attacker able to control or influence the contents of a model directory on disk can achieve arbitrary code execution within the context of the application loading the model. This bypasses the trust_remote_code=False security setting, potentially allowing full compromise of the host running the vulnerable sentence-transformers library.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until an official fix is available, avoid loading models from untrusted or user-controlled directories. Do not rely solely on the trust_remote_code=False argument to prevent code execution from local model paths.
CVE-2026-68770: Improper Control of Generation of Code ('Code Injection') in Hugging Face sentence-transformers
Description
sentence-transformers contains a security control bypass vulnerability that allows attackers to achieve arbitrary code execution by exploiting a logic flaw in the import_module_class helper within sentence_transformers/util/misc.py, where the guard condition includes an 'or os.path.exists(model_name_or_path)' clause that satisfies the trust gate whenever the supplied path exists on the local filesystem, regardless of the trust_remote_code=False argument. Attackers who can control or influence the contents of a model directory on disk can place malicious Python files such as modeling_*.py referenced via modules.json, causing the code to execute at import time when an application loads the model with SentenceTransformer(path, trust_remote_code=False), bypassing the documented security contract and achieving code execution within the loading process.
CVSS v4.0
Score 9.3critical
Affected software
Hugging Face
sentence-transformers
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 is a critical security control bypass vulnerability in the sentence-transformers library by Hugging Face. The vulnerability arises from a logic flaw in the import_module_class helper within sentence_transformers/util/misc.py. The guard condition improperly trusts any existing local path due to an 'or os.path.exists(model_name_or_path)' clause, ignoring the trust_remote_code=False argument. Consequently, attackers who can control or influence the contents of a model directory on disk can place malicious Python files (e.g., modeling_*.py referenced via modules.json). These files execute at import time when the application loads the model with SentenceTransformer(path, trust_remote_code=False), leading to arbitrary code execution and bypassing the documented security contract.
Potential Impact
An attacker able to control or influence the contents of a model directory on disk can achieve arbitrary code execution within the context of the application loading the model. This bypasses the trust_remote_code=False security setting, potentially allowing full compromise of the host running the vulnerable sentence-transformers library.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until an official fix is available, avoid loading models from untrusted or user-controlled directories. Do not rely solely on the trust_remote_code=False argument to prevent code execution from local model paths.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- VulnCheck
- Date Reserved
- 2026-07-31T16:10:55.448Z
- Cvss Version
- 4.0
- State
- PUBLISHED
Threat ID: 6a6d131bbf32cb7a3452db5b
Added to database: 07/31/2026, 21:26:51 UTC
Last enriched: 08/16/2026, 13:43:29 UTC
Last updated: 09/14/2026, 10:01:32 UTC
Views: 104
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.