CVE-2025-46059: LangChain GmailToolkit: indirect prompt injection to RCE
CRITICAL CISA: ATTENDAny LangChain agent with GmailToolkit enabled can be hijacked by a single crafted inbound email — no user interaction required beyond the agent checking the inbox. While LangChain disputes the root cause (blaming insecure user-written glue code), the practical risk is the same: untrusted email content flows directly into LLM context where it can trigger arbitrary tool invocations. Audit all agentic email workflows immediately, enforce input sanitization, and restrict tool permissions to least-privilege until a hardened implementation is verified.
Risk Assessment
CVSS 9.8 reflects worst-case: network-reachable, zero privileges, no user click required once the agent is running. The supplier dispute introduces ambiguity — exploitability depends on how the GmailToolkit is wired in each deployment — but that does not reduce operational risk for organizations that shipped agents without explicit input sandboxing. LangChain's broad adoption in enterprise agentic workflows (RAG pipelines, email triage bots, AI assistants) makes the blast radius significant. Email is a universally accessible attack surface, lowering attacker cost to near zero.
Severity & Risk
Attack Surface
Recommended Action
5 steps-
IMMEDIATE
Audit all LangChain deployments using GmailToolkit or any email-reading tool. Disable or restrict auto-processing of inbound emails in production agents.
-
SHORT-TERM: Implement input sanitization/escaping of email content before passing to LLM context. Follow LangChain's official security guide (python.langchain.com/docs/security/).
-
ARCHITECTURE
Run agents with least-privilege tool scopes — Gmail read-only if write is not needed. Isolate code execution tools from email-processing agents. Add a human-in-the-loop step before any write/execute action triggered by external email content.
-
DETECTION
Monitor for anomalous tool invocations correlated with inbound email processing — unusual send_email, file_write, or shell_execute calls following email reads are red flags.
-
UPGRADE
Review langchain-community changelog for any hardening patches post-v0.3.51 and test against your implementation.
CISA SSVC Assessment
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
Classification
Compliance Impact
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2025-46059?
Any LangChain agent with GmailToolkit enabled can be hijacked by a single crafted inbound email — no user interaction required beyond the agent checking the inbox. While LangChain disputes the root cause (blaming insecure user-written glue code), the practical risk is the same: untrusted email content flows directly into LLM context where it can trigger arbitrary tool invocations. Audit all agentic email workflows immediately, enforce input sanitization, and restrict tool permissions to least-privilege until a hardened implementation is verified.
Is CVE-2025-46059 actively exploited?
No confirmed active exploitation of CVE-2025-46059 has been reported, but organizations should still patch proactively.
How to fix CVE-2025-46059?
1. IMMEDIATE: Audit all LangChain deployments using GmailToolkit or any email-reading tool. Disable or restrict auto-processing of inbound emails in production agents. 2. SHORT-TERM: Implement input sanitization/escaping of email content before passing to LLM context. Follow LangChain's official security guide (python.langchain.com/docs/security/). 3. ARCHITECTURE: Run agents with least-privilege tool scopes — Gmail read-only if write is not needed. Isolate code execution tools from email-processing agents. Add a human-in-the-loop step before any write/execute action triggered by external email content. 4. DETECTION: Monitor for anomalous tool invocations correlated with inbound email processing — unusual send_email, file_write, or shell_execute calls following email reads are red flags. 5. UPGRADE: Review langchain-community changelog for any hardening patches post-v0.3.51 and test against your implementation.
What systems are affected by CVE-2025-46059?
This vulnerability affects the following AI/ML architecture patterns: agent frameworks, email automation pipelines, RAG pipelines with email ingestion, AI-powered email assistants, agentic workflow orchestration.
What is the CVSS score for CVE-2025-46059?
CVE-2025-46059 has a CVSS v3.1 base score of 9.8 (CRITICAL). The EPSS exploitation probability is 0.27%.
Technical Details
NVD Description
langchain-ai v0.3.51 was discovered to contain an indirect prompt injection vulnerability in the GmailToolkit component. This vulnerability allows attackers to execute arbitrary code and compromise the application via a crafted email message. NOTE: this is disputed by the Supplier because the code-execution issue was introduced by user-written code that does not adhere to the LangChain security practices.
Exploitation Scenario
An attacker sends an email to a corporate inbox monitored by a LangChain AI assistant. The email body contains a prompt injection payload disguised as normal text, e.g., hidden instructions at the end of a marketing email. When the agent's GmailToolkit fetches and passes the email to the LLM for summarization or triage, the injected instructions override the agent's system prompt. The LLM then calls available tools — executing shell commands, exfiltrating credentials from the context window, forwarding emails, or downloading and running remote payloads — entirely within the agent's normal permission scope, leaving minimal forensic trace since all actions appear as legitimate tool use.
Weaknesses (CWE)
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H References
Timeline
Related Vulnerabilities
CVE-2023-3765 10.0 MLflow: path traversal allows arbitrary file read
Same attack type: Data Extraction CVE-2025-5120 10.0 smolagents: sandbox escape enables unauthenticated RCE
Same attack type: Code Execution CVE-2025-2828 10.0 LangChain RequestsToolkit: SSRF exposes cloud metadata
Same attack type: Data Extraction CVE-2025-53767 10.0 Azure OpenAI: SSRF EoP, no auth required (CVSS 10)
Same attack type: Data Extraction CVE-2025-59528 10.0 Flowise: Unauthenticated RCE via MCP config injection
Same attack type: Code Execution
AI Threat Alert