# CVE-2024-42369: A room with itself as a its predecessor will freeze matrix-js-sdk

> A malicious homeserver can cause the Matrix JavaScript SDK to hang via infinite recursion when processing cyclic room structures, requiring an upgrade.

- **Severity:** Medium 4.1 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 20 Aug 2024
- **Updated:** 3 Sep 2024
- **Also known as:** DEBIAN-CVE-2024-42369, GHSA-vhr5-g3pm-49fm, UBUNTU-CVE-2024-42369, openSUSE-SU-2024:14288-1, openSUSE-SU-2024:14289-1

## What is CVE-2024-42369?

CVE-2024-42369 is a medium-severity denial of service vulnerability in matrix-org matrix-js-sdk, published on 20 Aug 2024. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

matrix-js-sdk is a Matrix messaging protocol Client-Server SDK for JavaScript. 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. This was patched in matrix-js-sdk 34.3.1.

Weakness: CWE-674 (Uncontrolled Recursion)

## Which versions are affected by CVE-2024-42369?

2 open source packages ship an affected version, including matrix-js-sdk. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `matrix-js-sdk` | npm | All versions | 34.3.1 |
| `matrix-js-sdk` | npm | All versions | 34.3.1 |
| `element-desktop` | openSUSE:Tumbleweed | All versions | 1.11.75-1.1 |
| `element-web` | openSUSE:Tumbleweed | All versions | 1.11.75-1.1 |

Products: Matrix Javascript Sdk.

## How do I fix CVE-2024-42369?

Upgrade matrix-js-sdk to 34.3.1 or later.

## Is CVE-2024-42369 being exploited?

There is no known exploitation of CVE-2024-42369 in the wild and no public exploit code.

## Other vulnerabilities in matrix-org matrix-js-sdk

- [CVE-2022-39250](https://insights.sbomify.com/CVE-2022-39250/): Matrix JavaScript SDK vulnerable to key/device identifier confusion in SAS verification (high 8.6)
- [CVE-2022-39251](https://insights.sbomify.com/CVE-2022-39251/): Matrix Javascript SDK vulnerable to Olm/Megolm protocol confusion (high 8.6)
- [CVE-2022-36059](https://insights.sbomify.com/CVE-2022-36059/): Prototype pollution in matrix-js-sdk (high 8.2)
- [CVE-2023-28427](https://insights.sbomify.com/CVE-2023-28427/): Prototype pollution in matrix-js-sdk (high 8.2)
- [CVE-2022-39249](https://insights.sbomify.com/CVE-2022-39249/): Matrix Javascript SDK vulnerable to impersonation via forwarded Megolm sessions (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-42369 and fix it if it is affected.

What it is: CVE-2024-42369 is a medium-severity denial of service vulnerability in matrix-org matrix-js-sdk, published on 20 Aug 2024. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2024-42369 in the wild and no public exploit code.

Affected packages and fixed versions:
- matrix-js-sdk (npm): affected all versions; fixed in 34.3.1
- matrix-js-sdk (npm): affected all versions; fixed in 34.3.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-42369/ (Markdown: https://insights.sbomify.com/CVE-2024-42369/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-42369
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-42369
- OSV: https://osv.dev/vulnerability/CVE-2024-42369

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-42369/
Summaries are generated and may contain mistakes; the official description above is the record.
