CVE-2026-26013: LangChain SSRF Vulnerability in ChatOpenAI Image Token Counting

langchain-core Updated 11 Feb 2026

Summary

11/02/2026
Yes i
Low
3.7

CVE-2026-26013: LangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messages. Affects langchain-core versions < 1.2.11. Fixed in 1.2.11. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

LangChain is an open-source framework designed for building applications powered by language models. It provides various tools and integrations to facilitate the development of AI-driven applications. The framework includes components for handling messages, including those with image URLs, which are processed to compute token counts for vision-enabled models. However, a vulnerability has been identified in the way LangChain handles image URLs, leading to potential security risks.

Vulnerability Detail

The vulnerability arises from the ChatOpenAI.get_num_tokens_from_messages() method, which fetches arbitrary image_url values without proper validation. This oversight allows attackers to exploit the system through Server-Side Request Forgery (SSRF) attacks by submitting malicious image URLs. The implications include unauthorized HTTP requests from the application server to both internal and external resources, potentially exposing sensitive internal network information. The vulnerability is classified as low severity due to its limited impact, including blind SSRF, a default timeout of 5 seconds, and failure of non-image responses during parsing.

How To Fix

Latest published version: 1.7.0 as of 22 Oct 2026

pip install --upgrade "langchain-core==1.7.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

1.2.11

This is the first release that contains the fix.

pip install --upgrade "langchain-core==1.2.11"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If immediate upgrading is not feasible, consider the following workaround: Validate and filter image_url values before passing them to the get_num_tokens_from_messages() method. Implementing input sanitization can help mitigate the risk of SSRF attacks. Example code for sanitization could look like this:

def sanitize_image_url(image_url):
    # Add validation logic to ensure the URL is safe
    if is_safe_url(image_url):
        return image_url
    else:
        raise ValueError('Unsafe URL')

# Usage
try:
    safe_url = sanitize_image_url(user_provided_url)
    # Proceed with safe_url
except ValueError as e:
    print(e)

Conclusion

In summary, the SSRF vulnerability in LangChain's ChatOpenAI.get_num_tokens_from_messages() method poses a risk due to improper handling of image URLs. It is crucial to update to the patched version or implement input sanitization to mitigate potential attacks.

See every vulnerability recorded for langchain-core →

Share this vulnerability

FAQ

Server-Side Request Forgery (SSRF) is a security vulnerability that allows an attacker to send crafted requests from the server to internal or external resources, potentially exposing sensitive data.

You can check if your application is affected by using the Vulert playground at Vulert Scanner, which monitors open-source vulnerabilities in real-time.

The potential impacts include unauthorized access to internal network resources, minor resource consumption from image downloads, and exposure to external URLs.

Yes, the vulnerability has been patched in langchain-openai==1.1.9 and requires langchain-core==1.2.11.

If you cannot upgrade immediately, sanitize input by validating and filtering image_url values before processing them.

Related vulnerabilities

Recent vulnerabilities recorded for langchain-core.

How To Fix

Latest published version: 1.7.0 as of 22 Oct 2026

pip install --upgrade "langchain-core==1.7.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

1.2.11

This is the first release that contains the fix.

pip install --upgrade "langchain-core==1.2.11"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback