CVE-2021-32622: Matrix react sdk Improper File Handling Vulnerability

MODERATE
Advisory Identifier: GHSA-cg57-p69r-3m7p
CVSS 4.2
CWE-434 CWE-74
Published
Advisory Summary

CVE-2021-32622 is a MODERATE (CVSS 4.2) improper file handling vulnerability (CWE-434: Unrestricted Upload of File with Dangerous Type) affecting Matrix react sdk libraries in the npm ecosystem. The issue involves improper file handling in matrix-react-sdk. Remediation is available by upgrading affected packages to version 3.21.0.

CVE-2021-32622 at a Glance

CVE Identifier CVE-2021-32622
GHSA Identifier GHSA-cg57-p69r-3m7p
Severity MODERATE
CVSS v3.1 Base Score 4.2
CWE Classification CWE-434: Unrestricted Upload of File with Dangerous Type
Affected Product Matrix react sdk
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L).

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2021-32622

To remediate this vulnerability, upgrade all affected Matrix react 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.

matrix-react-sdk fixed: 3.21.0
npm install matrix-react-sdk@3.21.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls matrix-react-sdk

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2021-32622, inspect your project dependencies using npm:

npm ls matrix-react-sdk

Analyze the terminal output to locate any version of Matrix react sdk in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.21.0), your application is affected.

Note: The npm ls matrix-react-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-434: Unrestricted Upload of File with Dangerous Type, where the product allows the upload or transfer of dangerous file types that are automatically processed within its environment. In Matrix react 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

Matrix-React-SDK is a react-based SDK for inserting a Matrix chat/voip client into a web page. Before version 3.21.0, when uploading a file, the local file preview can lead to execution of scripts embedded in the uploaded file. This can only occur after several user interactions to open the preview in a separate tab. This only impacts the local user while in the process of uploading. It cannot be exploited remotely or by other users. This vulnerability is patched in version 3.21.0.

CVE-2021-32622 Affected Matrix react sdk Versions

1 component(s)
Fixed Versions:
3.21.0
Product / Package Ecosystem Affected Versions Fixed Version
matrix-react-sdk
npm
< 3.21.0
3.21.0

References

Frequently Asked Questions

What is CVE-2021-32622?
CVE-2021-32622 is a security vulnerability in Matrix react sdk involving Improper file handling in matrix-react-sdk under CWE-434: Unrestricted Upload of File with Dangerous Type.
Which Matrix react sdk versions are affected?
Affected versions include releases prior to 3.21.0 across affected packages: matrix-react-sdk.
What version fixes CVE-2021-32622?
Upgrading to 3.21.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is matrix-react-sdk affected?
Yes, matrix-react-sdk is affected in releases prior to 3.21.0. Upgrade your dependency to 3.21.0 or later.
What is the CVSS score of CVE-2021-32622?
CVE-2021-32622 has a CVSS v3.1 base score of 4.2 (MODERATE) with vector string CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2021-32622?
CVE-2021-32622 is classified under CWE-434: Unrestricted Upload of File with Dangerous Type (The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.).
How can I check npm dependencies for CVE-2021-32622?
Run the dependency tree command: 'npm ls matrix-react-sdk'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-cg57-p69r-3m7p",
  "modified" : "2021-05-19T17:48:44Z",
  "published" : "2022-02-10T23:46:51Z",
  "aliases" : [ "CVE-2021-32622" ],
  "summary" : "Improper file handling in matrix-react-sdk",
  "details" : "Matrix-React-SDK is a react-based SDK for inserting a Matrix chat/voip client into a web page. Before version 3.21.0, when uploading a file, the local file preview can lead to execution of scripts embedded in the uploaded file. This can only occur after several user interactions to open the preview in a separate tab. This only impacts the local user while in the process of uploading. It cannot be exploited remotely or by other users. This vulnerability is patched in version 3.21.0.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "matrix-react-sdk"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.21.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/matrix-react-sdk/security/advisories/GHSA-8796-gc9j-63rv"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32622"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/matrix-react-sdk/pull/5981"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/matrix-react-sdk"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-434", "CWE-74" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-19T17:48:44Z",
    "nvd_published_at" : "2021-05-17T20:15:00Z"
  }
}