# CVE-2022-23638: Cross-site Scripting in svg-sanitizer

> An attacker can inject malicious scripts via SVG files processed by the svg-sanitizer library, potentially executing code in the victim's browser.

- **Severity:** Medium 6.2 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 14 Feb 2022
- **Updated:** 23 Apr 2025
- **Also known as:** GHSA-fqx8-v33p-4qcc, UBUNTU-CVE-2022-23638

## What is CVE-2022-23638?

CVE-2022-23638 is a medium-severity cross-site scripting vulnerability in darylldoyle svg-sanitizer, published on 14 Feb 2022. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

svg-sanitizer is a SVG/XML sanitizer written in PHP. A cross-site scripting vulnerability impacts all users of the `svg-sanitizer` library prior to version 0.15.0. This issue is fixed in version 0.15.0. There is currently no workaround available.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation)

## Which versions are affected by CVE-2022-23638?

2 open source packages ship an affected version, including enshrined/svg-sanitize. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `enshrined/svg-sanitize` | Packagist | All versions | 0.15.0 |
| `enshrined/svg-sanitize` | Packagist | All versions | 0.15.0 |

Products: Svg-Sanitizer Project Svg-Sanitizer.

## How do I fix CVE-2022-23638?

Upgrade enshrined/svg-sanitize to 0.15.0 or later.

## Is CVE-2022-23638 being exploited?

There is no known exploitation of CVE-2022-23638 in the wild and no public exploit code.

## Other vulnerabilities in darylldoyle svg-sanitizer

- [CVE-2019-18857](https://insights.sbomify.com/CVE-2019-18857/): XSS in enshrined/svg-sanitize due to mishandled script and data values in attributes (high 7.5)
- [CVE-2019-10772](https://insights.sbomify.com/CVE-2019-10772/): Sanitizer bypass in svg-sanitizer (medium 6.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-23638 and fix it if it is affected.

What it is: CVE-2022-23638 is a medium-severity cross-site scripting vulnerability in darylldoyle svg-sanitizer, published on 14 Feb 2022. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-23638 in the wild and no public exploit code.

Affected packages and fixed versions:
- enshrined/svg-sanitize (Packagist): affected all versions; fixed in 0.15.0
- enshrined/svg-sanitize (Packagist): affected all versions; fixed in 0.15.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-23638/ (Markdown: https://insights.sbomify.com/CVE-2022-23638/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-23638
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-23638
- OSV: https://osv.dev/vulnerability/CVE-2022-23638

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-23638/
Summaries are generated and may contain mistakes; the official description above is the record.
