CVE-2024-27935: Deno Deno's Node.js Compatibility Runtime Has Vulnerability

HIGH
Advisory Identifier: GHSA-wrqv-pf6j-mqjp
CVSS 7.2
CWE-488
Published
Advisory Summary

CVE-2024-27935 is a HIGH (CVSS 7.2) deno's node.js compatibility runtime has vulnerability (CWE-488: Exposure of Data Element to Wrong Session) affecting Deno libraries in the crates.io ecosystem. The issue involves deno's node.js compatibility runtime has cross-session data contamination. Remediation is available by upgrading affected packages to version 1.36.3.

CVE-2024-27935 at a Glance

CVE Identifier CVE-2024-27935
GHSA Identifier GHSA-wrqv-pf6j-mqjp
Severity HIGH
CVSS v3.1 Base Score 7.2
CWE Classification CWE-488: Exposure of Data Element to Wrong Session
Affected Product Deno
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 7.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:N/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability Low (A:L)

How to Fix CVE-2024-27935

To remediate this vulnerability, upgrade all affected Deno dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

deno fixed: 1.36.3
Upgrade deno to 1.36.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for deno

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-27935, inspect your project dependencies for Deno:

inspect dependencies for deno

Analyze the terminal output to locate any version of Deno in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.36.3), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-488: Exposure of Data Element to Wrong Session, where the product does not sufficiently enforce boundaries between the states of different sessions, causing data to be provided to, or used by, the wrong session. In Deno, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary A vulnerability in Deno's Node.js compatibility runtime allows for cross-session data contamination during simultaneous asynchronous reads from Node.js streams sourced from sockets or files. The issue arises from the re-use of a global buffer (BUF) in stream_wrap.ts used as a performance optimization to limit allocations during these asynchronous read operations. This can lead to data intended for one session being received by another session, potentially resulting in data corruption and unexpected behavior. ### Details A bug in Deno's Node.js compatibility runtime results in data cross-reception during simultaneous asynchronous reads from Node.js network streams. When multiple independent network socket connections are involved, this vulnerability can be triggered. For instance, two separate server sockets that receive data from their respective client sockets and then echo the received data back to the client using Node.js streams may experience an issue where data from one socket may appear on another socket. Due to the improper isolation of the global buffer (`BUF`), data sent by one socket can end up being incorrectly received by another socket. Consequently, data intended for one session may be exposed to another session, potentially leading to data corruption and unexpected behavior. This buffer was introduced as a performance optimization to avoid excessive allocations during network read operations. In cases where the [net.Stream](https://nodejs.org/api/net.html) is connected to a remote server such as a database or key/value store such as Redis, this may result in a packet received on one connection being presented to another, causing data cross-contamination between multiple users and potentially leaking sensitive information. It is important to note that this vulnerability does not affect Deno network streams created with the `Deno.listen` and `Deno.connect` APIs. The impact of this issue may extend beyond node.js network streams, however, and may also affect asynchronous reads from non-network node.js Stream such as those created from files. ### PoC https://github.com/denoland/deno/issues/20188 ### Impact This affects all users of Deno that use the node.js compatibility layer for network communication or other streams, including packages that may require node.js libraries indirectly.

CVE-2024-27935 Affected Deno Versions

1 component(s)
Fixed Versions:
1.36.3
Product / Package Ecosystem Affected Versions Fixed Version
deno
crates.io
≥ 1.35.1
< 1.36.3
1.36.3

References

Frequently Asked Questions

What is CVE-2024-27935?
CVE-2024-27935 is a security vulnerability in Deno involving Deno's Node.js Compatibility Runtime has Cross-Session Data Contamination under CWE-488: Exposure of Data Element to Wrong Session.
Which Deno versions are affected?
Affected versions include releases prior to 1.36.3 across affected packages: deno.
What version fixes CVE-2024-27935?
Upgrading to 1.36.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is deno affected?
Yes, deno is affected in releases prior to 1.36.3. Upgrade your dependency to 1.36.3 or later.
What is the CVSS score of CVE-2024-27935?
CVE-2024-27935 has a CVSS v3.1 base score of 7.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:N/A:L.
What CWE is associated with CVE-2024-27935?
CVE-2024-27935 is classified under CWE-488: Exposure of Data Element to Wrong Session (The product does not sufficiently enforce boundaries between the states of different sessions, causing data to be provided to, or used by, the wrong session.).
How can I check crates.io dependencies for CVE-2024-27935?
Run the dependency tree command: 'inspect dependencies for deno'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-wrqv-pf6j-mqjp",
  "modified" : "2024-03-21T18:29:19Z",
  "published" : "2024-03-05T20:49:14Z",
  "aliases" : [ "CVE-2024-27935" ],
  "summary" : "Deno's Node.js Compatibility Runtime has Cross-Session Data Contamination",
  "details" : "### Summary\n\nA vulnerability in Deno's Node.js compatibility runtime allows for cross-session data contamination during simultaneous asynchronous reads from Node.js streams sourced from sockets or files. The issue arises from the re-use of a global buffer (BUF) in stream_wrap.ts used as a performance optimization to limit allocations during these asynchronous read operations. This can lead to data intended for one session being received by another session, potentially resulting in data corruption and unexpected behavior.\n\n### Details\n\nA bug in Deno's Node.js compatibility runtime results in data cross-reception during simultaneous asynchronous reads from Node.js network streams. When multiple independent network socket connections are involved, this vulnerability can be triggered. For instance, two separate server sockets that receive data from their respective client sockets and then echo the received data back to the client using Node.js streams may experience an issue where data from one socket may appear on another socket. Due to the improper isolation of the global buffer (`BUF`), data sent by one socket can end up being incorrectly received by another socket. Consequently, data intended for one session may be exposed to another session, potentially leading to data corruption and unexpected behavior.\n\nThis buffer was introduced as a performance optimization to avoid excessive allocations during network read operations.\n\nIn cases where the [net.Stream](https://nodejs.org/api/net.html) is connected to a remote server such as a database or key/value store such as Redis, this may result in a packet received on one connection being presented to another, causing data cross-contamination between multiple users and potentially leaking sensitive information.\n\nIt is important to note that this vulnerability does not affect Deno network streams created with the `Deno.listen` and `Deno.connect` APIs. \n\nThe impact of this issue may extend beyond node.js network streams, however, and may also affect asynchronous reads from non-network node.js Stream such as those created from files.\n\n### PoC\n\nhttps://github.com/denoland/deno/issues/20188\n\n### Impact\n\nThis affects all users of Deno that use the node.js compatibility layer for network communication or other streams, including packages that may require node.js libraries indirectly.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "deno"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.35.1"
      }, {
        "fixed" : "1.36.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/denoland/deno/security/advisories/GHSA-wrqv-pf6j-mqjp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-27935"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/denoland/deno/issues/20188"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/denoland/deno/commit/3e9fb8aafd9834ebacd27734cea4310caaf794c6"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/denoland/deno"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-488" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-03-05T20:49:14Z",
    "nvd_published_at" : "2024-03-21T02:52:22Z"
  }
}