🛡️ CVE-2026-57138 — praisonai
Description
npm PraisonAI codeMode sandbox escape via Function constructor
Summary
The published npm package praisonai exports a TypeScript built-in tool named codeMode. The package describes this tool as executing code in a sandboxed environment, marks its capability as sandbox: true, and registers it through the public tools facade.
The implementation does not create an isolation boundary. It applies a small regular-expression blocklist, sets process and require to undefined inside a plain JavaScript object, and then executes attacker-controlled code with the host process new Function constructor:
```text
const fn = new Function('sandbox', with (sandbox) { ${code} });
const result = fn(sandbox);
```
Because this runs in the host V8 context, code inside codeMode can use the JavaScript prototype chain to recover the real Function constructor:
```text
({}).constructor.constructor('return process')()
```
From a normal CommonJS application script, the recovered process object exposes process.mainModule.require. That bypasses the explicit require('fs') and require('child_process') controls and allows host filesystem access and subprocess execution from code that was supposed to be sandboxed.
Technical Details
Current-head source says codeMode is a built-in package tool and explicitly advertises a sandbox boundary:
```text
src/praisonai-ts/src/tools/builtins/code-mode.ts
13: description: 'Execute code that can import and use other tools in a sandboxed environment',
24: capabilities: {
25: sandbox: true,
26: code: true,
28: packageName: 'praisonai',
85: description: 'Execute code in a sandboxed environment with access to imported tools. Write files, run code, and get results.',
```
The same file implements security as a blocklist of exact source-code patterns:
```text
src/praisonai-ts/src/tools/builtins/code-mode.ts
108: const blockedPatterns = [
109: /require\s*\(\s*['"]child_process['"]\s*\)/,
110: /require\s*\(\s*['"]fs['"]\s*\)/,
111: /import\s+.*from\s+['"]child_process['"]/,
112: /process\.exit/,
113: /eval\s*\(/,
```
It then tries to hide dangerous globals by shadowing names in a normal object:
```text
src/praisonai-ts/src/tools/builtins/code-mode.ts
168: process: undefined,
169: require: undefined,
```
Finally, it executes the untrusted code in the host process using new Function and with (sandbox):
```text
src/praisonai-ts/src/tools/builtins/code-mode.ts
187: const fn = new Function(
188: 'sandbox',
189: with (sandbox) { ${code} }
190: );
191: const result = fn(sandbox);
```
This is not a sandbox. new Function does not create a separate security context, and variable shadowing does not remove access to constructors reachable through normal JavaScript objects.
The tool is reachable through the public npm SDK:
```text
src/praisonai-ts/src/index.ts
117: airweaveSearch, codeMode,
src/praisonai-ts/src/tools/tools.ts
104: // Code Mode
105: registry.register(CODE_MODE_METADATA, createCodeModeTool as ToolFactory);
167: // Code Mode
168: codeMode: (config?: CodeModeConfig) => codeMode(config),
```
Why This Is Not Intended Behavior
This is not merely "the user can execute code because codeMode executes code." The vulnerability is that code which is explicitly described and exposed as sandboxed can escape the intended restrictions.
The implementation itself proves an intended security boundary exists:
CODE_MODE_METADATA.capabilities.sandboxistrue;- the tool description says it executes in a sandboxed environment;
- direct access to
fsandchild_processis explicitly blocked; processandrequireare explicitly shadowed asundefined;allowNetworkdefaults tofalse; and- the config includes security-relevant controls such as
blockedTools,allowedPaths,timeoutMs, andmaxMemoryMb.
The PoV shows those intended restrictions work for naive payloads but fail for a standard JavaScript prototype-chain escape.
PraisonAI's official JavaScript and TypeScript docs describe the npm package as a production-ready agent framework installed with npm install praisonai. Public PraisonAI advisories rate comparable Python sandbox escapes as Critical when user/LLM-supplied code crosses from a claimed sandbox into host execution.
PoV
The PoV installs a published npm package version into a temporary project and runs from a real CommonJS script file. Running from a file is important because normal Node applications expose process.mainModule.require; node -e or stdin do not always reproduce that deployment shape.
Run from a local reproduction checkout:
```fish
node poc/pov_poc.js 1.7.1
```
Observed result:
```json
{
"package": "praisonai",
"version": "1.7.1",
"codeModeExported": true,
"directRequireFsControl": {
"stderr": "Blocked pattern detected: require\\s*\\(\\s*['\"]fs['\"]\\s*\\)",
"exitCode": 1,
"success": false,
"error": "Code contains
How this vulnerability can be exploited
This issue can be reached over the network, attack complexity is low, an attacker needs low-level privileges on the target. No user interaction is required. The scope is changed, meaning a successful attack can affect components beyond the vulnerable one. Rated impact: confidentiality high, integrity high, availability high.
Affected software
CVE-2026-57138 is recorded against 1 package.
- praisonai
Timeline and source
Published on 18 June 2026 and last revised on 20 July 2026. No public exploit is currently recorded for this entry. Record sourced from OSV.
References
Details
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
Affected Packages
| Software | From version | Fixed in |
|---|---|---|
| praisonai | — | — |
References
Similar Threats
- Medium CVE-2026-40112
- High CVE-2026-40113
- High CVE-2026-40114
- Critical CVE-2026-39888
- High CVE-2026-39889
More CVE 2026 advisories
Browse all of CVE 2026 in the advisory index.
Exploit Protection
Are you running praisonai?
CVE-2026-57138 carries CVSS 9.5 Critical rating. BotEraser checks your installation against this and other known CVE records, and blocks IPs associated with exploit activity.
Check My Site For CVE-2026-57138 →No credit card required · Results in minutes
ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.