CVE-2024-42369: Matrix js sdk Matrix-js-sdk Will Freeze When A Vulnerability

MODERATE
Advisory Identifier: GHSA-vhr5-g3pm-49fm
CVSS 4.1
CWE-674
Published
Advisory Summary

CVE-2024-42369 is a MODERATE (CVSS 4.1) matrix-js-sdk will freeze when a vulnerability (CWE-674: Uncontrolled Recursion) affecting Matrix js sdk libraries in the npm ecosystem. The issue involves matrix-js-sdk will freeze when a user sets a room with itself as a its predecessor. Remediation is available by upgrading affected packages to version 34.3.1.

CVE-2024-42369 at a Glance

CVE Identifier CVE-2024-42369
GHSA Identifier GHSA-vhr5-g3pm-49fm
Severity MODERATE
CVSS v3.1 Base Score 4.1
CWE Classification CWE-674: Uncontrolled Recursion
Affected Product Matrix js sdk
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.1

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

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

How to Fix CVE-2024-42369

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

matrix-js-sdk fixed: 34.3.1
npm install matrix-js-sdk@34.3.1
Verify Direct and Transitive Dependencies

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

npm ls matrix-js-sdk

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-42369, inspect your project dependencies using npm:

npm ls matrix-js-sdk

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

Note: The npm ls matrix-js-sdk command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-674: Uncontrolled Recursion, where the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. In Matrix js sdk, 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

### Impact A malicious homeserver can craft a room or room structure such that the predecessors form a cycle. The matrix-js-sdk's `getRoomUpgradeHistory` function will infinitely recurse in this case, causing the code to hang. This method is public but also called by the 'leaveRoomChain()' method, so leaving a room will also trigger the bug. Even if the CVSS score would be 4.1 ([AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:N/A:L](https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:N/A:L&version=3.1)) we classify this as High severity issue. ### Patches This was patched in matrix-js-sdk 34.3.1. ### Workarounds Sanity check rooms before passing them to the matrix-js-sdk or avoid calling either `getRoomUpgradeHistory` or `leaveRoomChain`. ### References N/A.

CVE-2024-42369 Affected Matrix js sdk Versions

1 component(s)
Fixed Versions:
34.3.1
Product / Package Ecosystem Affected Versions Fixed Version
matrix-js-sdk
npm
< 34.3.1
34.3.1

References

Frequently Asked Questions

What is CVE-2024-42369?
CVE-2024-42369 is a security vulnerability in Matrix js sdk involving matrix-js-sdk will freeze when a user sets a room with itself as a its predecessor under CWE-674: Uncontrolled Recursion.
Which Matrix js sdk versions are affected?
Affected versions include releases prior to 34.3.1 across affected packages: matrix-js-sdk.
What version fixes CVE-2024-42369?
Upgrading to 34.3.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is matrix-js-sdk affected?
Yes, matrix-js-sdk is affected in releases prior to 34.3.1. Upgrade your dependency to 34.3.1 or later.
What is the CVSS score of CVE-2024-42369?
CVE-2024-42369 has a CVSS v3.1 base score of 4.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:N/A:L.
What CWE is associated with CVE-2024-42369?
CVE-2024-42369 is classified under CWE-674: Uncontrolled Recursion (The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.).
How can I check npm dependencies for CVE-2024-42369?
Run the dependency tree command: 'npm ls matrix-js-sdk'. 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-vhr5-g3pm-49fm",
  "modified" : "2024-08-20T18:35:28Z",
  "published" : "2024-08-20T18:35:27Z",
  "aliases" : [ "CVE-2024-42369" ],
  "summary" : "matrix-js-sdk will freeze when a user sets a room with itself as a its predecessor",
  "details" : "### Impact\nA malicious homeserver can craft a room or room structure such that the predecessors form a cycle. The matrix-js-sdk's `getRoomUpgradeHistory` function will infinitely recurse in this case, causing the code to hang. This method is public but also called by the 'leaveRoomChain()' method, so leaving a room will also trigger the bug.\n\nEven if the CVSS score would be 4.1 ([AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:N/A:L](https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:N/A:L&version=3.1)) we classify this as High severity issue.\n\n### Patches\nThis was patched in matrix-js-sdk 34.3.1.\n\n### Workarounds\nSanity check rooms before passing them to the matrix-js-sdk or avoid calling either `getRoomUpgradeHistory` or `leaveRoomChain`.\n\n### References\nN/A.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:N/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:L/SC:N/SI:N/SA:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "matrix-js-sdk"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "34.3.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/matrix-js-sdk/security/advisories/GHSA-vhr5-g3pm-49fm"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-42369"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/matrix-js-sdk/commit/a0efed8b881b3db6c9f2c71d6a6e74c2828978c6"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/matrix-org/matrix-js-sdk"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-674" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-08-20T18:35:27Z",
    "nvd_published_at" : "2024-08-20T15:15:21Z"
  }
}