/

CVE-2026-57141

Severity:

CRITICAL RISK

(9.8)

JavaScript Code Injection (CWE-94) in PraisonAI Code Mode

CVE-2026-57141

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

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

A critical code-injection vulnerability in PraisonAI's codeMode tool allows model-influenced JavaScript to execute with the privileges of the PraisonAI process. The risk arises when an attacker can influence the tool's code argument, potentially enabling host access, file operations, credential exposure, and operating-system command execution.

Affected context

The vulnerability occurs in PraisonAI deployments using the codeMode tool before the security fix was applied. The tool executes model-generated JavaScript with a sandboxing pattern and relies on a regular-expression blocklist, which may be insufficient to prevent access to host capabilities when attacker-controlled or attacker-influenced code reaches the execution path.

Exploit preconditions

  • Attack surface: PraisonAI's codeMode tool and its JavaScript execution path
  • Required access: The ability to influence the code argument or otherwise control model-generated code submitted to the tool
  • Trigger point: Execution of the supplied JavaScript by the codeMode implementation
  • Why exploitation is possible: The blocklist does not reliably enforce a complete execution boundary, allowing restricted capabilities to be reached through alternative language and runtime behaviors

Why this happens

The underlying flaw is the execution of model-generated JavaScript through dynamic function construction and a with-based sandbox while treating a regular-expression blocklist as the primary control. This pattern does not provide a reliable capability boundary: JavaScript runtime features may expose global objects or enable indirect access to powerful host modules. The issue maps to CWE-94: Improper Control of Generation of Code, because input that can be influenced by an attacker is executed as program logic.

Potential impact

  • An attacker could execute operating-system commands with PraisonAI process privileges
  • The process could read or modify accessible files
  • Environment variables and embedded credentials may be exposed
  • The host or workload could be compromised
  • Connected agents, tools, and data sources could be manipulated
  • The vulnerability could enable lateral movement where excessive permissions are available

General mitigation guidance

Mitigation generally focuses on removing unrestricted code execution from application trust boundaries and replacing blacklist-based filtering with explicit capability controls.

Common defensive patterns include:

  • Avoiding dynamic evaluation of model-generated or untrusted JavaScript
  • Running unavoidable code execution in an isolated, minimally privileged sandbox with a narrow allowlist of capabilities
  • Separating tool execution from sensitive host resources and credentials
  • Restricting filesystem, network, process, and module access by default
  • Treating model output as untrusted data and applying structured schemas before invoking tools
  • Running the service with a dedicated low-privilege identity and minimal environment secrets
  • Applying resource limits, auditing, and containment around code-execution workers

How teams detect issues like this

Organizations can look for this class of issue through:

  • Static analysis rules targeting new Function, eval, dynamic module loading, and sandbox implementations based on textual blocklists
  • Code review checks for model output flowing directly into interpreters or operating-system interfaces
  • Dependency and policy scanning for tools that expose unrestricted host capabilities to generated code
  • Runtime monitoring of child-process creation, unusual file access, module loading, and outbound connections
  • CI policies requiring explicit security review for code-execution features and privileged tool integrations
  • Automated code review tools that flag dynamic code generation and untrusted data reaching execution sinks

Sources

SourceLink
github.comgithub.com/MervinPraison/PraisonAI/commit/709a0387853709a5e2f2c34680fa64cada252c27
github.comgithub.com/MervinPraison/PraisonAI/releases/tag/v4.6.60
github.comgithub.com/MervinPraison/PraisonAI/security/advisories/GHSA-p69m-4f92-2v84

Frequently asked

questions

It can be exploitable through a remote or integrated interface when that interface allows an attacker to influence the code argument or model output sent to codeMode. Exploitability depends on how the tool is exposed and how requests are authorized.

An attacker generally needs a path to control or meaningfully influence code submitted to the code-execution tool. The resulting impact is determined by the PraisonAI process privileges and its access to files, credentials, and networks.

The safest pattern is to avoid executing untrusted or model-generated code. If execution is essential, use a strongly isolated worker with explicit capabilities, minimal privileges, and no ambient access to host resources; a regular-expression blocklist alone is not sufficient.

Treat model output as untrusted input, prohibit direct flows into dynamic interpreters, enforce allowlisted tool capabilities, minimize runtime permissions and secrets, and continuously monitor code-execution environments.

Find out what's already
exploitable in your codebase.