Skip to main content

CVE-2022-39254: CWE-322: Key Exchange without Entity Authentication in poljar matrix-nio

Medium
Published: Thu Sep 29 2022 (09/29/2022, 14:35:10 UTC)
Source: CVE
Vendor/Project: poljar
Product: matrix-nio

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.

AI-Powered Analysis

AILast updated: 06/22/2025, 16:20:22 UTC

Technical Analysis

CVE-2022-39254 is a vulnerability identified in the poljar matrix-nio Python client library, which is used to interact with the Matrix decentralized communication protocol. Matrix-nio is designed following sans I/O principles to provide asynchronous communication capabilities. The vulnerability exists in versions prior to 0.20 and relates to the handling of room key requests and acceptance. Specifically, when a user requests a room key from their devices, the client correctly remembers the request. However, upon receiving a forwarded room key, the client accepts it without verifying the identity of the sender. This lack of entity authentication during the key exchange process allows a malicious homeserver to inject room keys of questionable validity. Consequently, this flaw can be exploited to perform impersonation attacks, where an attacker could masquerade as a legitimate user or device by forwarding fraudulent encryption keys. This undermines the confidentiality and integrity of encrypted communications within Matrix rooms. The vulnerability is categorized under CWE-322 (Key Exchange without Entity Authentication) and CWE-287 (Improper Authentication), highlighting the failure to authenticate entities during cryptographic key exchanges. The issue was addressed and fixed in version 0.20 of matrix-nio. There are no known exploits in the wild as of the published date, and no CVSS score has been assigned to this vulnerability. The flaw primarily affects the confidentiality and integrity of encrypted messages in Matrix communications, potentially allowing attackers to decrypt or manipulate messages by injecting unauthorized keys.

Potential Impact

For European organizations using Matrix-based communication platforms that rely on the matrix-nio client library versions prior to 0.20, this vulnerability poses a significant risk to secure messaging confidentiality and integrity. Attackers controlling or compromising a homeserver could exploit this flaw to impersonate users or devices by injecting fraudulent room keys, potentially decrypting sensitive communications or injecting malicious content. This could lead to unauthorized disclosure of confidential information, manipulation of communication content, and erosion of trust in secure communication channels. Sectors such as government, finance, healthcare, and critical infrastructure in Europe that adopt Matrix for secure collaboration and messaging are particularly at risk. The decentralized nature of Matrix means that a compromised homeserver in one organization could affect communications with other organizations, amplifying the impact. While the vulnerability does not directly affect availability, the loss of confidentiality and integrity in communications can have severe operational and reputational consequences.

Mitigation Recommendations

European organizations should ensure that all deployments of matrix-nio are upgraded to version 0.20 or later, where the vulnerability has been fixed. It is critical to audit all client implementations and dependencies to confirm no legacy versions remain in use. Organizations should also enforce strict verification and authentication policies for homeservers and devices within their Matrix ecosystems to prevent unauthorized key injections. Monitoring and logging of key exchange events can help detect anomalous behavior indicative of attempted impersonation attacks. Additionally, organizations should consider implementing network segmentation and access controls to limit the exposure of homeservers to untrusted networks or entities. For environments where upgrading immediately is not feasible, temporary mitigations include restricting homeserver trust relationships and increasing user awareness about potential impersonation risks. Finally, organizations should stay informed about updates from the matrix-nio project and the broader Matrix community for any further security advisories.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-09-02T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9845c4522896dcbf463e

Added to database: 5/21/2025, 9:09:25 AM

Last enriched: 6/22/2025, 4:20:22 PM

Last updated: 7/26/2025, 4:02:40 AM

Views: 13

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats