# CVE-2024-40648: matrix-sdk-crypto's `UserIdentity::is_verified` not checking verification status of own user identity while performing the check

> A malicious homeserver can manipulate identity verification status, causing the SDK to incorrectly trust unverified users during sensitive operations.

- **Severity:** Medium 5.4 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 18 Jul 2024
- **Updated:** 2 Aug 2024
- **Also known as:** GHSA-4qg4-cvh2-crgg, RUSTSEC-2024-0356, openSUSE-SU-2024:14224-1

## What is CVE-2024-40648?

CVE-2024-40648 is a medium-severity authentication bypass vulnerability in matrix-org matrix-rust-sdk, published on 18 Jul 2024. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

matrix-rust-sdk is an implementation of a Matrix client-server library in Rust. The `UserIdentity::is_verified()` method in the matrix-sdk-crypto crate before version 0.7.2 doesn't take into account the verification status of the user's own identity while performing the check and may as a result return a value contrary to what is implied by its name and documentation. If the method is used to decide whether to perform sensitive operations towards a user identity, a malicious homeserver could manipulate the outcome in order to make the identity appear trusted. This is not a typical usage of the method, which lowers the impact. The method itself is not used inside the `matrix-sdk-crypto` crate. The 0.7.2 release of the `matrix-sdk-crypto` crate includes a fix. All users are advised to upgrade. There are no known workarounds for this vulnerability.

Weakness: CWE-287 (Improper Authentication)

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

3 open source packages ship an affected version, including matrix-sdk-crypto.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `matrix-sdk-crypto` | crates.io | All versions | 0.7.2 |
| `matrix-sdk-crypto` | crates.io | All versions | 0.7.2 |
| `matrix-sdk-crypto` | crates.io | From 0.0.0-0 | 0.7.2 |
| `cargo-audit-advisory-db` | openSUSE:Tumbleweed | All versions | 20240730-1.1 |

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

Upgrade matrix-sdk-crypto to 0.7.2 or later.

## Is CVE-2024-40648 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2024-40648 is a medium-severity authentication bypass vulnerability in matrix-org matrix-rust-sdk, published on 18 Jul 2024. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-40648 in the wild and no public exploit code.

Affected packages and fixed versions:
- matrix-sdk-crypto (crates.io): affected all versions; fixed in 0.7.2
- matrix-sdk-crypto (crates.io): affected all versions; fixed in 0.7.2
- matrix-sdk-crypto (crates.io): affected from 0.0.0-0; fixed in 0.7.2

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

## Sources

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

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