CVE-2021-40823: Matrix js sdk Matrix-js-sdk Can Be Tricked Into Vulnerability
MODERATECVE-2021-40823 is a MODERATE (CVSS 5.9) matrix-js-sdk can be tricked into vulnerability (CWE-327: Use of a Broken or Risky Cryptographic Algorithm) affecting Matrix js sdk libraries in the npm ecosystem. The issue involves matrix-js-sdk can be tricked into disclosing e2ee room keys to a participating homeserver. Remediation is available by upgrading affected packages to version 12.4.1.
CVE-2021-40823 at a Glance
Security Impact
CVSS: 5.9
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2021-40823
To remediate this vulnerability, upgrade all affected Matrix js sdk dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install matrix-js-sdk@12.4.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls matrix-js-sdk
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-40823, inspect your project dependencies using npm:
npm ls matrix-js-sdk
Analyze the terminal output to locate any version of Matrix js sdk in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 12.4.1), your application is affected.
Note: The npm ls matrix-js-sdk command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-327: Use of a Broken or Risky Cryptographic Algorithm, where the product uses a broken or risky cryptographic algorithm or protocol. In Matrix js sdk, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-40823 Affected Matrix js sdk Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
matrix-js-sdk
|
npm |
< 12.4.1
|
12.4.1
|
References
Frequently Asked Questions
What is CVE-2021-40823?
Which Matrix js sdk versions are affected?
What version fixes CVE-2021-40823?
Is matrix-js-sdk affected?
What is the CVSS score of CVE-2021-40823?
What CWE is associated with CVE-2021-40823?
How can I check npm dependencies for CVE-2021-40823?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-23cm-x6j7-6hq3",
"modified" : "2023-08-08T19:58:08Z",
"published" : "2021-09-14T20:24:18Z",
"aliases" : [ "CVE-2021-40823" ],
"summary" : "matrix-js-sdk can be tricked into disclosing E2EE room keys to a participating homeserver",
"details" : "### Impact\n\nA logic error in the room key sharing functionality of matrix-js-sdk before 12.4.1 allows a malicious Matrix homeserver† participating in an encrypted room to steal room encryption keys from affected Matrix clients participating in that room. This allows the homeserver to decrypt end-to-end encrypted messages sent by affected clients.\n\n† Or anyone with access to the account of the original recipient of an encrypted message.\n\nKnown clients affected (via their use of vulnerable versions of matrix-js-sdk):\n\n- Element Web (1.8.2 and earlier)\n- Element Desktop (1.8.2 and earlier)\n- SchildiChat Web (1.7.32-sc1 and earlier)\n- SchildiChat Desktop (1.7.32-sc1 and earlier)\n- Cinny (1.2.0 and earlier)\n\n### Patch\n\nThis was fixed in https://github.com/matrix-org/matrix-js-sdk/commit/894c24880da0e1cc81818f51c0db80e3c9fb2be9.\n\n### Workarounds\nTo prevent a homeserver from being able to steal the room keys, vulnerable clients can be taken offline or signed out. If signing out, care should be taken to either set up Secure Backup or export E2E room keys in order to preserve access to past messages.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "matrix-js-sdk"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "12.4.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/matrix-org/matrix-js-sdk/security/advisories/GHSA-23cm-x6j7-6hq3"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-40823"
}, {
"type" : "WEB",
"url" : "https://github.com/matrix-org/matrix-js-sdk/commit/894c24880da0e1cc81818f51c0db80e3c9fb2be9"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/matrix-org/matrix-js-sdk"
}, {
"type" : "WEB",
"url" : "https://github.com/matrix-org/matrix-js-sdk/releases/tag/v12.4.1"
}, {
"type" : "WEB",
"url" : "https://matrix.org/blog/2021/09/13/vulnerability-disclosure-key-sharing"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-200", "CWE-327" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2021-09-14T18:08:41Z",
"nvd_published_at" : "2021-09-13T19:15:00Z"
}
}