Skip to main content
HIGH Vulnerabilities #Node Js#RCE

Critical Type Confusion in isolated-vm Leads to Host RCE

4 min read Runtime Rebel Intel
Primary source: securityweek.com

This article was written by a language model from the source above and was not reviewed by a human before publication. Verify anything operational against the original. Editorial policy

Key points
  • A critical type confusion vulnerability in the isolated-vm Node.js library can lead to remote code execution on the host.
  • Affected systems include any embedder running untrusted code in an isolate and sharing a Reference, or passing a caller-influenced transferList.
  • Immediate remediation requires updating isolated-vm to versions 6.2.0 or 7.0.1 to patch the vulnerability.

Advertisement

Overview of the Critical isolated-vm Vulnerability

A critical-severity type confusion vulnerability has been identified in the isolated-vm Node.js library. This flaw could enable threat actors to achieve remote code execution (RCE) on the host system, posing a significant risk to applications that rely on isolated-vm for sandboxing untrusted JavaScript code. The isolated-vm library is widely used by developers to access the V8 JavaScript engine’s Isolate interface, creating completely isolated JavaScript environments with their own heap memory, execution state, and garbage collector. These V8 Isolates facilitate the execution of multiple sandboxed JavaScript code instances on the same machine without the overhead of containers or virtual machines.

According to SecurityWeek, successful exploitation of this security defect can lead to a crash (denial-of-service) or a control-flow hijack of the host process, ultimately enabling RCE. The vulnerability, which currently has no assigned CVE identifier, impacts the ExternalCopy function, a key component for securely copying data across Isolates.

Understanding the isolated-vm Type Confusion RCE

The core of this vulnerability lies within the ExternalCopy function, which is responsible for serializing data in one Isolate and reconstructing it in another instance. For performance optimization, ExternalCopy utilizes a transferList mechanism, where large ArrayBuffers are listed, and their underlying memory is transferred by detaching the buffer from the source and handing it to the destination.

EndorLabs explains that the issue stems from a time-of-check/time-of-use (TOCTOU) weakness. During data transfer, the reconstructor iterates over the byte array list twice, with the second pass implicitly trusting the results of the first. However, if an element within the transfer_list JavaScript array is defined as a getter, iterating it would not return the same value for each pass. An attacker can abuse this discrepancy to dereference an attacker-controlled pointer, leading to arbitrary memory access.

While the ExternalCopy constructor is generally only accessible from the host, a guest Isolate can still target ivm.Reference, the mechanism through which the host exposes objects to the sandbox. By manipulating ivm.Reference, a guest can construct a malicious transferList and trigger the vulnerability. The advisory from isolated-vm states that “Any embedder that runs untrusted code in an isolate and shares even one Reference into it is affected. Host code that passes a caller-influenced array as transferList is affected directly, without any guest.”

This vulnerability primarily resides in the native glue code—the C++ binding responsible for serializing values across the Isolate boundary. This layer, written in a memory-unsafe language, manipulates raw V8 handles and backing-store pointers. A single unchecked cast on a re-read value during a security-sensitive operation was sufficient to transform a correct isolation primitive into a full escape.

Mitigation and Recommendations for V8 Isolate Security Vulnerability

Given the critical nature of this flaw, immediate action is required to protect affected systems. Organisations running applications that use the isolated-vm library should prioritise patching.

Prioritize Patching and Updates

Patches for this isolated-vm type confusion RCE vulnerability have been released and are included in isolated-vm versions 6.2.0 and 7.0.1. These updates prevent user JavaScript from executing during the copy operation, thereby eliminating the TOCTOU race condition. Defenders should immediately upgrade their isolated-vm dependencies to one of these patched versions or newer. This is the most critical step to address the risk.

Secure Coding Practices and Input Validation

Even after patching, it is prudent to review and enhance secure coding practices, especially when dealing with untrusted code within V8 Isolates. Developers should be cautious when exposing objects to guest Isolates via ivm.Reference and ensure that any transferList inputs influenced by caller data are thoroughly validated. Explicitly checking for malicious or unexpected data types and structures before passing them to ExternalCopy can add an additional layer of defence.

Monitoring for Suspicious Activity

Organizations should implement enhanced monitoring for processes utilising isolated-vm. Look for unusual process behaviour, unexpected network connections originating from sandboxed environments, or crashes indicative of exploitation attempts. Proactive monitoring can help detect and respond to potential exploitation attempts if patches have not yet been applied or if other unknown vulnerabilities exist. Staying informed on isolated-vm security advisories is also key for maintaining a secure environment.

Related: Flowise RCE via CVE-2024-31621 — Mitigation Guide, Dify AI Platform Vulnerabilities: How to Mitigate DifyTap Exploit

Advertisement

Advertisement