Join the Cyber Forum: Threat Intel on May 12, 2026 to learn how AI is reshaping threat defense.Join the Virtual Cyber Forum: Threat IntelRegister Now
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2023-39659

CVE-2023-39659: Langchain RCE Vulnerability

CVE-2023-39659 is a remote code execution vulnerability in Langchain v.0.0.232 and earlier versions affecting the PythonAstREPLTool component. Attackers can exploit this flaw to execute arbitrary code. This article covers technical details, affected versions, security impact, and mitigation strategies.

Published: February 11, 2026

CVE-2023-39659 Overview

A critical remote code execution vulnerability exists in langchain-ai's LangChain library versions 0.0.232 and earlier. The vulnerability resides in the PythonAstREPLTool._run component, which improperly handles user-supplied input, allowing remote attackers to execute arbitrary Python code on affected systems. This vulnerability represents a significant security risk for applications utilizing LangChain's Python REPL tool functionality.

Critical Impact

Remote attackers can execute arbitrary code on systems running vulnerable LangChain versions, potentially leading to complete system compromise, data theft, or lateral movement within networks.

Affected Products

  • LangChain langchain-ai v.0.0.232 and earlier versions
  • Applications integrating the vulnerable PythonAstREPLTool component
  • AI/ML pipelines utilizing LangChain's Python REPL functionality

Discovery Timeline

  • 2023-08-15 - CVE-2023-39659 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2023-39659

Vulnerability Analysis

This vulnerability is classified as CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component, also known as Injection). The PythonAstREPLTool._run component in LangChain is designed to execute Python code within a controlled environment. However, the implementation fails to properly sanitize or restrict the code that can be executed, allowing attackers to craft malicious Python scripts that escape the intended sandbox.

The vulnerability is particularly concerning in the context of LangChain's use cases, which often involve processing user-provided inputs or prompts. When an application uses PythonAstREPLTool to evaluate Python expressions derived from user input, an attacker can inject malicious code that will be executed with the privileges of the application.

Root Cause

The root cause of this vulnerability lies in insufficient input validation and code sandboxing within the PythonAstREPLTool._run method. The tool parses Python code using the Abstract Syntax Tree (AST) module but fails to adequately restrict dangerous operations. This allows attackers to bypass intended security controls and execute arbitrary system commands, access files, or perform other malicious operations.

The vulnerability exists because the tool trusts that input passed to it has already been sanitized, but in many LangChain workflows, user-controlled data can reach this component without proper validation.

Attack Vector

The attack vector for CVE-2023-39659 is network-based, requiring no authentication or user interaction. An attacker can exploit this vulnerability remotely by:

  1. Identifying an application that uses LangChain's PythonAstREPLTool component
  2. Crafting a malicious Python payload designed to execute system commands
  3. Delivering the payload through any input vector that eventually reaches the _run method
  4. Achieving arbitrary code execution on the target system

The exploitation mechanism involves injecting Python code that can import dangerous modules like os, subprocess, or socket to execute system commands, establish reverse shells, or exfiltrate data. For detailed technical information, see the GitHub Issue #7700.

Detection Methods for CVE-2023-39659

Indicators of Compromise

  • Unusual process spawning from Python/LangChain application processes
  • Unexpected network connections originating from applications using LangChain
  • Suspicious file system access or modifications from LangChain-integrated services
  • Log entries indicating execution of system commands through Python REPL components

Detection Strategies

  • Monitor application logs for suspicious Python code patterns including os.system, subprocess, exec, or eval calls
  • Implement network monitoring to detect unexpected outbound connections from LangChain-enabled applications
  • Deploy runtime application self-protection (RASP) solutions to detect code injection attempts
  • Use SentinelOne's Singularity platform to detect anomalous behavior from Python processes

Monitoring Recommendations

  • Enable verbose logging for all LangChain tool executions in production environments
  • Configure alerts for any process execution events originating from LangChain application contexts
  • Monitor for unusual import statements or module loading within LangChain workflows
  • Implement egress filtering and monitor for data exfiltration attempts

How to Mitigate CVE-2023-39659

Immediate Actions Required

  • Upgrade LangChain to a version newer than 0.0.232 that contains the security fix
  • Audit all applications using PythonAstREPLTool and evaluate if this functionality is necessary
  • Implement additional input validation before data reaches LangChain tool components
  • Consider disabling or removing PythonAstREPLTool if not essential to your application

Patch Information

The LangChain development team has addressed this vulnerability through Pull Request #5640. Organizations should update to a patched version of LangChain as soon as possible. Review your requirements.txt or pyproject.toml files to ensure you are not pinned to vulnerable versions.

To update LangChain to the latest version:

bash
pip install --upgrade langchain

Workarounds

  • Implement a strict allowlist of permitted Python operations before passing code to PythonAstREPLTool
  • Run LangChain applications in isolated containers with minimal privileges and restricted network access
  • Use security controls like seccomp profiles or AppArmor to limit what the application can execute
  • Consider alternative LangChain tools that do not execute arbitrary Python code
bash
# Configuration example - Run LangChain in a restricted container
docker run --security-opt seccomp=langchain-restricted.json \
  --network=internal-only \
  --read-only \
  --cap-drop=ALL \
  your-langchain-app:latest

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechLangchain

  • SeverityCRITICAL

  • CVSS Score9.8

  • EPSS Probability1.20%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-74
  • Technical References
  • GitHub Issue #7700
  • Vendor Resources
  • GitHub Pull Request #5640
  • Related CVEs
  • CVE-2026-30617: LangChain-ChatChat 0.3.1 RCE Vulnerability

  • CVE-2026-40087: LangChain RCE Vulnerability

  • CVE-2025-46059: LangChain GmailToolkit RCE Vulnerability

  • CVE-2024-46946: Langchain-experimental RCE Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English