Vulnerabilities in pkg:pypi/sentence-transformers

PACKAGE
Advisory Identifier: GHSA-jhr6-gm9c-rqjv
Advisory Summary

CVE-2026-68770 is a CRITICAL (CVSS 9.8) sentence-transformers local model loading bypasses vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Sentence transformers libraries in the PyPI ecosystem. The issue involves sentence-transformers local model loading bypasses trust_remote_code and executes custom python. Remediation is available by upgrading affected packages to version 5.6.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/sentence-transformers

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/sentence-transformers. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-jhr6-gm9c-rqjv CVE-2026-68770 CRITICAL sentence-transformers local model loading bypasses trust_remote_code and executes custom Python

CVE-2026-68770 at a Glance

CVE Identifier CVE-2026-68770
GHSA Identifier GHSA-jhr6-gm9c-rqjv
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Sentence transformers
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-68770

To remediate this vulnerability, upgrade all affected Sentence 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.

sentence-transformers fixed: 5.6.0
pip install sentence-transformers>=5.6.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show sentence-transformers

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-68770, inspect your installed packages using pip:

pip show sentence-transformers

Analyze the terminal output to locate any version of Sentence transformers in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.6.0), your application is affected.

Note: The pip show sentence-transformers command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Sentence 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

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.

CVE-2026-68770 Affected Sentence transformers Versions

1 component(s)
Fixed Versions:
5.6.0
Product / Package Ecosystem Affected Versions Fixed Version
sentence-transformers
PyPI
< 5.6.0
5.6.0

References

Frequently Asked Questions

What is CVE-2026-68770?
CVE-2026-68770 is a security vulnerability in Sentence transformers involving sentence-transformers local model loading bypasses trust_remote_code and executes custom Python under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Sentence transformers versions are affected?
Affected versions include releases prior to 5.6.0 across affected packages: sentence-transformers.
What version fixes CVE-2026-68770?
Upgrading to 5.6.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sentence-transformers affected?
Yes, sentence-transformers is affected in releases prior to 5.6.0. Upgrade your dependency to 5.6.0 or later.
What is the CVSS score of CVE-2026-68770?
CVE-2026-68770 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-68770?
CVE-2026-68770 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check PyPI dependencies for CVE-2026-68770?
Run the dependency tree command: 'pip show sentence-transformers'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-jhr6-gm9c-rqjv",
  "modified" : "2026-09-30T23:24:23Z",
  "published" : "2026-07-31T21:31:59Z",
  "aliases" : [ "CVE-2026-68770" ],
  "summary" : "sentence-transformers local model loading bypasses trust_remote_code and executes custom Python",
  "details" : "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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "sentence-transformers"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.6.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-68770"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/sentence-transformers/issues/3801"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/sentence-transformers/pull/3807"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/sentence-transformers/pull/3935"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/sentence-transformers/commit/626eb602b088878a8173bcab69225f68411b99e1"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/sentence-transformers/commit/ae1acc3fb2aa2004577b297eb4a915ce7a03316a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/huggingface/sentence-transformers"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/sentence-transformers/releases/tag/v5.6.0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/sentence-transformers/releases/tag/v6.0.0"
  }, {
    "type" : "WEB",
    "url" : "https://www.vulncheck.com/advisories/sentence-transformers-arbitrary-code-execution-on-local-model-load-despite-trust-remote-code-false"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-30T23:24:22Z",
    "nvd_published_at" : "2026-07-31T21:17:32Z"
  }
}