{"id":"CVE-2026-41488","aliases":["CVE-2026-41488","GHSA-r7w7-9xr2-qq2r","PYSEC-2026-76"],"related":[],"kind":"vulnerability","state":"published","title":"angchain-openai: Image token counting SSRF protection can be bypassed via DNS rebinding","summary":"LangChain is a framework for building agents and LLM-powered applications. Prior to 1.1.14, 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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"LangChain is a framework for building agents and LLM-powered applications. Prior to 1.1.14, 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.","source":"cvelist"},{"lang":"en","text":"## 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.","format":"markdown","source":"ghsa"},{"lang":"es","text":"LangChain es un framework para construir agentes y aplicaciones impulsadas por LLM. Antes de la versión 1.1.14, el asistente _url_to_size() de langchain-openai (utilizado por get_num_tokens_from_messages para el recuento de tokens de imagen) validaba las URL para la protección contra SSRF y luego las obtenía en una operación de red separada con resolución DNS independiente. Esto dejaba una ventana de TOCTOU / revinculación de DNS: un nombre de host controlado por un atacante podría resolverse a una IP pública durante la validación y luego a una IP privada/localhost durante la obtención real.","source":"nvd"}],"published":"2026-04-16T23:00:12.000Z","modified":"2026-10-26T21:10:00.170Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N","score":3.1,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N","score":3.1,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N","score":3.1,"rating":"LOW"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N","score":3.1,"rating":"LOW"}],"cwes":["CWE-918"],"affected":[{"ranges":[{"version":"< 1.1.14","status":"affected"}],"vendor":"langchain-ai","product":"langchain-openai","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.1.14"}],"ecosystem":"PyPI","package":"langchain-openai","purl":"pkg:pypi/langchain-openai","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.1.14"}],"vendor":"langchain","product":"langchain-openai","cpe":"cpe:2.3:a:langchain:langchain-openai:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.1.14"}],"ecosystem":"PyPI","package":"langchain-openai","purl":"pkg:pypi/langchain-openai","source":"pysec"}],"references":[{"url":"https://github.com/langchain-ai/langchain/security/advisories/GHSA-r7w7-9xr2-qq2r","tags":["advisory","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41488","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/langchain-ai/langchain","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/langchain-openai/PYSEC-2026-76.yaml","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-04-27T13:40:34.758Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-41488","url":"https://www.cve.org/CVERecord?id=CVE-2026-41488","licence":"CVE Terms of Use","modified":"2026-04-27T13:40:42.065Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-r7w7-9xr2-qq2r","url":"https://github.com/advisories/GHSA-r7w7-9xr2-qq2r","licence":"CC-BY-4.0","modified":"2026-06-06T01:15:07.912Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-41488","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41488","licence":"Public domain","modified":"2026-10-26T21:10:00.170Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-76","url":"https://osv.dev/vulnerability/PYSEC-2026-76","licence":"CC-BY-4.0","modified":"2026-05-20T09:19:04.187Z"}],"updatedAt":"2026-11-25T22:59:19.587Z","epss":{"score":0.00164,"percentile":0.05824,"date":"2026-12-01T12:00:22.000Z"}}