CVE-2023-30609: Matrix react sdk HTML Injection Vulnerability

HIGH
Advisory Identifier: GHSA-xv83-x443-7rmw
CVSS 8.2
CWE-79 CWE-74
Published
Advisory Summary

CVE-2023-30609 is a HIGH (CVSS 8.2) html injection vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Matrix react sdk libraries in the npm ecosystem. The issue involves html injection in search results via plaintext message highlighting. Remediation is available by upgrading affected packages to version 3.71.0.

CVE-2023-30609 at a Glance

CVE Identifier CVE-2023-30609
GHSA Identifier GHSA-xv83-x443-7rmw
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Matrix react sdk
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.2

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

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

How to Fix CVE-2023-30609

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.71.0
npm install matrix-react-sdk@3.71.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-2023-30609, 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.71.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-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. 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

### Impact Plain text messages containing HTML tags are rendered as HTML in the search results. To exploit this, an attacker needs to trick a user into searching for a specific message containing an HTML injection payload. Cross-site scripting is possible by including resources from `recaptcha.net` and `gstatic.com` which are included in the default CSP. Thanks to [Cadence Ember](https://cadence.moe/) for finding the injection and to [S1m](https://github.com/p1gp1g/) for finding possible XSS vectors. ### Patches Version 3.71.0 of the SDK fixes the issue. ### Workarounds Restarting the client will clear the injection.

CVE-2023-30609 Affected Matrix react sdk Versions

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

References

Frequently Asked Questions

What is CVE-2023-30609?
CVE-2023-30609 is a security vulnerability in Matrix react sdk involving HTML injection in search results via plaintext message highlighting under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Matrix react sdk versions are affected?
Affected versions include releases prior to 3.71.0 across affected packages: matrix-react-sdk.
What version fixes CVE-2023-30609?
Upgrading to 3.71.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.71.0. Upgrade your dependency to 3.71.0 or later.
What is the CVSS score of CVE-2023-30609?
CVE-2023-30609 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:L.
What CWE is associated with CVE-2023-30609?
CVE-2023-30609 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2023-30609?
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-xv83-x443-7rmw",
  "modified" : "2023-09-22T19:51:24Z",
  "published" : "2023-04-25T19:48:11Z",
  "aliases" : [ "CVE-2023-30609" ],
  "summary" : "HTML injection in search results via plaintext message highlighting",
  "details" : "### Impact\nPlain text messages containing HTML tags are rendered as HTML in the search results. To exploit this, an attacker needs to trick a user into searching for a specific message containing an HTML injection payload.\n\nCross-site scripting is possible by including resources from `recaptcha.net` and `gstatic.com` which are included in the default CSP.\n\nThanks to [Cadence Ember](https://cadence.moe/) for finding the injection and to [S1m](https://github.com/p1gp1g/) for finding possible XSS vectors.\n\n### Patches\nVersion 3.71.0 of the SDK fixes the issue.\n\n### Workarounds\nRestarting the client will clear the injection.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "matrix-react-sdk"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.71.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/matrix-react-sdk/security/advisories/GHSA-xv83-x443-7rmw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-30609"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/matrix-react-sdk/commit/bf182bc94556849d7acdfa0e5fdea2aa129ea826"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/matrix-org/matrix-react-sdk"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.71.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74", "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-04-25T19:48:11Z",
    "nvd_published_at" : "2023-04-25T21:15:10Z"
  }
}