sandbox-escape cve-2026-25115 n8n pyodide python CRITICAL 9.9
• 10 min read • David Martin

CVE-2026-25115: When Python Sandboxes Fail — n8n's Pyodide Escape

Another week, another sandbox escape. After SandboxJS last week, n8n's Python execution proves that sandboxing dynamic languages is fundamentally broken.

Five critical sandbox escapes (CVSS 9.9) in one platform. This isn't bad luck — it's a pattern.

The n8n Security Crisis

n8n, the popular open-source workflow automation platform with over 200,000 weekly npm downloads, has been hit by a wave of critical vulnerabilities in early 2026. The most concerning? CVE-2026-25115 — a Python sandbox escape that lets authenticated users execute arbitrary system commands.

But it doesn't stop there. In just the past few weeks:

CVE CVSS Vulnerability
CVE-2026-25115 9.9 Python sandbox escape (Pyodide)
CVE-2026-25049 9.9 JavaScript expression sandbox bypass
CVE-2026-25053 9.9 Git node command execution
CVE-2026-1470 9.9 AST sandbox escape (JS with statement)
CVE-2026-0863 9.9 Python format-string sandbox escape

How CVE-2026-25115 Works

n8n's Python Code Node allows users to embed Python scripts in their workflows. To prevent malicious code from compromising the server, n8n uses Pyodide — a WebAssembly-based Python runtime with a blocklist of dangerous functions.

The problem? Blocklists can't enumerate every dangerous capability.

The Exploit Chain

┌─────────────────────────────────────────────────────────────┐ │ n8n Workflow API │ │ │ │ 1. Attacker creates workflow with Python Code Node │ │ ┌──────────────────────────────────────────────────┐ │ │ │ # Looks innocent... │ │ │ │ data = input_data │ │ │ │ result = process(data) │ │ │ │ │ │ │ │ # But hidden in the code: │ │ │ │ _pyodide._base.eval_code("__import__('os')...") │ │ │ └──────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ 2. Pyodide sandbox receives code │ │ - Blocklist checks: __builtins__? ❌ blocked │ │ - But _pyodide._base.eval_code()? ✅ allowed │ │ │ │ │ ▼ │ │ 3. Sandbox ESCAPED — attacker has shell access │ │ $ whoami │ │ n8n-server │ │ $ cat /etc/passwd │ │ root:x:0:0:root:/root:/bin/bash │ │ $ env | grep -i key │ │ STRIPE_API_KEY=sk_live_... │ │ AWS_SECRET_ACCESS_KEY=... │ └─────────────────────────────────────────────────────────────┘

The Core Problem

As JFrog researchers noted:

"These vulnerabilities highlight how difficult it is to safely sandbox dynamic, high-level languages such as JavaScript and Python. Even with multiple validation layers, deny lists, and AST-based controls in place, subtle language features and runtime behaviors can be leveraged to bypass security assumptions."

The blocklist approach is fundamentally flawed:

  • ✗ Python has dozens of ways to access __builtins__
  • ✗ Format strings can leak object references
  • ✗ AttributeError.obj in Python 3.10+ exposes restricted objects
  • ✗ Every Python version adds new introspection capabilities

Why Traditional Security Misses This

When a malicious workflow hits your n8n instance:

✓ API Gateway: Valid authentication token, passes through
✓ WAF: No SQL injection signatures, no XSS patterns, passes through
✓ Rate Limiter: Single request from legitimate user, passes through
✓ n8n Application: User has workflow permissions, executes Python...
✗ Pyodide Sandbox: Blocklist bypassed, code escapes
! Result: Full server compromise, credential theft, lateral movement

The attack is "technically valid" at every layer until it reaches the sandbox — and by then it's too late.

The Contract-First Defense

ContractShield operates at the API layer, before code ever reaches the sandbox. By validating workflow payloads against a strict contract, we can detect and block sandbox escape attempts at the HTTP request level.

What ContractShield Detects

# contractshield.yaml
# ContractShield policy for n8n API rules: - id: python-sandbox-escape match: path: "/api/v1/workflows" methods: [POST, PUT, PATCH] detect: patterns: # Pyodide internals - "_pyodide" - "_base.eval_code" - "pyodide.runPython" # Python introspection - "__builtins__" - "__import__" - "__class__" - "__mro__" - "__subclasses__" - "__globals__" - "__code__" # Dangerous modules - "os.system" - "os.popen" - "subprocess" - "importlib" # Format string attacks - "{0.__class__" - "{.__class__" action: block

Defense in Depth

┌─────────────────────────────────────────────────────────────┐ │ With ContractShield │ │ │ │ Request: POST /api/v1/workflows │ │ Body: { "nodes": [{ "code": "_pyodide._base..." }] } │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ ContractShield PEP │ │ │ │ │ │ │ │ ✗ Pattern detected: "_pyodide._base" │ │ │ │ ✗ Pattern detected: "__import__" │ │ │ │ │ │ │ │ Action: BLOCK │ │ │ │ Response: 403 Forbidden │ │ │ └─────────────────────────────────────────────────────┘ │ │ │ │ │ ✗ Request never reaches n8n │ │ │ │ Sandbox escape? Impossible — code never executed. │ └─────────────────────────────────────────────────────────────┘

The Bigger Picture: Sandboxes Are Not Security

This is the second major sandbox escape we've covered this month:

Platform Language CVE Sandbox Tech Escaped?
SandboxJS JavaScript CVE-2026-25142 Proxy-based Yes
n8n Python CVE-2026-25115 Pyodide/WASM Yes
n8n JavaScript CVE-2026-25049 AST sanitization Yes

The pattern is clear: sandboxing dynamic languages doesn't work. The attack surface is too large, the languages are too flexible, and there's always another escape route.

The solution isn't a better sandbox. It's not letting untrusted code reach the sandbox in the first place.

Recommendations

If You Run n8n

  • → Upgrade immediately to version 2.5.2+ (or 1.123.17+ for 1.x)
  • → Restrict workflow permissions — only trusted users should create/modify workflows
  • → Disable Python if not needed: N8N_PYTHON_ENABLED=false
  • → Add API-layer protection to detect sandbox escape patterns

If You Build Platforms with Code Execution

  • → Don't rely on sandboxes alone — they will be bypassed
  • → Validate inputs at the API layer before code reaches execution
  • → Use allowlists, not blocklists — enumerate what's permitted, not what's forbidden
  • → Assume the sandbox will fail and design your architecture accordingly

Conclusion

CVE-2026-25115 is not an isolated incident. It's part of a systemic failure in how we approach code execution security. Sandboxes provide defense in depth, but they cannot be your only defense.

ContractShield's contract-first approach catches these attacks where they originate — at the API boundary — before malicious code ever gets a chance to probe for sandbox weaknesses.

The sandbox is your last line of defense. Make sure it's not your only one.

Protect your APIs against sandbox escape attacks