GitHub Advisoryadvisory · npm

GHSA-h857-2g56-468g @mattkrick/sanitize-svg vulnerable to Cross-Site Scripting (XSS)

HIGH Published 2023-01-05 Modified 2023-01-05 Official page ↗
Aliases
CVE-2023-22461
Ecosystem
npm
Packages
@mattkrick/sanitize-svg
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N
Weaknesses
CWE-79
Reviewed
2023-01-05

Affected packages

• npm @mattkrick/sanitize-svg: < 0.4.0 → fixed in 0.4.0

Description

Impact The *sanitize-svg* package uses a deny-list-pattern to sanitize SVGs to prevent cross-site scripting (XSS). In doing so, literal ``-tags and on-event handlers were detected: ```typescript [...] const svgEl = div.firstElementChild! const attributes = Array.from(svgEl.attributes).map(({ name }) => name) const hasScriptAttr = !!attributes.find((attr) => attr.startsWith('on')) const scripts = svgEl.getElementsByTagName('script') return scripts.length === 0 && !hasScriptAttr ? svg : null [...] ``` There are more ways to embed JavaScript in XML files. Anchor Tag (requires user to click link): ```xml Lauritz ``` Foreign Object Tag (no user interaction required): ```xml Lauritz ``` As a result, downstream software that relies on `sanitize-svg` and expects resulting SVGs to be safe, may be vulnerable to XSS. We are aware of at least one downstream project for which this vulnerability had security implications. Patches This vulnerability was addressed in v0.4.0. Workarounds N/A

Related

Alias · CVE (1)

  • CVE-2023-22461 The `sanitize-svg` package, a small SVG sanitizer to prevent cross-site scripting attacks, uses a deny-list-pattern to sanitize SVGs to… vulnerability

Weakness · CWE (1)

  • CWE-79 Improper Neutralization of Input During Web Page Generation weakness

References