Skip to content

ajtazer/heckit / skills/cve-hunting/sandbox-escape

sandbox-escape

Verified

Detect VM/sandbox escape vulnerabilities in packages using node:vm, simpleeval, or custom sandboxes that can be bypassed to achieve code execution.

FileKindSize
SKILL.mdskill md4.8 KB
references/false-positive-indicators.mdmarkdown1.8 KB
references/poc-skeleton.mdmarkdown3.4 KB
references/sinks.mdmarkdown2.4 KB

references/sinks.md

View on GitHub
# Sandbox Mechanisms and Known Escape Patterns

## JavaScript

### node:vm (ALL UNSAFE)
| API | Escapable? | Escape Method |
|-----|-----------|---------------|
| `vm.runInNewContext(code, sandbox)` | YES | Constructor chain |
| `vm.runInThisContext(code)` | YES | Direct access to host context |
| `vm.runInContext(code, context)` | YES | Constructor chain |
| `vm.compileFunction(code)` | YES | Constructor chain via this |
| `new vm.Script(code).runInNewContext()` | YES | Constructor chain |
| `vm.createContext(sandbox)` | N/A | Creates context, doesn't execute |

### vm2 (Deprecated -- MOSTLY UNSAFE)
| Version | Status | Notes |
|---------|--------|-------|
| < 3.9.15 | UNSAFE | Multiple known escapes |
| 3.9.15-3.9.18 | PARTIALLY SAFE | Some escapes patched |
| >= 3.9.19 | MOSTLY SAFE | Most escapes patched but library deprecated |
| Any | DEPRECATED | Use isolated-vm instead |

### isolated-vm (SAFE)
Runs code in a separate V8 isolate. No shared memory, no prototype chain access. Genuinely isolated. The correct choice for running untrusted JS.

### quickjs-emscripten (SAFE)
Runs QuickJS engine compiled to WebAssembly. No access to Node.js APIs.

## Python

### simpleeval
| Version | Status | Notes |
|---------|--------|-------|
| < 0.9.13 | UNSAFE | Multiple bypasses |
| >= 0.9.13 | MOSTLY SAFE | Basic expressions safe, compound types risky |
| EvalWithCompoundTypes | UNSAFE | Allows list/dict comprehensions, more attack surface |

### ast.literal_eval (SAFE)
Only evaluates Python literals: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, None, and frozensets. Cannot execute arbitrary code.

### RestrictedPython
| Version | Status | Notes |
|---------|--------|-------|
| < 5.0 | UNSAFE | Known bypasses |
| >= 5.0 | MEDIUM | Improved but still has attack surface |
| >= 6.0 | MOSTLY SAFE | Major security improvements |

### Python eval/exec (ALWAYS UNSAFE)
No sandbox. Direct code execution. Even with restricted builtins, class hierarchy traversal bypasses restrictions.

## Known Escape Techniques

### Constructor Chain (node:vm)
```js
this.constructor.constructor('return process')()
```

### Python Class Hierarchy
```python
''.__class__.__mro__[1].__subclasses__()  # All loaded classes
().__class__.__base__.__subclasses__()     # Via tuple
```

### Python Function Object Access
```python
func.__globals__  # Global namespace of function
func.__code__     # Code object, can inspect/modify
type.__subclasses__(type)  # All types
```
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall