chore(deps): update dependency langchain-core to v1 [security]#14242
chore(deps): update dependency langchain-core to v1 [security]#14242renovate-bot wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request upgrades langchain-core from 0.2.33 to 1.2.11 across multiple requirements.txt files. However, keeping langchain-google-vertexai pinned to 1.0.10 will cause dependency resolution conflicts, as it strictly requires an older version of langchain-core (<0.3.0). To resolve this, langchain-google-vertexai should also be upgraded to a compatible version.
| google-auth==2.38.0 | ||
| anthropic[vertex]==0.28.0 | ||
| langchain-core==0.2.33 | ||
| langchain-core==1.2.11 |
There was a problem hiding this comment.
Upgrading langchain-core to 1.2.11 while keeping langchain-google-vertexai pinned to 1.0.10 will cause a dependency resolution conflict during installation. langchain-google-vertexai==1.0.10 has a strict dependency constraint on older versions of langchain-core (typically <0.3.0). To resolve this, langchain-google-vertexai should also be upgraded to a version compatible with langchain-core v1.x.
| google-auth==2.38.0 | ||
| anthropic[vertex]==0.28.0 | ||
| langchain-core==0.2.33 | ||
| langchain-core==1.2.11 |
There was a problem hiding this comment.
Upgrading langchain-core to 1.2.11 while keeping langchain-google-vertexai pinned to 1.0.10 will cause a dependency resolution conflict during installation. langchain-google-vertexai==1.0.10 has a strict dependency constraint on older versions of langchain-core (typically <0.3.0). To resolve this, langchain-google-vertexai should also be upgraded to a version compatible with langchain-core v1.x.
| google-auth==2.38.0 | ||
| anthropic[vertex]==0.28.0 | ||
| langchain-core==0.2.33 | ||
| langchain-core==1.2.11 |
There was a problem hiding this comment.
Upgrading langchain-core to 1.2.11 while keeping langchain-google-vertexai pinned to 1.0.10 will cause a dependency resolution conflict during installation. langchain-google-vertexai==1.0.10 has a strict dependency constraint on older versions of langchain-core (typically <0.3.0). To resolve this, langchain-google-vertexai should also be upgraded to a version compatible with langchain-core v1.x.
| google-auth==2.38.0 | ||
| anthropic[vertex]==0.28.0 | ||
| langchain-core==0.2.33 | ||
| langchain-core==1.2.11 |
There was a problem hiding this comment.
Upgrading langchain-core to 1.2.11 while keeping langchain-google-vertexai pinned to 1.0.10 will cause a dependency resolution conflict during installation. langchain-google-vertexai==1.0.10 has a strict dependency constraint on older versions of langchain-core (typically <0.3.0). To resolve this, langchain-google-vertexai should also be upgraded to a version compatible with langchain-core v1.x.
| google-auth==2.38.0 | ||
| anthropic[vertex]==0.28.0 | ||
| langchain-core==0.2.33 | ||
| langchain-core==1.2.11 |
There was a problem hiding this comment.
Upgrading langchain-core to 1.2.11 while keeping langchain-google-vertexai pinned to 1.0.10 will cause a dependency resolution conflict during installation. langchain-google-vertexai==1.0.10 has a strict dependency constraint on older versions of langchain-core (typically <0.3.0). To resolve this, langchain-google-vertexai should also be upgraded to a version compatible with langchain-core v1.x.
| google-auth==2.38.0 | ||
| anthropic[vertex]==0.28.0 | ||
| langchain-core==0.2.33 | ||
| langchain-core==1.2.11 |
There was a problem hiding this comment.
Upgrading langchain-core to 1.2.11 while keeping langchain-google-vertexai pinned to 1.0.10 will cause a dependency resolution conflict during installation. langchain-google-vertexai==1.0.10 has a strict dependency constraint on older versions of langchain-core (typically <0.3.0). To resolve this, langchain-google-vertexai should also be upgraded to a version compatible with langchain-core v1.x.
| google-auth==2.38.0 | ||
| anthropic[vertex]==0.28.0 | ||
| langchain-core==0.2.33 | ||
| langchain-core==1.2.11 |
There was a problem hiding this comment.
Upgrading langchain-core to 1.2.11 while keeping langchain-google-vertexai pinned to 1.0.10 will cause a dependency resolution conflict during installation. langchain-google-vertexai==1.0.10 has a strict dependency constraint on older versions of langchain-core (typically <0.3.0). To resolve this, langchain-google-vertexai should also be upgraded to a version compatible with langchain-core v1.x.
This PR contains the following updates:
==0.2.33→==1.2.11langchain-core allows unauthorized users to read arbitrary files from the host file system
CVE-2024-10940 / GHSA-5chr-fjjv-38qv
More information
Details
A vulnerability in langchain-core versions >=0.1.17,<0.1.53, >=0.2.0,<0.2.43, and >=0.3.0,<0.3.15 allows unauthorized users to read arbitrary files from the host file system. The issue arises from the ability to create langchain_core.prompts.ImagePromptTemplate's (and by extension langchain_core.prompts.ChatPromptTemplate's) with input variables that can read any user-specified path from the server file system. If the outputs of these prompt templates are exposed to the user, either directly or through downstream model outputs, it can lead to the exposure of sensitive information.
Severity
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
LangChain Vulnerable to Template Injection via Attribute Access in Prompt Templates
CVE-2025-65106 / GHSA-6qv9-48xg-fc7f
More information
Details
Context
A template injection vulnerability exists in LangChain's prompt template system that allows attackers to access Python object internals through template syntax. This vulnerability affects applications that accept untrusted template strings (not just template variables) in
ChatPromptTemplateand related prompt template classes.Templates allow attribute access (
.) and indexing ([]) but not method invocation (()).The combination of attribute access and indexing may enable exploitation depending on which objects are passed to templates. When template variables are simple strings (the common case), the impact is limited. However, when using
MessagesPlaceholderwith chat message objects, attackers can traverse through object attributes and dictionary lookups (e.g.,__globals__) to reach sensitive data such as environment variables.The vulnerability specifically requires that applications accept template strings (the structure) from untrusted sources, not just template variables (the data). Most applications either do not use templates or else use hardcoded templates and are not vulnerable.
Affected Components
langchain-corepackagetemplate_format="f-string") - Vulnerability fixedtemplate_format="mustache") - Defensive hardeningtemplate_format="jinja2") - Defensive hardeningImpact
Attackers who can control template strings (not just template variables) can:
__class__,__globals__)Attack Vectors
1. F-string Template Injection
Before Fix:
2. Mustache Template Injection
Before Fix:
3. Jinja2 Template Injection
Before Fix:
Root Cause
string.Formatter().parse()to extract variable names from template strings. This method returns the complete field expression, including attribute access syntax:{obj.__class__.__name__}or{obj.method.__globals__[os]}) were accepted and subsequently evaluated during formatting. While f-string templates do not support method calls with(), they do support[]indexing, which could allow traversal through dictionaries like__globals__to reach sensitive objects.getattr()as a fallback to support accessing attributes on objects (e.g., `` on a User object). However, we decided to restrict this to simpler primitives that subclass dict, list, and tuple types as defensive hardening, since untrusted templates could exploit attribute access to reach internal properties like class on arbitrary objectsSandboxedEnvironmentblocks dunder attributes (e.g.,__class__) but permits access to other attributes and methods on objects. While Jinja2 templates in LangChain are typically used with trusted template strings, as a defense-in-depth measure, we've restricted the environment to block all attribute and method access on objectspassed to templates.
Who Is Affected?
High Risk Scenarios
You are affected if your application:
Example vulnerable code:
Low/No Risk Scenarios
You are NOT affected if:
Example safe code:
The Fix
F-string Templates
F-string templates had a clear vulnerability where attribute access syntax was exploitable. We've added strict validation to prevent this:
{obj.attr},{obj[0]}, or{obj.__class__}{variable_name}Mustache Templates (Defensive Hardening)
As defensive hardening, we've restricted what Mustache templates support to reduce the attack surface:
getattr()fallback with strict type checkingdict,list, andtupletypesJinja2 Templates (Defensive Hardening)
As defensive hardening, we've significantly restricted Jinja2 template capabilities:
_RestrictedSandboxedEnvironmentthat blocks ALL attribute/method accessSecurityErroron any attribute access attemptImportant Recommendation: Due to the expressiveness of Jinja2 and the difficulty of fully sandboxing it, we recommend reserving Jinja2 templates for trusted sources only. If you need to accept template strings from untrusted users, use f-string or mustache templates with the new restrictions instead.
While we've hardened the Jinja2 implementation, the nature of templating engines makes comprehensive sandboxing challenging. The safest approach is to only use Jinja2 templates when you control the template source.
Important Reminder: Many applications do not need prompt templates. Templates are useful for variable substitution and dynamic logic (if statements, loops, conditionals). However, if you're building a chatbot or conversational application, you can often work directly with message objects (e.g.,
HumanMessage,AIMessage,ToolMessage) without templates. Direct message construction avoids template-related security concerns entirely.Remediation
Immediate Actions
langchain-coreBest Practices
HumanMessage,AIMessage, etc.) without templates## ContextA template injection vulnerability exists in LangChain's prompt template system that allows attackers to access Python object internals through template syntax. This vulnerability affects applications that accept untrusted template strings (not just template variables) in
ChatPromptTemplateand related prompt template classes.Templates allow attribute access (
.) and indexing ([]) but not method invocation (()).The combination of attribute access and indexing may enable exploitation depending on which objects are passed to templates. When template variables are simple strings (the common case), the impact is limited. However, when using
MessagesPlaceholderwith chat message objects, attackers can traverse through object attributes and dictionary lookups (e.g.,__globals__) to reach sensitive data such as environment variables.The vulnerability specifically requires that applications accept template strings (the structure) from untrusted sources, not just template variables (the data). Most applications either do not use templates or else use hardcoded templates and are not vulnerable.
Affected Components
langchain-corepackagetemplate_format="f-string") - Vulnerability fixedtemplate_format="mustache") - Defensive hardeningtemplate_format="jinja2") - Defensive hardeningImpact
Attackers who can control template strings (not just template variables) can:
__class__,__globals__)Attack Vectors
1. F-string Template Injection
Before Fix:
2. Mustache Template Injection
Before Fix:
3. Jinja2 Template Injection
Before Fix:
Root Cause
string.Formatter().parse()to extract variable names from template strings. This method returns the complete field expression, including attribute access syntax:{obj.__class__.__name__}or{obj.method.__globals__[os]}) were accepted and subsequently evaluated during formatting. While f-string templates do not support method calls with(), they do support[]indexing, which could allow traversal through dictionaries like__globals__to reach sensitive objects.getattr()as a fallback to support accessing attributes on objects (e.g., `` on a User object). However, we decided to restrict this to simpler primitives that subclass dict, list, and tuple types as defensive hardening, since untrusted templates could exploit attribute access to reach internal properties like class on arbitrary objectsSandboxedEnvironmentblocks dunder attributes (e.g.,__class__) but permits access to other attributes and methods on objects. While Jinja2 templates in LangChain are typically used with trusted template strings, as a defense-in-depth measure, we've restricted the environment to block all attribute and method access on objectspassed to templates.
Who Is Affected?
High Risk Scenarios
You are affected if your application:
Example vulnerable code:
Low/No Risk Scenarios
You are NOT affected if:
Example safe code:
The Fix
F-string Templates
F-string templates had a clear vulnerability where attribute access syntax was exploitable. We've added strict validation to prevent this:
{obj.attr},{obj[0]}, or{obj.__class__}{variable_name}Mustache Templates (Defensive Hardening)
As defensive hardening, we've restricted what Mustache templates support to reduce the attack surface:
getattr()fallback with strict type checkingdict,list, andtupletypesJinja2 Templates (Defensive Hardening)
As defensive hardening, we've significantly restricted Jinja2 template capabilities:
_RestrictedSandboxedEnvironmentthat blocks ALL attribute/method accessSecurityErroron any attribute access attemptImportant Recommendation: Due to the expressiveness of Jinja2 and the difficulty of fully sandboxing it, we recommend reserving Jinja2 templates for trusted sources only. If you need to accept template strings from untrusted users, use f-string or mustache templates with the new restrictions instead.
While we've hardened the Jinja2 implementation, the nature of templating engines makes comprehensive sandboxing challenging. The safest approach is to only use Jinja2 templates when you control the template source.
Important Reminder: Many applications do not need prompt templates. Templates are useful for variable substitution and dynamic logic (if statements, loops, conditionals). However, if you're building a chatbot or conversational application, you can often work directly with message objects (e.g.,
HumanMessage,AIMessage,ToolMessage) without templates. Direct message construction avoids template-related security concerns entirely.Remediation
Immediate Actions
langchain-coreBest Practices
HumanMessage,AIMessage, etc.) without templatesUpdate: Jinja2 Restrictions Reverted
The Jinja2 hardening introduced in the initial patch has been reverted as of
langchain-core1.1.3. The restriction was not addressing a direct vulnerability but was part of broader defensive hardening. In practice, it significantly limited legitimate Jinja2 usage and broke existing templates. Since Jinja2 is intended to be used only with trusted template sources, the original behavior has been restored. Users should continue to avoid accepting untrusted template strings when using Jinja2, but no security issue exists with trusted templates.Severity
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
LangChain serialization injection vulnerability enables secret extraction in dumps/loads APIs
CVE-2025-68664 / GHSA-c67j-w6g6-q2cm
More information
Details
Summary
A serialization injection vulnerability exists in LangChain's
dumps()anddumpd()functions. The functions do not escape dictionaries with'lc'keys when serializing free-form dictionaries. The'lc'key is used internally by LangChain to mark serialized objects. When user-controlled data contains this key structure, it is treated as a legitimate LangChain object during deserialization rather than plain user data.Attack surface
The core vulnerability was in
dumps()anddumpd(): these functions failed to escape user-controlled dictionaries containing'lc'keys. When this unescaped data was later deserialized viaload()orloads(), the injected structures were treated as legitimate LangChain objects rather than plain user data.This escaping bug enabled several attack vectors:
metadata,additional_kwargs, orresponse_metadataSerializablesubclass, but only within the pre-approved trusted namespaces (langchain_core,langchain,langchain_community). This includes classes with side effects in__init__(network calls, file operations, etc.). Note that namespace validation was already enforced before this patch, so arbitrary classes outside these trusted namespaces could not be instantiated.Security hardening
This patch fixes the escaping bug in
dumps()anddumpd()and introduces new restrictive defaults inload()andloads(): allowlist enforcement viaallowed_objects="core"(restricted to serialization mappings),secrets_from_envchanged fromTruetoFalse, and default Jinja2 template blocking viainit_validator. These are breaking changes for some use cases.Who is affected?
Applications are vulnerable if they:
astream_events(version="v1")— The v1 implementation internally uses vulnerable serialization. Note:astream_events(version="v2")is not vulnerable.Runnable.astream_log()— This method internally uses vulnerable serialization for streaming outputs.dumps()ordumpd()on untrusted data, then deserialize withload()orloads()— Trusting your own serialization output makes you vulnerable if user-controlled data (e.g., from LLM responses, metadata fields, or user inputs) contains'lc'key structures.load()orloads()— Directly deserializing untrusted data that may contain injected'lc'structures.RunnableWithMessageHistory— Internal serialization in message history handling.InMemoryVectorStore.load()to deserialize untrusted documents.langchain-communitycaches.hub.pull.StringRunEvaluatorChainon untrusted runs.create_lc_storeorcreate_kv_docstorewith untrusted documents.MultiVectorRetrieverwith byte stores containing untrusted documents.LangSmithRunChatLoaderwith runs containing untrusted messages.The most common attack vector is through LLM response fields like
additional_kwargsorresponse_metadata, which can be controlled via prompt injection and then serialized/deserialized in streaming operations.Impact
Attackers who control serialized data can extract environment variable secrets by injecting
{"lc": 1, "type": "secret", "id": ["ENV_VAR"]}to load environment variables during deserialization (whensecrets_from_env=True, which was the old default). They can also instantiate classes with controlled parameters by injecting constructor structures to instantiate any class within trusted namespaces with attacker-controlled parameters, potentially triggering side effects such as network calls or file operations.Key severity factors:
secrets_from_env=True(the old default)additional_kwargscan be controlled via prompt injectionExploit example
Security hardening changes (breaking changes)
This patch introduces three breaking changes to
load()andloads():allowed_objectsparameter (defaults to'core'): Enforces allowlist of classes that can be deserialized. The'all'option corresponds to the list of objects specified inmappings.pywhile the'core'option limits to objects withinlangchain_core. We recommend that users explicitly specify which objects they want to allow for serialization/deserialization.secrets_from_envdefault changed fromTruetoFalse: Disables automatic secret loading from environmentinit_validatorparameter (defaults todefault_init_validator): Blocks Jinja2 templates by defaultMigration guide
No changes needed for most users
If you're deserializing standard LangChain types (messages, documents, prompts, trusted partner integrations like
ChatOpenAI,ChatAnthropic, etc.), your code will work without changes:For custom classes
If you're deserializing custom classes not in the serialization mappings, add them to the allowlist:
For Jinja2 templates
Jinja2 templates are now blocked by default because they can execute arbitrary code. If you need Jinja2 templates, pass
init_validator=None:For secrets from environment
secrets_from_envnow defaults toFalse. If you need to load secrets from environment variables:Credits
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
LangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messages
CVE-2026-26013 / GHSA-2g6r-c272-w58r
More information
Details
Server-Side Request Forgery (SSRF) in ChatOpenAI Image Token Counting
Summary
The
ChatOpenAI.get_num_tokens_from_messages()method fetches arbitraryimage_urlvalues 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 containingimage_urlcontent blocksdetail: "low", it calls_url_to_size()to fetch the image and compute token counts_url_to_size()performshttpx.get(image_source)on any URL without validationFile:
libs/partners/openai/langchain_openai/chat_models/base.pyPatches
The vulnerability has been patched in
langchain-openai==1.1.9(requireslangchain-core==1.2.11).The patch adds:
langchain_core._security._ssrf_protection.validate_safe_url()to block:httpx.getdefault)allow_fetching_images=FalseparameterWorkarounds
If you cannot upgrade immediately:
image_urlvalues before passing messages to token counting or model invocationSeverity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Never, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.