# CVE-2024-47080: matrix-js-sdk keys sent via `sendSharedHistoryKeys` vulnerable to interception by malicious homeserver

> A malicious homeserver can intercept historical message keys sent by the Matrix JavaScript SDK when using the legacy crypto stack, exposing past encrypted messages.

- **Severity:** High 8.7 (`CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 15 Oct 2024
- **Updated:** 15 Oct 2024
- **Also known as:** DEBIAN-CVE-2024-47080, GHSA-4jf8-g8wp-cx7c, UBUNTU-CVE-2024-47080

## What is CVE-2024-47080?

CVE-2024-47080 is a high-severity vulnerability in matrix-org matrix-js-sdk, published on 15 Oct 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

matrix-js-sdk is the Matrix Client-Server SDK for JavaScript and TypeScript. In matrix-js-sdk versions versions 9.11.0 through 34.7.0, the method `MatrixClient.sendSharedHistoryKeys` is vulnerable to interception by malicious homeservers.  The method was introduced by MSC3061) and is commonly used to share historical message keys with newly invited users, granting them access to past messages in the room. However, it unconditionally sends these "shared" keys to all of the invited user's devices, regardless of whether the user's cryptographic identity is verified or whether the user's devices are signed by that identity. This allows the attacker to potentially inject its own devices to receive sensitive historical keys without proper security checks. Note that this only affects clients running the SDK with the legacy crypto stack. Clients using the new Rust cryptography stack (i.e. those that call `MatrixClient.initRustCrypto()` instead of `MatrixClient.initCrypto()`) are unaffected by this vulnerability, because `MatrixClient.sendSharedHistoryKeys()` raises an exception in such environments. The vulnerability was fixed in matrix-js-sdk 34.8.0 by removing the vulnerable functionality. As a workaround, remove use of affected functionality from clients.

Weakness: CWE-287 (Improper Authentication), CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor)

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

2 open source packages ship an affected version, including matrix-js-sdk.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `matrix-js-sdk` | npm | From 9.11.0 | 34.8.0 |
| `matrix-js-sdk` | npm | From 9.11.0 | 34.8.0 |

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

Upgrade matrix-js-sdk to 34.8.0 or later.

## Is CVE-2024-47080 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2024-47080 is a high-severity vulnerability in matrix-org matrix-js-sdk, published on 15 Oct 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-47080 in the wild and no public exploit code.

Affected packages and fixed versions:
- matrix-js-sdk (npm): affected from 9.11.0; fixed in 34.8.0
- matrix-js-sdk (npm): affected from 9.11.0; fixed in 34.8.0

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-47080/ (Markdown: https://insights.sbomify.com/CVE-2024-47080/index.md)
```

## Sources

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

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