-
Notifications
You must be signed in to change notification settings - Fork 6.6k
chore(deps): update dependency langchain-core to v0.3.80 [security] #13643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
chore(deps): update dependency langchain-core to v0.3.80 [security] #13643
Conversation
Summary of ChangesHello @renovate-bot, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request updates the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly updates the langchain-core dependency to version 0.3.80, addressing the critical template injection vulnerability GHSA-6qv9-48xg-fc7f. The update is applied consistently across all relevant requirements.txt files, which is a necessary and important security remediation.
While reviewing, I noticed significant duplication of dependencies across the various requirements.txt files. To improve long-term maintainability and simplify future updates, I've left a suggestion to consider centralizing common dependencies into a shared file. This is a recommendation for future improvement and doesn't block this important security update.
| google-auth==2.38.0 | ||
| anthropic[vertex]==0.28.0 | ||
| langchain-core==0.2.33 | ||
| langchain-core==0.3.80 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this version bump is correct and necessary for security, I've observed that this dependency and several others are duplicated across numerous requirements.txt files within the generative_ai/ directory. This practice can make dependency management cumbersome and error-prone, as any update needs to be manually synchronized across all files.
To improve maintainability, I recommend consolidating common dependencies into a single, shared file (e.g., generative_ai/requirements.common.txt). Each specific requirements.txt file can then include these common dependencies using the -r requirements.common.txt directive. This would centralize version management and simplify future updates.
This change is outside the scope of the current security fix but would be a valuable improvement to address in a follow-up pull request.
This PR contains the following updates:
==0.2.33->==0.3.80Warning
Some dependencies could not be looked up. Check the Dependency Dashboard for more information.
GitHub Vulnerability Alerts
GHSA-6qv9-48xg-fc7f
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 templatesConfiguration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 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.