CVE-2023-44390: HtmlSanitizer Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-43cp-6p3q-2pc4
CVSS 6.1
CWE-79
Published
Advisory Summary

CVE-2023-44390 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting HtmlSanitizer libraries in the NuGet ecosystem. The issue involves htmlsanitizer vulnerable to cross-site scripting in foreign content. Remediation is available by upgrading affected packages to version 8.0.723, 8.1.722-beta.

CVE-2023-44390 at a Glance

CVE Identifier CVE-2023-44390
GHSA Identifier GHSA-43cp-6p3q-2pc4
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product HtmlSanitizer
Package Ecosystem NuGet
Published Date
Last Updated

Security Impact

CVSS: 6.1

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

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

How to Fix CVE-2023-44390

To remediate this vulnerability, upgrade all affected HtmlSanitizer dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

HtmlSanitizer fixed: 8.0.723
Upgrade HtmlSanitizer to 8.0.723
HtmlSanitizer fixed: 8.1.722-beta
Upgrade HtmlSanitizer to 8.1.722-beta
Verify Direct and Transitive Dependencies

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

inspect dependencies for HtmlSanitizer

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-44390, inspect your project dependencies for HtmlSanitizer:

inspect dependencies for HtmlSanitizer

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

Note: Verify declared build manifests and deployed runtime container environments.

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 HtmlSanitizer, 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 The vulnerability occurs in configurations where foreign content is allowed, i.e. either `svg` or `math` are in the list of allowed elements. Specifically, the requirements for the vulnerability are: 1. Allowing one foreign element: `svg`, or `math` 2. Comments or one raw text element: `iframe`, `noembed`, `xmp`, `title`, `noframes`, `style` or `noscript` Configurations that meet the above requirements plus the following are vulnerable to an additional vulnerability: - Any HTML integration element: `title`, `desc`, `mi`, `mo`, `mn`, `ms`, `mtext`, `annotation-xml`. In case an application sanitizes user input with a vulnerable configuration, an attacker could bypass the sanitization and inject arbitrary HTML, including JavaScript code. Note that in the default configuration the vulnerability is not present. ### Patches The vulnerability has been fixed in versions 8.0.723 and 8.1.722-beta (preview version). ### Workarounds Disallow foreign elements `svg` and `math`. This is the case in the default configuration, which is therefore not affected by the vulnerability.

CVE-2023-44390 Affected HtmlSanitizer Versions

2 component(s)
Fixed Versions:
8.0.7238.1.722-beta
Product / Package Ecosystem Affected Versions Fixed Version
HtmlSanitizer
NuGet
< 8.0.723
8.0.723
HtmlSanitizer
NuGet
≥ 8.1.0-beta
< 8.1.722-beta
8.1.722-beta

References

Frequently Asked Questions

What is CVE-2023-44390?
CVE-2023-44390 is a security vulnerability in HtmlSanitizer involving HtmlSanitizer vulnerable to Cross-site Scripting in Foreign Content under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which HtmlSanitizer versions are affected?
Affected versions include releases prior to 8.0.723, 8.1.722-beta across affected packages: HtmlSanitizer.
What version fixes CVE-2023-44390?
Upgrading to 8.0.723, 8.1.722-beta (or the latest patched release for your respective branch) resolves the vulnerability.
Is HtmlSanitizer affected?
Yes, HtmlSanitizer is affected in releases prior to 8.0.723, 8.1.722-beta. Upgrade your dependency to 8.0.723, 8.1.722-beta or later.
What is the CVSS score of CVE-2023-44390?
CVE-2023-44390 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2023-44390?
CVE-2023-44390 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 NuGet dependencies for CVE-2023-44390?
Run the dependency tree command: 'inspect dependencies for HtmlSanitizer'. 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-43cp-6p3q-2pc4",
  "modified" : "2023-10-05T19:39:51Z",
  "published" : "2023-10-04T18:52:35Z",
  "aliases" : [ "CVE-2023-44390" ],
  "summary" : "HtmlSanitizer vulnerable to Cross-site Scripting in Foreign Content",
  "details" : "### Impact\n\nThe vulnerability occurs in configurations where foreign content is allowed, i.e. either `svg` or `math` are in the list of allowed elements.\nSpecifically, the requirements for the vulnerability are:\n\n1. Allowing one foreign element: `svg`, or `math`\n2. Comments or one raw text element: `iframe`, `noembed`, `xmp`, `title`, `noframes`, `style` or `noscript`\n\nConfigurations that meet the above requirements plus the following are vulnerable to an additional vulnerability:\n\n- Any HTML integration element: `title`, `desc`, `mi`, `mo`, `mn`, `ms`, `mtext`, `annotation-xml`.\n\nIn case an application sanitizes user input with a vulnerable configuration, an attacker could\nbypass the sanitization and inject arbitrary HTML, including JavaScript code.\n\nNote that in the default configuration the vulnerability is not present.\n\n### Patches\n\nThe vulnerability has been fixed in versions 8.0.723 and 8.1.722-beta (preview version).\n\n### Workarounds\n\nDisallow foreign elements `svg` and `math`. This is the case in the default configuration, which is therefore not affected by the vulnerability.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "HtmlSanitizer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "8.0.723"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "HtmlSanitizer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.1.0-beta"
      }, {
        "fixed" : "8.1.722-beta"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mganss/HtmlSanitizer/security/advisories/GHSA-43cp-6p3q-2pc4"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-44390"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mganss/HtmlSanitizer/commit/ab29319866c020f0cc11e6b92228cd8039196c6e"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mganss/HtmlSanitizer"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-10-04T18:52:35Z",
    "nvd_published_at" : "2023-10-05T14:15:09Z"
  }
}