# CVE-2026-68770: Hugging Face sentence-transformers code execution via trust_remote_code bypass

Source: https://junglewise.ai/threats/cve-2026-68770-hugging-face-sentence-transformers-code-execution-via-trust  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-31. Updated: 2026-07-31  
License: CC BY 4.0 with a link back

CVE-2026-68770 · Severity: critical · CVSS 9.8 · Published 2026-07-31

Hugging Face sentence-transformers, a popular library for generating AI text embeddings, contains a security flaw that allows for arbitrary code execution. The library is designed to block untrusted code from running unless specifically permitted by the user; however, a logic error causes it to automatically trust and execute any code found within a model directory if that directory exists on the local disk. An attacker who can influence the contents of a model folder (e.g., through a shared drive, a downloaded archive, or a model registration API) can execute malicious commands on the underlying system when the application attempts to load the model.

Vendors: [Hugging Face](https://junglewise.ai/threats/vendors/hugging-face), [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2026-68770 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-68770 being exploited in the wild.

**How severe is CVE-2026-68770?** Critical severity, with a CVSS score of 9.8, published 31 July 2026.

**Which products and versions are affected?** Hugging Face Sentence-Transformers <= 5.5.1; sentence-transformers (PyPI) < 5.6.0, ECOSYSTEM:introduced=0,fixed=5.6.0.

**Is there a fix for CVE-2026-68770?** Yes. sentence-transformers (PyPI): upgrade to 5.6.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-68770 attacked?** It is attacked over the network or with local access, in a software library.

**Am I affected by CVE-2026-68770?** Check whether you run Hugging Face Sentence-Transformers or sentence-transformers (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- sentence-transformers (PyPI): upgrade to 5.6.0 or later

  ```sh
  pip install "sentence-transformers>=5.6.0"
  ```


## Technical details

A logic flaw exists in the 'import_module_class' helper within 'sentence_transformers/util/misc.py'. The guard condition intended to enforce the 'trust_remote_code' security gate contains an 'or os.path.exists(model_name_or_path)' clause. This short-circuit causes the library to satisfy the trust requirement whenever the model path exists on the local filesystem, bypassing the user's 'trust_remote_code=False' configuration. An attacker can exploit this by placing a malicious Python file (e.g., 'modeling_*.py') in a model directory and referencing it via 'modules.json'. When 'SentenceTransformer(path, trust_remote_code=False)' is called, the library will dynamically import and execute the attacker's code. A fix involving a FutureWarning was introduced in version 5.5.1+, with a full removal of the vulnerable logic planned for v6.0.

## Affected products

- Hugging Face sentence-transformers <= 5.5.1

## Identifiers

- CVE-2026-68770
- GHSA-jhr6-gm9c-rqjv
- PYSEC-2026-4164

## Timeline

- 2026-06-09: other: Vulnerability reported and fix proposed in PR 3807
- 2026-06-12: patched: Initial mitigation (FutureWarning) merged into main branch
- 2026-07-31: advisory: CVE-2026-68770 published

## References

- [https://github.com/huggingface/sentence-transformers](https://github.com/huggingface/sentence-transformers)
- [https://github.com/huggingface/sentence-transformers/commit/ae1acc3fb2aa2004577b297eb4a915ce7a03316a](https://github.com/huggingface/sentence-transformers/commit/ae1acc3fb2aa2004577b297eb4a915ce7a03316a)
- [https://github.com/huggingface/sentence-transformers/issues/3801](https://github.com/huggingface/sentence-transformers/issues/3801)
- [https://github.com/huggingface/sentence-transformers/pull/3807](https://github.com/huggingface/sentence-transformers/pull/3807)
- [https://www.vulncheck.com/advisories/sentence-transformers-arbitrary-code-execution-on-local-model-load-despite-trust-remote-code-false](https://www.vulncheck.com/advisories/sentence-transformers-arbitrary-code-execution-on-local-model-load-despite-trust-remote-code-false)
