CVE-2023-28426: Enshrined/svg sanitize Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-xrqq-wqh4-5hg2
CVSS 5.3
CWE-79
Published
Advisory Summary

CVE-2023-28426 is a MODERATE (CVSS 5.3) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Enshrined/svg sanitize libraries in the Packagist ecosystem. The issue involves svg-sanitizer has cross-site scripting bypass. Remediation is available by upgrading affected packages to version 0.16.0.

CVE-2023-28426 at a Glance

CVE Identifier CVE-2023-28426
GHSA Identifier GHSA-xrqq-wqh4-5hg2
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Enshrined/svg sanitize
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 5.3

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:N/S:U/C:L/I:N/A:N).

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

How to Fix CVE-2023-28426

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

enshrined/svg-sanitize fixed: 0.16.0
Upgrade enshrined/svg-sanitize to 0.16.0
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 enshrined/svg-sanitize

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-28426, inspect your project dependencies for Enshrined/svg sanitize:

inspect dependencies for enshrined/svg-sanitize

Analyze the terminal output to locate any version of Enshrined/svg sanitize in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.16.0), 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 Enshrined/svg sanitize, 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

### Update In [#88](https://github.com/darylldoyle/svg-sanitizer/issues/88) we have determined that the bypass this security advisory was created for, was a false positive and as such we have requested that the CVE be rejected. ___ A bypass has been found that allows an attacker to upload an SVG with persistent XSS. HTML elements within CDATA needed to be sanitized correctly, as we were converting them to a textnode and therefore, the library wasn't seeing them as DOM elements. Any data within a CDATA node will now be sanitised using [HTMLPurifier](https://github.com/ezyang/htmlpurifier). We've also removed many of the HTML and MathML elements from the allowed element list, as without `ForiegnObject`, they're not legal within the SVG context. Additional tests have been added to the test suite to account for these new bypasses. ### Impact This impacts all users of the `svg-sanitizer` library. ### Patches This issue is fixed in 0.16.0 and higher. ### Workarounds There is currently no workaround available without upgrading. ### For more information If you have any questions or comments about this advisory: Open an issue in [Github](https://github.com/darylldoyle/svg-sanitizer/issues) Email us at [daryll@enshrined.co.uk](mailto:daryll@enshrined.co.uk)

CVE-2023-28426 Affected Enshrined/svg sanitize Versions

1 component(s)
Fixed Versions:
0.16.0
Product / Package Ecosystem Affected Versions Fixed Version
enshrined/svg-sanitize
Packagist
< 0.16.0
0.16.0

References

Frequently Asked Questions

What is CVE-2023-28426?
CVE-2023-28426 is a security vulnerability in Enshrined/svg sanitize involving svg-sanitizer has Cross-site Scripting Bypass under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Enshrined/svg sanitize versions are affected?
Affected versions include releases prior to 0.16.0 across affected packages: enshrined/svg-sanitize.
What version fixes CVE-2023-28426?
Upgrading to 0.16.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is enshrined/svg-sanitize affected?
Yes, enshrined/svg-sanitize is affected in releases prior to 0.16.0. Upgrade your dependency to 0.16.0 or later.
What is the CVSS score of CVE-2023-28426?
CVE-2023-28426 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2023-28426?
CVE-2023-28426 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 Packagist dependencies for CVE-2023-28426?
Run the dependency tree command: 'inspect dependencies for enshrined/svg-sanitize'. 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-xrqq-wqh4-5hg2",
  "modified" : "2023-03-23T12:50:28Z",
  "published" : "2023-03-20T20:44:30Z",
  "withdrawn" : "2023-03-23T12:50:28Z",
  "aliases" : [ "CVE-2023-28426" ],
  "summary" : "svg-sanitizer has Cross-site Scripting Bypass",
  "details" : "### Update\nIn [#88](https://github.com/darylldoyle/svg-sanitizer/issues/88) we have determined that the bypass this security advisory was created for, was a false positive and as such we have requested that the CVE be rejected.\n\n___\n\nA bypass has been found that allows an attacker to upload an SVG with persistent XSS.\n\nHTML elements within CDATA needed to be sanitized correctly, as we were converting them to a textnode and therefore, the library wasn't seeing them as DOM elements.\n\nAny data within a CDATA node will now be sanitised using [HTMLPurifier](https://github.com/ezyang/htmlpurifier). We've also removed many of the HTML and MathML elements from the allowed element list, as without `ForiegnObject`, they're not legal within the SVG context. \n\nAdditional tests have been added to the test suite to account for these new bypasses.\n\n### Impact\nThis impacts all users of the `svg-sanitizer` library.\n\n### Patches\nThis issue is fixed in 0.16.0 and higher.\n\n### Workarounds\nThere is currently no workaround available without upgrading.\n\n### For more information\nIf you have any questions or comments about this advisory:\n\nOpen an issue in [Github](https://github.com/darylldoyle/svg-sanitizer/issues)\nEmail us at [daryll@enshrined.co.uk](mailto:daryll@enshrined.co.uk)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "enshrined/svg-sanitize"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.16.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/darylldoyle/svg-sanitizer/security/advisories/GHSA-xrqq-wqh4-5hg2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-28426"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/darylldoyle/svg-sanitizer/issues/88"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/darylldoyle/svg-sanitizer/commit/cce18bc237c05c6e093e9672db7926788da9b322"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/darylldoyle/svg-sanitizer"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-03-20T20:44:30Z",
    "nvd_published_at" : "2023-03-20T14:15:00Z"
  }
}