/

CVE-2026-61447

Severity:

CRITICAL RISK

(10.0)

Code Injection (CWE-94) via LLM Python Agent in PraisonAI

CVE-2026-61447

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution and Secret Exfiltration

Severity:

CRITICAL RISK

(10.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

PraisonAI's CodeAgent component can be coerced into executing arbitrary Python code generated by a large language model without any validation or sandboxing.

When an attacker injects malicious prompts, they can steer the LLM to produce code that runs on the host, exfiltrating environment secrets and achieving full remote code execution.

Affected context

This vulnerability occurs in PraisonAI deployments that use the CodeAgent._execute_python() capability to run LLM-generated Python code directly on the host.

Risk is elevated when:

  • The LLM is exposed to untrusted user input or external content
  • Environment variables or secrets are accessible to the process
  • No sandbox, import restriction, or execution policy is enforced around the agent

Exploit preconditions

  • Attack surface: Any interface (chat, API, workflow) that feeds untrusted input into the LLM driving CodeAgent._execute_python()
  • Required access: Ability to supply or influence prompts or context consumed by the LLM
  • Trigger point: Invocation of the CodeAgent that causes unvalidated Python code to be executed on the host
  • Why exploitation is possible: The agent executes LLM-generated Python without AST inspection, import controls, or sandboxing, so injected instructions can be translated into arbitrary code that the host blindly runs

Why this happens

The underlying issue is direct execution of dynamically generated code with no validation or confinement, matching CWE-94: Improper Control of Generation of Code ('Code Injection').

PraisonAI's CodeAgent treats LLM output as trusted source code, executing it via Python without:

  • Parsing or constraining the abstract syntax tree (AST)
  • Restricting imports, file access, or network operations
  • Enforcing sandbox boundaries or least privilege

This design creates an execution path where attacker-controlled prompts can become executable Python, turning a text interface into a remote shell on the host.

Potential impact

  • Full remote code execution on the host running PraisonAI
  • Exfiltration of environment variables, API keys, and other secrets
  • Unauthorized access to local files, databases, and internal services
  • Installation of backdoors or persistence mechanisms on the system
  • Use of the compromised host as a pivot for lateral movement within the network

General mitigation guidance

Effective mitigation focuses on breaking the direct trust relationship between LLM output and code execution.

Pattern-based defensive strategies include:

  • Introducing strict AST-based validation and allowlists of safe constructs before any generated code is executed
  • Enforcing import and capability restrictions so generated code cannot access sensitive modules, files, or networks by default
  • Running code agents inside an isolated sandbox (e.g., container, VM, or restricted interpreter) with minimal privileges and no direct access to host secrets
  • Applying strong input trust reduction: treat all user-supplied prompts and external context as untrusted, and avoid binding them directly to high-privilege automation
  • Separating duties so that LLM-generated code is subject to human or automated review steps before execution in sensitive environments

How teams detect issues like this

Detection typically involves identifying dangerous code-generation and execution paths rather than specific payloads.

Common approaches include:

  • Static analysis rules that flag use of generic exec, eval, or equivalent dynamic execution in agent components without prior validation
  • Code review checklists that require AST inspection, sandboxing, and capability restriction for any LLM-integrated code execution feature
  • Runtime monitoring of agent processes for unusual file access, network connections, or secret retrieval patterns triggered by LLM workflows
  • Policy enforcement in CI/CD to block deployments where LLM output can reach execution sinks without intermediate safety controls
  • Use of automated security testing tools to simulate prompt injection and verify that generated code cannot escape its intended sandbox

Sources

SourceLink
github.comgithub.com/MervinPraison/PraisonAI/security/advisories/GHSA-2xv2-w8cq-5gxw
vulncheck.comvulncheck.com/advisories/praisonai-before-remote-code-execution-via-codeagent

Frequently asked

questions

Yes. If PraisonAI is exposed via a chat interface, API, or workflow that accepts remote input, an attacker can use prompt injection to cause the LLM to generate malicious Python, which the CodeAgent then executes.

The attacker generally needs the ability to influence the prompts or context sent to the LLM that drives the CodeAgent. They do not need local shell access; the vulnerability turns prompt control into execution control.

The safest pattern is to never execute LLM-generated code directly. Instead, apply strict AST validation and capability allowlists, run any necessary execution inside a hardened sandbox with minimal privileges, and remove direct access to secrets from the agent's environment.

Design LLM features under the assumption that all generated output is untrusted. Avoid direct binding of LLM output to powerful sinks such as code execution, system commands, or configuration changes, enforce sandboxing and policy layers around automation, and integrate security review and automated checks into the development lifecycle of agent-like components.

Find out what's already
exploitable in your codebase.