OpenSSL engines can be used to bypass and/or disable the Node.js permission model
Node.js 20's experimental permission model allows loading arbitrary OpenSSL engines via crypto.setEngine(), even when native addons are disallowed. An attacker could use a malicious engine to bypass or disable the permission model, escalating privileges.
- Triaged in 7 days
- Fixed in 38 days
- Paid in 38 days
- Disclosed after 2 months
Summary by the program
###OpenSSL engines can be used to bypass the permission model (Medium) (CVE-2023-30586)
Node.js 20 allows loading arbitrary OpenSSL engines when the experimental permission model is enabled, which can bypass and/or disable the permission model.
The crypto.setEngine() API can be used to bypass the permission model when called with a compatible OpenSSL engine. The OpenSSL engine can, for example, disable the permission model in the host process by manipulating the process's stack memory to locate the permission model Permission::enabled_ in the host process's heap memory.
This vulnerability affects all users using the experimental permission model in Node.js 20.
The report
Summary: Node.js 20 allows loading arbitrary OpenSSL engines even when the permission model is enabled, which can bypass and/or disable the permission model.
Description: The permission model implementation permits loading arbitrary native code, e.g., through crypto.setEngine(), even when native addons are disallowed, which is the default configuration. Not only can this code bypass the permission system, it can also disable the permission system entirely, effectively allowing JavaScript code to escalate its own privileges.
Steps To Reproduce:
- Enable the permission model.
- Call, for example,
crypto.setEngine()with a compatible OpenSSL engine. - Arbitrary code execution occurs, unaffected by the permission model.
Impact
The permission model is supposed to restrict the capabilities of running code. However, exploiting this vulnerability allows an attacker to easily bypass the permission model entirely. The OpenSSL engine can, for example, disable the permission model in the host process, and subsequently executed JavaScript code will be unaffected by the previously enabled permission model. This allows running JavaScript code to effectively elevate its own permissions.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The permission model implementation permits loading arbitrary native code through crypto.setEngine() even when native addons are disallowed.
Impact
An attacker could bypass or disable the permission model entirely, allowing JavaScript code to elevate its own permissions.
What the attacker needed
Node.js 20 with experimental permission model enabled; Ability to call crypto.setEngine(); A compatible OpenSSL engine
How it was found
- Enable the permission model.
- Call crypto.setEngine() with a compatible OpenSSL engine.
- Arbitrary code execution occurs, unaffected by the permission model.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Node.js has an experimental feature called the permission model that is meant to limit what code can do, like a sandbox. However, a function called crypto.setEngine() lets you load extra native code (an OpenSSL engine) even when other native code is blocked. That loaded code can then turn off the permission model, so the sandbox fails.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.