langchain-core
Affected
- introduced
0, fixed1.2.11(ecosystem)
Fixed versions
1.2.11
Fix
- Fixed version
1.2.11pip install --upgrade langchain-core==1.2.11
Advisory
Also known as: CVE-2026-26013, GHSA-2g6r-c272-w58r
LangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messages
Server-Side Request Forgery (SSRF) in ChatOpenAI Image Token Counting
Summary
The ChatOpenAI.get_num_tokens_from_messages() method fetches arbitrary image_url values without validation when computing token counts for vision-enabled models. This allows attackers to trigger Server-Side Request Forgery (SSRF) attacks by providing malicious image URLs in user input.
Severity
Low - The vulnerability allows SSRF attacks but has limited impact due to:
Impact
An attacker who can control image URLs passed to get_num_tokens_from_messages() can:
Note: This vulnerability occurs during token counting, which may happen outside of model invocation (e.g., in logging, metrics, or token budgeting flows).
Details
The vulnerable code path:
get_num_tokens_from_messages() processes messages containing image_url content blocksdetail: "low", it calls _url_to_size() to fetch the image and compute token counts_url_to_size() performs httpx.get(image_source) on any URL without validationFile: libs/partners/openai/langchain_openai/chat_models/base.py
Patches
The vulnerability has been patched in langchain-openai==1.1.9 (requires langchain-core==1.2.11).
The patch adds:
langchain_core._security._ssrf_protection.validate_safe_url() to block:httpx.get default)allow_fetching_images=False parameterWorkarounds
If you cannot upgrade immediately:
image_url values before passing messages to token counting or model invocationLow Basis: CVSS v3 score 3.7, vector CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L
0, fixed 1.2.11 (ecosystem)1.2.11
1.2.11pip install --upgrade langchain-core==1.2.11Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: PyPA Advisory Database · CC BY 4.0