PyPI: langchain-core

CVE-2026-26013

Safety vulnerability ID: SFTY-20260211-88956

Safety legacy ID: pyup.io-86270

Affected versions of the langchain-core package are vulnerable to Server-Side Request Forgery (SSRF) due to fetching user-supplied image_url values during token counting without URL validation. In ChatOpenAI.get_num_tokens_from_messages(), messages containing image_url blocks can flow into _url_to_size(), which calls httpx.get(image_source) on attacker-controlled URLs in libs/partners/openai/langchain_openai/chat_models/base.py when computing vision-model token counts.

Created at: Mar 17, 2026Updated at: Mar 17, 2026

Overview

LangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messages

Advisory

Affected versions of the langchain-core package are vulnerable to Server-Side Request Forgery (SSRF) due to fetching user-supplied image_url values during token counting without URL validation. In ChatOpenAI.get_num_tokens_from_messages(), messages containing image_url blocks can flow into _url_to_size(), which calls httpx.get(image_source) on attacker-controlled URLs in libs/partners/openai/langchain_openai/chat_models/base.py when computing vision-model token counts.

Affected Package

Affecting langchain-core package, versions
<1.2.11

Also affects

---

How to Fix

Upgrade
langchain-core
to
1.2.11
or higher.

Mitigation and Workarounds

---

Vulnerable Functions

Functions linked to known vulnerabilities.

Vulnerable function data is available for Enterprise customers

Book a call with us to see Safety in action.

Safety

Verified by Safety

Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.

Learn more