The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
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-2026-40158

CVE-2026-40158: PraisonAI Sandbox Bypass RCE Vulnerability

CVE-2026-40158 is a sandbox bypass RCE vulnerability in PraisonAI that allows attackers to execute arbitrary code using type.__getattribute__ trampoline. This post covers the technical details, affected versions, and mitigation.

Published: April 17, 2026

CVE-2026-40158 Overview

CVE-2026-40158 is a code injection vulnerability in PraisonAI, a multi-agent teams system. Prior to version 4.5.128, PraisonAI's AST-based Python sandbox can be bypassed using a type.__getattribute__ trampoline, allowing arbitrary code execution when running untrusted agent code. This vulnerability represents a significant risk for organizations using PraisonAI to execute agent-generated code, as attackers can escape the intended sandbox restrictions.

Critical Impact

Attackers can bypass sandbox restrictions and achieve arbitrary code execution on systems running untrusted PraisonAI agent code, potentially leading to full system compromise.

Affected Products

  • PraisonAI versions prior to 4.5.128
  • Systems running untrusted agent code through PraisonAI's _execute_code_direct function
  • Deployments utilizing praisonaiagents/tools/python_tools.py

Discovery Timeline

  • April 10, 2026 - CVE-2026-40158 published to NVD
  • April 13, 2026 - Last updated in NVD database

Technical Details for CVE-2026-40158

Vulnerability Analysis

This vulnerability stems from incomplete AST-based filtering in PraisonAI's Python sandbox implementation. The _execute_code_direct function in praisonaiagents/tools/python_tools.py uses Abstract Syntax Tree (AST) filtering to block dangerous Python attributes such as __subclasses__, __globals__, and __bases__. However, this filtering mechanism only inspects ast.Attribute nodes, creating a significant security gap.

The fundamental issue is that the sandbox fails to account for dynamic attribute resolution via built-in methods such as type.__getattribute__. When an attacker passes restricted attribute names as string constants (e.g., '__subclasses__'), these appear as ast.Constant nodes in the AST rather than ast.Attribute nodes. Since the filter only checks ast.Attribute nodes against the blocked list, these string constants pass through undetected.

This allows an attacker to use the type.__getattribute__ method as a trampoline to access blocked attributes dynamically at runtime, completely bypassing the intended security restrictions. The vulnerability is classified as CWE-94 (Improper Control of Generation of Code), reflecting the code injection nature of the attack.

Root Cause

The root cause lies in the incomplete implementation of AST-based security filtering. The sandbox design assumes that all dangerous attribute accesses will appear as ast.Attribute nodes in the parsed AST. However, Python's dynamic nature allows attribute names to be passed as string constants and resolved at runtime via methods like type.__getattribute__. Since string literals are parsed as ast.Constant nodes, they evade the attribute blocklist check entirely.

This represents a fundamental misunderstanding of Python's attribute resolution mechanism. The filter should have either:

  1. Blocked calls to type.__getattribute__ and similar reflection methods
  2. Scanned string constants for dangerous attribute names
  3. Implemented runtime-level sandboxing rather than relying solely on static AST analysis

Attack Vector

The attack requires local access with user interaction to execute. An attacker crafts malicious Python code that leverages type.__getattribute__ to access blocked attributes indirectly. Instead of writing object.__subclasses__, which would be caught by the AST filter, the attacker uses type.__getattribute__(object, '__subclasses__'). The string '__subclasses__' is not recognized as an attribute access by the filter, allowing the code to pass validation and execute with full access to Python's introspection capabilities.

From there, the attacker can traverse the class hierarchy to locate dangerous classes (like those with access to os or subprocess), instantiate them, and execute arbitrary system commands. This effectively provides the attacker with full code execution privileges within the context of the PraisonAI process.

The attack mechanism involves passing restricted attribute names as string constants to bypass AST filtering. Since the _execute_code_direct function only inspects ast.Attribute nodes, string constants like '__subclasses__' are never checked against the blocklist. This allows attackers to use type.__getattribute__ as a trampoline to dynamically resolve and access blocked attributes at runtime. For detailed technical analysis, see the GitHub Security Advisory.

Detection Methods for CVE-2026-40158

Indicators of Compromise

  • Presence of type.__getattribute__ or getattr calls with string arguments referencing __subclasses__, __globals__, or __bases__ in agent code submissions
  • Unexpected process spawning or file system access from PraisonAI worker processes
  • Agent code containing obfuscated or encoded string constants that resolve to blocked attribute names
  • Anomalous system calls or network connections originating from the PraisonAI execution context

Detection Strategies

  • Implement runtime monitoring of attribute access patterns within PraisonAI sandboxed code execution
  • Deploy application-layer logging to capture all code submissions to _execute_code_direct for forensic analysis
  • Use endpoint detection solutions to monitor for sandbox escape indicators such as unexpected child processes or system calls
  • Implement string pattern matching for known dangerous attribute names in code submissions, not just AST-level filtering

Monitoring Recommendations

  • Enable comprehensive logging for all code execution requests within PraisonAI agents
  • Monitor process trees to detect unexpected subprocess creation from PraisonAI worker processes
  • Implement file integrity monitoring on systems running PraisonAI to detect unauthorized modifications
  • Set up alerts for any access attempts to sensitive system resources from sandboxed code contexts

How to Mitigate CVE-2026-40158

Immediate Actions Required

  • Upgrade PraisonAI to version 4.5.128 or later immediately
  • Audit all agent code submissions for potential exploitation attempts using type.__getattribute__ patterns
  • Consider temporarily disabling untrusted code execution capabilities until the patch is applied
  • Review system logs for any signs of past exploitation attempts

Patch Information

The vulnerability is fixed in PraisonAI version 4.5.128. Organizations should update to this version or later to remediate the vulnerability. The patch addresses the AST filtering bypass by implementing more comprehensive security checks that account for dynamic attribute resolution methods.

For detailed patch information and security advisory, refer to the GitHub Security Advisory.

Workarounds

  • Restrict code execution to trusted sources only until the patch can be applied
  • Implement additional runtime sandboxing layers such as containerization or restricted user contexts
  • Deploy network segmentation to limit the impact of potential sandbox escapes
  • Consider using alternative sandboxing mechanisms like RestrictedPython or PyPy sandboxing as defense-in-depth measures
bash
# Configuration example - Upgrade PraisonAI to patched version
pip install --upgrade praisonai>=4.5.128

# Verify installed version
pip show praisonai | grep Version

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

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechPraisonai

  • SeverityHIGH

  • CVSS Score8.6

  • EPSS Probability0.03%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityHigh
  • AvailabilityHigh
  • CWE References
  • CWE-94
  • Technical References
  • GitHub Security Advisory
  • Related CVEs
  • CVE-2026-40287: PraisonAI RCE Vulnerability

  • CVE-2026-40288: PraisonAI YAML Workflow RCE Vulnerability

  • CVE-2026-40156: PraisonAI RCE Vulnerability

  • CVE-2026-40088: PraisonAI 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