Site icon API Security Blog

@nestjs/devtools-integration: CSRF to Sandbox Escape Allows for RCE against JS Developers

image
Summary A critical Remote Code Execution (RCE) vulnerability was discovered in the @nestjs/devtools-integration package. When enabled, the package exposes a local development HTTP server with an API endpoint that uses an unsafe JavaScript sandbox (safe-eval-like implementation). Due to improper sandboxing and missing cross-origin protections, any malicious website visited by a developer can execute arbitrary code on their local machine. A full blog post about how this vulnerability was uncovered can be found on Socket's blog. Details The @nestjs/devtools-integration package adds HTTP endpoints to a locally running NestJS development server. One of these endpoints, /inspector/graph/interact, accepts JSON input containing a code field and executes the provided code in a Node.js vm.runInNewContext sandbox. Key issues: 1. Unsafe Sandbox: The sandbox implementation closely resembles the abandoned safe-eval library. The Node.js vm module is explicitly documented as not providing a security mechanism for executing untrusted code. Numerous known sandbox escape techniques allow arbitrary code execution. 2. Lack of Proper CORS/Origin Checking: The server sets Access-Control-Allow-Origin to a fixed domain (https://devtools.nestjs.com) but does not validate the request's Origin or Content-Type. Attackers can craft POST requests with text/plain content type using HTML forms or simple XHR requests, bypassing CORS preflight checks. By chaining these issues, a malicious website can trigger…Read More

Exit mobile version