CVE-2022-23638: Enshrined/svg sanitize Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-fqx8-v33p-4qcc
CVSS 6.2
CWE-79
Published
Advisory Summary

CVE-2022-23638 is a MODERATE (CVSS 6.2) 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 cross-site scripting in enshrined/svg-sanitize. Remediation is available by upgrading affected packages to version 0.15.0.

CVE-2022-23638 at a Glance

CVE Identifier CVE-2022-23638
GHSA Identifier GHSA-fqx8-v33p-4qcc
Severity MODERATE
CVSS v3.1 Base Score 6.2
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: 6.2

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

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

How to Fix CVE-2022-23638

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.15.0
Upgrade enshrined/svg-sanitize to 0.15.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-2022-23638, 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.15.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

### Impact SVG sanitizer library before version `0.15.0` did not remove HTML elements wrapped in a CDATA section. As a result, SVG content embedded in HTML (fetched as `text/html`) was susceptible to cross-site scripting. Plain SVG files (fetched as `image/svg+xml`) were not affected. ### Patches This issue is fixed in `0.15.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-2022-23638 Affected Enshrined/svg sanitize Versions

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

References

Frequently Asked Questions

What is CVE-2022-23638?
CVE-2022-23638 is a security vulnerability in Enshrined/svg sanitize involving Cross-site Scripting in enshrined/svg-sanitize 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.15.0 across affected packages: enshrined/svg-sanitize.
What version fixes CVE-2022-23638?
Upgrading to 0.15.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.15.0. Upgrade your dependency to 0.15.0 or later.
What is the CVSS score of CVE-2022-23638?
CVE-2022-23638 has a CVSS v3.1 base score of 6.2 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2022-23638?
CVE-2022-23638 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-2022-23638?
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-fqx8-v33p-4qcc",
  "modified" : "2022-03-09T23:27:04Z",
  "published" : "2022-02-14T22:54:18Z",
  "aliases" : [ "CVE-2022-23638" ],
  "summary" : "Cross-site Scripting in enshrined/svg-sanitize",
  "details" : "### Impact\nSVG sanitizer library before version `0.15.0` did not remove HTML elements wrapped in a CDATA section. As a result, SVG content embedded in HTML (fetched as `text/html`) was susceptible to cross-site scripting. Plain SVG files (fetched as `image/svg+xml`) were not affected.\n\n### Patches\nThis issue is fixed in `0.15.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* Open an issue in [Github](https://github.com/darylldoyle/svg-sanitizer/issues)\n* Email us at [daryll@enshrined.co.uk](mailto:daryll@enshrined.co.uk)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "enshrined/svg-sanitize"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.15.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/darylldoyle/svg-sanitizer/security/advisories/GHSA-fqx8-v33p-4qcc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23638"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/darylldoyle/svg-sanitizer/issues/71"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/darylldoyle/svg-sanitizer/commit/17e12ba9c2881caa6b167d0fbea555c11207fbb0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/enshrined/svg-sanitize/CVE-2022-23638.yaml"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-fqx8-v33p-4qcc"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/darylldoyle/svg-sanitizer"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-02-14T22:54:18Z",
    "nvd_published_at" : "2022-02-14T21:15:00Z"
  }
}