langchain - 💡(How to fix) Fix CRITICAL SECURITY: RCE via ShellTool in langchain_classic (LC-CLASSIC-001) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#36623Fetched 2026-04-09 07:50:54
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
closed ×1commented ×1labeled ×1

Code Execution via ShellTool in langchain_classic

Root Cause

Code Execution via ShellTool in langchain_classic

Fix Action

Fix / Workaround

Patched Versions

Pending fix

Code Example

DEPRECATED_LOOKUP = {
    'ShellInput': 'langchain_community.tools.shell.tool',
    'ShellTool': 'langchain_community.tools'
}
RAW_BUFFERClick to expand / collapse

GHSA Submission: LC-CLASSIC-001

Summary

Code Execution via ShellTool in langchain_classic

Description

langchain_classic.tools.shell.tool redirects to langchain_community.tools.shell.tool.ShellTool which executes arbitrary shell commands. The 'classic' package is NOT deprecated - it actively imports dangerous tools.

Severity

CRITICAL (CVSS 9.1)

CWE

CWE-94 (Code Injection)

Affected Package/Repository

langchain/langchain

Affected File

libs/langchain/langchain_classic/tools/shell/tool.py

Vulnerable Version Range

All versions where langchain_classic imports langchain_community ShellTool

Patched Versions

Pending fix

Reproduction

The DEPRECATED_LOOKUP mapping shows:

DEPRECATED_LOOKUP = {
    'ShellInput': 'langchain_community.tools.shell.tool',
    'ShellTool': 'langchain_community.tools'
}

Applications using classic tools with LLM-driven tool selection are vulnerable to Remote Code Execution (RCE). An attacker can craft prompts that cause the LLM to select the ShellTool and execute arbitrary shell commands on the host system.

Impact

CRITICAL: Remote Code Execution. An attacker can execute arbitrary shell commands on any system running LangChain applications that use langchain_classic with LLM-driven tool selection. This provides full system access to attackers.

Recommended Fix

  1. Immediately deprecate and remove ShellTool from langchain_classic
  2. Add explicit warnings and require opt-in confirmation for any shell execution tools
  3. Implement sandboxing or containerization for any shell command execution
  4. Add allowlists for permitted commands if shell execution is required

References

extent analysis

TL;DR

Remove or deprecate the ShellTool from langchain_classic to prevent Remote Code Execution vulnerabilities.

Guidance

  • Identify and assess all applications using langchain_classic with LLM-driven tool selection for potential vulnerabilities.
  • Consider implementing sandboxing or containerization for any shell command execution as a temporary mitigation strategy.
  • Review the DEPRECATED_LOOKUP mapping to ensure no other tools are redirecting to vulnerable community tools.
  • Plan for explicit warnings and opt-in confirmation for any shell execution tools to enhance security.

Example

No code snippet is provided due to the nature of the issue focusing on removal and mitigation rather than code correction.

Notes

The provided guidance is based on the critical severity of the issue and the need for immediate action to prevent Remote Code Execution. The lack of a patched version means that mitigation strategies and removal of vulnerable components are the primary recommendations.

Recommendation

Apply workaround: Remove or deprecate the ShellTool from langchain_classic and implement additional security measures such as sandboxing or containerization for shell command execution. This is recommended due to the critical nature of the vulnerability and the absence of a patched version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING