LangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messages
CVE-2026-26013 · GHSA-2g6r-c272-w58r · published 2026-02-11
- Severity
- Low
- CVSS score
- 3.7
- Chance of exploitation (EPSS)
- 0.42%
- Fixed in
- 1.2.11
- Exploitation No known exploitation
- Automatable No
- Technical impact Partial
- CISA SSVC
An attacker who can control image URLs passed to get_num_tokens_from_messages() can: Trigger HTTP requests from the application server to arbitrary internal or external URLs Cause the server to access internal network resources (private IPs, cloud metadata endpoints) Cause minor resource consumption through image downloads (bounded by timeout) Note: This vulnerability occurs during token counting, which may happen outside of model invocation (e.g., in logging, metrics, or token budgeting flows).
Upgrade langchain-core to 1.2.11 or later. If you start it from an MCP config with npx or uvx, pin that version so an old cached copy is not used.
The vulnerability has been patched in langchain-openai==1.1.9 (requires langchain-core==1.2.11). The patch adds: 1. SSRF validation using to block: Private IP ranges (RFC 1918, loopback, link-local) Cloud metadata endpoints (169.254.169.254, etc.) Invalid URL schemes 2. Explicit size limits (50 MB maximum, matching OpenAI's payload limit) 3. Explicit timeout (5 seconds, same as httpx.get default) 4. Allow disabling image fetching via allow_fetching_images=False parameter
If you cannot upgrade immediately: 1. Sanitize input: Validate and filter image_url values before passing messages to token counting or model invocation 2. Use network controls: Implement egress filtering to prevent outbound requests to private IPs
| Package | Registry | Affected | Fixed in |
|---|---|---|---|
| langchain-core | PyPI | < 1.2.11 | 1.2.11 |
1 registered MCP server installs an affected version today, by the dependency versions a fresh install resolves.
- io.github.jahanv01/sec-intelligence-mcplangchain-core@0.3.86
- CriticalMLflow: Unauthenticated full-read SSRF in webhook delivery: _validate_webhook_url bypassed via unvalidated HTTP redirects (and DNS rebindingmlflowExploited
- Critical@zereight/mcp-gitlab Vulnerable to Server-Side Request Forgery@zereight/mcp-gitlab
- CriticalSSRF + LLM API key exfiltration via user-controlled basepath / baseUrl in 8 chat-model nodesflowise, flowise-components
- CriticalLocalAI POST /models/apply permits unauthenticated server-side request forgery through gallery URLsgithub.com/mudler/LocalAI
- CriticalFastMCP OpenAPI Provider has an SSRF & Path Traversal Vulnerabilityfastmcp
- CriticalBentoML SSRF Vulnerability in File Upload Processingbentoml
- CriticalLangChain serialization injection vulnerability enables secret extraction in dumps/loads APIslangchain-core, langchain-core
- HighLangChain vulnerable to unsafe deserialization of attacker-controlled objects through overly broad `load()` allowlistslangchain-core, langchain-core
- HighLangChain Core has Path Traversal vulnerabilites in legacy `load_prompt` functionslangchain-core
- HighLangChain Vulnerable to Template Injection via Attribute Access in Prompt Templateslangchain-core, langchain-core
- MediumLangChain has incomplete f-string validation in prompt templateslangchain-core, langchain-core
- Mediumlangchain-core allows unauthorized users to read arbitrary files from the host file systemlangchain-core, langchain-core, langchain-core
The impact, patch and workaround text comes from the advisory, shortened (GitHub Advisory Database, CC BY 4.0). Proof-of-concept and reproduction sections and code are left out; the original advisory has them.