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.
Published: 2026-07-31
Score: 9.3 Critical
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

A flaw in the import_module_class helper in the sentence-transformers library bypasses the trust_remote_code guard when the supplied model path exists locally. The guard condition includes an unnecessary or os.path.exists clause, allowing a local attacker to place malicious Python modules referenced in modules.json. When the SentenceTransformer constructor is invoked with trust_remote_code=False, these modules are imported at load time, resulting in arbitrary code execution in the application's process space. The vulnerability is associated with both CWE‑94, a code injection issue, and CWE‑454, a logic flaw that leads to unintended privilege escalation.

Affected Systems

All releases of Hugging Face's sentence‑transformers that contain the unpatched import_module_class implementation. Specific version numbers are not provided, but any version before the fix is vulnerable.

Risk and Exploitability

The CVSS score of 9.3 signals a high‑severity flaw involving a logic error (CWE‑454) and code injection (CWE‑94). The EPSS score of <1% indicates that the current exploitation probability is low, and the vulnerability is not listed in the CISA KEV catalog, suggesting no widespread exploitation campaigns yet. Based on the description, it is inferred that the primary attack vector is local filesystem; an attacker must control or influence the contents of a model directory on disk. Based on the description, it is also inferred that the potential for remote code execution exists if an application loads user‑supplied model directories from untrusted sources. The vulnerability can be exploited by dropping malicious Python files into a model folder and loading that model, causing the application to execute those files at import time.

Generated by OpenCVE AI on August 7, 2026 at 02:09 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade sentence‑transformers to a version that includes the security fix, such as the commit referenced in the advisory.
  • If upgrading is not feasible, locate all model directories in a read‑only or otherwise restricted environment so that malicious modules cannot be written or executed by an attacker.
  • Validate that any supplied model path originates from a trusted source and does not contain custom Python modules; reject or ignore models that do.

Generated by OpenCVE AI on August 7, 2026 at 02:09 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Fri, 14 Aug 2026 17:15:00 +0000

Type Values Removed Values Added
CPEs cpe:2.3:a:huggingface:transformers:*:*:*:*:*:*:*:*

Fri, 07 Aug 2026 00:15:00 +0000

Type Values Removed Values Added
Weaknesses CWE-454
References
Metrics threat_severity

None

threat_severity

Important


Mon, 03 Aug 2026 19:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'poc', 'Technical Impact': 'total'}, 'version': '2.0.3'}


Sun, 02 Aug 2026 19:30:00 +0000

Type Values Removed Values Added
First Time appeared Huggingface
Huggingface transformers
Vendors & Products Huggingface
Huggingface transformers

Fri, 31 Jul 2026 21:15:00 +0000

Type Values Removed Values Added
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.
Title sentence-transformers Arbitrary Code Execution on Local Model Load Despite trust_remote_code=False
Weaknesses CWE-94
References
Metrics cvssV3_1

{'score': 9.8, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H'}

cvssV4_0

{'score': 9.3, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N'}


Subscriptions

Huggingface Transformers
cve-icon MITRE

Status: PUBLISHED

Assigner: VulnCheck

Published:

Updated: 2026-08-14T16:51:09.552Z

Reserved: 2026-07-31T16:10:55.448Z

Link: CVE-2026-68770

cve-icon Vulnrichment

Updated: 2026-08-03T18:15:23.616Z

cve-icon NVD

Status : Received

Published: 2026-07-31T21:17:32.440

Modified: 2026-08-03T19:16:53.307

Link: CVE-2026-68770

cve-icon Redhat

Severity : Important

Publid Date: 2026-07-31T20:56:06Z

Links: CVE-2026-68770 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-08-07T02:15:04Z

Weaknesses
  • CWE-454

    External Initialization of Trusted Variables or Data Stores

  • CWE-94

    Improper Control of Generation of Code ('Code Injection')