# Dependency Policy Bypass via process.binding

Node's experimental policy.json dependency restrictions can be bypassed via process.binding('spawn_sync') to spawn a child node process and run arbitrary code.

- Payout: $635
- Severity: medium
- Program: Internet Bug Bounty
- Found by: leodog896
- Disclosed: 2023-09-09
- CVE: CVE-2023-32559
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/2120719
- Library page: https://bugbountylibrary.com/r/h1%3A2120719
- Tags: area:oss domain:oss impact:internal-access impact:rce kind:bounty platform:hackerone sev:medium tech:nodejs technique:source-review vuln:access-control vuln:misconfiguration vuln:sandbox-escape

**Target:** Node.js experimental policy mechanism (--experimental-policy)
**Root cause:** process.binding() exposes internal C++ bindings (e.g. spawn_sync) that are not subject to the policy.json dependency manifest checks, so code loaded through them escapes the policy's module restrictions.
**Steps:**
1. Create `policy.json` with `onerror: exit` and a `file:` scope with empty `dependencies: {}` and `integrity: true`.
2. In `app.js`, call `const { spawn } = process.binding("spawn_sync")`.
3. Invoke `spawn({file:"node", args:["node","-"], stdio:[{type:"pipe",input:Buffer.from(script)},...]})` to run an arbitrary inline script.
4. Run `node --experimental-policy=policy.json app.js`; the spawned script reads `/etc/passwd` despite the empty dependency list.
5. Confirm direct `require('fs')` under the same policy fails with `ERR_MANIFEST_DEPENDENCY_MISSING`.
**How found:** Observed that policy enforcement operates at the module-loader level, then hypothesized that internal bindings reachable via process.binding bypass the loader entirely; tested spawn_sync to spawn a child node process.
**Exploitation:** Attacker who can supply JS executed under a restrictive policy.json uses process.binding('spawn_sync') to spawn a fresh node process with an inline script, escaping the dependency allowlist and achieving arbitrary code execution/read of files like /etc/passwd.
**Insight:** Policy/sandbox mechanisms enforced in the JS module loader can be bypassed by reaching lower-level internal bindings (process.binding) that don't route through the loader—enumerate such escape hatches when auditing any JS-level restriction.

## Proof of concept (copied exactly from the original report)

**policy.json with empty dependencies**

```
{
  "onerror": "exit",
  "scopes": {
    "file:": {
      "integrity": true,
      "dependencies": {}
    }
  }
}
```

**Command running node with experimental policy**

```
node --experimental-policy=policy.json app.js
```

