# CVE-2026-26013: PYSEC-2026-2562 - LangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messages

Source: https://junglewise.ai/threats/cve-2026-26013-langchain-chatopenai-server-side-request-forgery-via-image-token  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-13. Updated: 2026-09-26  
License: CC BY 4.0 with a link back

CVE-2026-26013 · Severity: low · CVSS 3.1 · Published 2026-07-13

LangChain's ChatOpenAI token counting method fetches image URLs without validation when processing vision-enabled model inputs. An attacker who can provide image URLs to the application can force the server to make HTTP requests to arbitrary internal or external addresses, potentially accessing private networks or cloud metadata endpoints.

Technologies: [langchain-core (PyPI)](https://junglewise.ai/threats/technologies/langchain-core). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

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

**How severe is CVE-2026-26013?** Low severity, with a CVSS score of 3.1, published 13 July 2026.

**Which products and versions are affected?** langchain-core (PyPI) ECOSYSTEM:introduced=0,fixed=1.2.11.

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

**How is CVE-2026-26013 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-26013?** Check whether you run langchain-core (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

- langchain-core (PyPI): upgrade to 1.2.11 or later

  ```sh
  pip install "langchain-core>=1.2.11"
  ```


## Technical details

This is a server-side request forgery (SSRF) vulnerability in the ChatOpenAI.get_num_tokens_from_messages() method, which calls _url_to_size() to fetch and measure images for token counting without URL validation. The vulnerable code performs httpx.get() on attacker-controlled image_url values without checking for private IP ranges, loopback addresses, or cloud metadata endpoints. Token counting may occur outside of direct model invocation—such as in logging, metrics, and budgeting flows—expanding the attack surface. The impact is limited to blind SSRF (no response returned to attacker) with a 5-second timeout and PIL image parsing requirements, preventing full data exfiltration. The patch (langchain-openai 1.1.9, requiring langchain-core 1.2.11) adds URL validation, size limits (50 MB), and an explicit timeout.

## Affected products

- LangChain langchain-core before 1.2.11
- LangChain langchain-openai before 1.1.9

## Identifiers

- CVE-2026-26013
- GHSA-2g6r-c272-w58r
- PYSEC-2026-2562

## Timeline

- 2026-02-11: disclosed: GHSA-2g6r-c272-w58r published
- 2026-02-11: patched: langchain-openai 1.1.9 and langchain-core 1.2.11 released

## References

- [https://github.com/langchain-ai/langchain/security/advisories/GHSA-2g6r-c272-w58r](https://github.com/langchain-ai/langchain/security/advisories/GHSA-2g6r-c272-w58r)

## Related threats

- [PYSEC-2026-1517 - langchain-core allows unauthorized users to read arbitrary files from the host file system](https://junglewise.ai/threats/cve-2024-10940-langchain-core-allows-unauthorized-users-to-read-arbitrary-files)
- [PYSEC-2026-1519 - LangChain's XMLOutputParser vulnerable to XML Entity Expansion](https://junglewise.ai/threats/cve-2024-1455-langchain-s-xmloutputparser-vulnerable-to-xml-entity-expansion)
- [LangChain unsafe deserialization in load() via broad object allowlists](https://junglewise.ai/threats/cve-2026-44843-langchain-unsafe-deserialization-in-load-via-broad-object)
- [LangChain incomplete f-string validation in prompt templates](https://junglewise.ai/threats/cve-2026-40087-langchain-incomplete-f-string-validation-in-prompt-templates)
- [LangChain langchain-core path traversal in prompt loading functions](https://junglewise.ai/threats/cve-2026-34070-langchain-langchain-core-path-traversal-in-prompt-loading)
