# CVE-2025-65106: LangChain Vulnerable to Template Injection via Attribute Access in Prompt Templates

> Attackers can execute arbitrary code by injecting malicious template syntax into LangChain prompt templates that accept untrusted input.

- **Severity:** High 8.3 (`CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 21 Nov 2025
- **Updated:** 21 Nov 2025
- **Also known as:** ECHO-159f-63a0-e634, GHSA-6qv9-48xg-fc7f, PYSEC-2026-1518, ROOT-APP-PYPI-CVE-2025-65106

## What is CVE-2025-65106?

CVE-2025-65106 is a high-severity code injection vulnerability in langchain-ai langchain, published on 21 Nov 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

LangChain is a framework for building agents and LLM-powered applications. From versions 0.3.79 and prior and 1.0.0 to 1.0.6, a template injection vulnerability exists in LangChain's prompt template system that allows attackers to access Python object internals through template syntax. This vulnerability affects applications that accept untrusted template strings (not just template variables) in ChatPromptTemplate and related prompt template classes. This issue has been patched in versions 0.3.80 and 1.0.7.

Weakness: CWE-1336 (Improper Neutralization of Special Elements Used in a Template Engine)

## Which versions are affected by CVE-2025-65106?

5 open source packages ship an affected version, including langchain-core.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `langchain-core` | PyPI | All versions | 0.3.80, 1.0.7 |
| `langchain-core` | PyPI | All versions | 0.3.80 |
| `langchain-core` | PyPI | All versions | 0.3.80 |
| `langchain-core` | PyPI | From 1.0.0 | 1.0.7 |
| `langchain-core` | PyPI | From 1.0.0 | 1.0.7 |

## How do I fix CVE-2025-65106?

Upgrade langchain-core to a fixed version for your release line: 0.3.80 or 1.0.7.

## Is CVE-2025-65106 being exploited?

There is no known exploitation of CVE-2025-65106 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-65106 and fix it if it is affected.

What it is: CVE-2025-65106 is a high-severity code injection vulnerability in langchain-ai langchain, published on 21 Nov 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2025-65106 in the wild and no public exploit code.

Affected packages and fixed versions:
- langchain-core (PyPI): affected all versions; fixed in 0.3.80, 1.0.7
- langchain-core (PyPI): affected all versions; fixed in 0.3.80
- langchain-core (PyPI): affected all versions; fixed in 0.3.80
- langchain-core (PyPI): affected from 1.0.0; fixed in 1.0.7
- langchain-core (PyPI): affected from 1.0.0; fixed in 1.0.7

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-65106/ (Markdown: https://insights.sbomify.com/CVE-2025-65106/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-65106
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-65106
- OSV: https://osv.dev/vulnerability/CVE-2025-65106

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-65106/
Summaries are generated and may contain mistakes; the official description above is the record.
