# OpenSSL engines can be used to bypass and/or disable the Node.js permission model

Node.js 20 permission model allowed crypto.setEngine() to load arbitrary OpenSSL engines, letting JS run native code that disables the permission model and escalates privileges.

- Payout: $2,540
- Severity: medium
- Program: Internet Bug Bounty
- Found by: tniessen
- Disclosed: 2023-10-07
- CVE: CVE-2023-30586
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/2091137
- Library page: https://bugbountylibrary.com/r/h1%3A2091137
- Tags: area:oss domain:oss impact:privesc impact:rce kind:bounty platform:hackerone sev:medium tech:nodejs technique:source-review vuln:misconfiguration vuln:privilege-escalation vuln:sandbox-escape

**Target:** Node.js 20 experimental permission model / crypto.setEngine()
**Root cause:** The permission model blocked native addons but not OpenSSL engine loading via crypto.setEngine(), which loads arbitrary native code into the process.
**Steps:**
1. Enable the Node.js 20 permission model.
2. Call `crypto.setEngine()` with a compatible OpenSSL engine.
3. Engine native code executes unrestricted, bypassing the permission model.
4. Engine manipulates process stack/heap to locate `Permission::enabled_` and disable the permission model.
**How found:** Researcher observed the permission model blocks native addons by default but overlooked the crypto.setEngine() path, which also loads native code; hypothesized it could both bypass and disable the model.
**Exploitation:** Attacker-controlled JS calls crypto.setEngine() with a malicious OpenSSL engine; the engine's native code runs outside the permission model's restrictions and can walk the process stack to find and flip Permission::enabled_ in heap memory, disabling the model so subsequent JS runs unconfined.
**Escalation:** Native engine code disables the permission model in-process, so all later JavaScript executes without restrictions, turning a sandboxed context into full privilege escalation.
**Insight:** When auditing a sandbox/permission model, enumerate every API that loads native code (OpenSSL engines, FFI, JIT, dlopen paths), not just the obvious addon loader; in-process native code can often locate and flip the sandbox's own state flags in memory.

