CVE-2026-41488: langchain-openai Image Token Counting SSRF Protection Vulnerability

LOW
Advisory Identifier: GHSA-r7w7-9xr2-qq2r
CVSS 3.1
CWE-918
Published
Advisory Summary

CVE-2026-41488 is a LOW (CVSS 3.1) image token counting ssrf protection vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting langchain-openai libraries in the PyPI ecosystem. The issue involves image token counting ssrf protection can be bypassed via dns rebinding. Remediation is available by upgrading affected packages to version 1.1.14.

CVE-2026-41488 at a Glance

CVE Identifier CVE-2026-41488
GHSA Identifier GHSA-r7w7-9xr2-qq2r
Severity LOW
CVSS v3.1 Base Score 3.1
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product langchain-openai
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 3.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-41488

To remediate this vulnerability, upgrade all affected langchain-openai dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

langchain-openai fixed: 1.1.14
pip install langchain-openai>=1.1.14
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show langchain-openai

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-41488, inspect your installed packages using pip:

pip show langchain-openai

Analyze the terminal output to locate any version of langchain-openai in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.1.14), your application is affected.

Note: The pip show langchain-openai command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-918: Server-Side Request Forgery (SSRF), where the web server receives a url or similar request from an upstream component and retrieves the contents of this url, but it does not sufficiently ensure that the request is being sent to the expected destination. In langchain-openai, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary `langchain-openai`'s `_url_to_size()` helper (used by `get_num_tokens_from_messages` for image token counting) validated URLs for SSRF protection and then fetched them in a separate network operation with independent DNS resolution. This left a TOCTOU / DNS rebinding window: an attacker-controlled hostname could resolve to a public IP during validation and then to a private/localhost IP during the actual fetch. The practical impact is limited because the fetched response body is passed directly to Pillow's `Image.open()` to extract dimensions — the response content is never returned, logged, or otherwise exposed to the caller. An attacker cannot exfiltrate data from internal services through this path. A potential risk is blind probing (inferring whether an internal host/port is open based on timing or error behavior). ## Affected versions - `langchain-openai` < 1.1.14 ## Patched versions - `langchain-openai` >= 1.1.14 (requires `langchain-core` >= 1.2.31) ## Affected code **File:** `libs/partners/openai/langchain_openai/chat_models/base.py` — `_url_to_size()` The vulnerable pattern was a validate-then-fetch with separate DNS resolution: ```python validate_safe_url(image_source, allow_private=False, allow_http=True) # ... separate network operation with independent DNS resolution ... response = httpx.get(image_source, timeout=timeout) ``` ## Fix The fix replaces the validate-then-fetch pattern with an SSRF-safe httpx transport (`SSRFSafeSyncTransport` from `langchain-core`) that: - Resolves DNS once and validates all returned IPs against a policy (private ranges, cloud metadata, localhost, k8s internal DNS) - Pins the connection to the validated IP, eliminating the DNS rebinding window - Disables redirect following to prevent redirect-based SSRF bypasses This fix was released in langchain-openai 1.1.14.

CVE-2026-41488 Affected langchain-openai Versions

1 component(s)
Fixed Versions:
1.1.14
Product / Package Ecosystem Affected Versions Fixed Version
langchain-openai
PyPI
< 1.1.14
1.1.14

References

Frequently Asked Questions

What is CVE-2026-41488?
CVE-2026-41488 is a security vulnerability in langchain-openai involving Image token counting SSRF protection can be bypassed via DNS rebinding under CWE-918: Server-Side Request Forgery (SSRF).
Which langchain-openai versions are affected?
Affected versions include releases prior to 1.1.14 across affected packages: langchain-openai.
What version fixes CVE-2026-41488?
Upgrading to 1.1.14 (or the latest patched release for your respective branch) resolves the vulnerability.
Is langchain-openai affected?
Yes, langchain-openai is affected in releases prior to 1.1.14. Upgrade your dependency to 1.1.14 or later.
What is the CVSS score of CVE-2026-41488?
CVE-2026-41488 has a CVSS v3.1 base score of 3.1 (LOW) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2026-41488?
CVE-2026-41488 is classified under CWE-918: Server-Side Request Forgery (SSRF) (The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.).
How can I check PyPI dependencies for CVE-2026-41488?
Run the dependency tree command: 'pip show langchain-openai'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-r7w7-9xr2-qq2r",
  "modified" : "2026-06-06T00:59:02Z",
  "published" : "2026-04-16T23:00:12Z",
  "aliases" : [ "CVE-2026-41488" ],
  "summary" : "langchain-openai: Image token counting SSRF protection can be bypassed via DNS rebinding",
  "details" : "## Summary\n\n`langchain-openai`'s `_url_to_size()` helper (used by `get_num_tokens_from_messages` for image token counting) validated URLs for SSRF protection and then fetched them in a separate network operation with independent DNS resolution. This left a TOCTOU / DNS rebinding window: an attacker-controlled hostname could resolve to a public IP during validation and then to a private/localhost IP during the actual fetch.\n\nThe practical impact is limited because the fetched response body is passed directly to Pillow's `Image.open()` to extract dimensions — the response content is never returned, logged, or otherwise exposed to the caller. An attacker cannot exfiltrate data from internal services through this path. A potential risk is blind probing (inferring whether an internal host/port is open based on timing or error behavior).\n\n## Affected versions\n\n- `langchain-openai` < 1.1.14\n\n## Patched versions\n\n- `langchain-openai` >= 1.1.14 (requires `langchain-core` >= 1.2.31)\n\n## Affected code\n\n**File:** `libs/partners/openai/langchain_openai/chat_models/base.py` — `_url_to_size()`\n\nThe vulnerable pattern was a validate-then-fetch with separate DNS resolution:\n\n```python\nvalidate_safe_url(image_source, allow_private=False, allow_http=True)\n# ... separate network operation with independent DNS resolution ...\nresponse = httpx.get(image_source, timeout=timeout)\n```\n\n## Fix\n\nThe fix replaces the validate-then-fetch pattern with an SSRF-safe httpx transport (`SSRFSafeSyncTransport` from `langchain-core`) that:\n\n- Resolves DNS once and validates all returned IPs against a policy (private ranges, cloud metadata, localhost, k8s internal DNS)\n- Pins the connection to the validated IP, eliminating the DNS rebinding window\n- Disables redirect following to prevent redirect-based SSRF bypasses\n\nThis fix was released in langchain-openai 1.1.14.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "langchain-openai"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.1.14"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/langchain-ai/langchain/security/advisories/GHSA-r7w7-9xr2-qq2r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-41488"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/langchain-ai/langchain"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/langchain-openai/PYSEC-2026-76.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-918" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-16T23:00:12Z",
    "nvd_published_at" : "2026-04-24T21:16:19Z"
  }
}