# CVE-2023-50251: php-svg-lib possible DoS caused by infinite recursion when parsing SVG document

> An attacker can cause a denial of service via infinite recursion in php-svg-lib by sending a crafted SVG document, exhausting server resources.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 12 Dec 2023
- **Updated:** 22 May 2025
- **Also known as:** DEBIAN-CVE-2023-50251, GHSA-ff5x-7qg5-vwf2

## What is CVE-2023-50251?

CVE-2023-50251 is a medium-severity denial of service vulnerability in dompdf php-svg-lib, published on 12 Dec 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

php-svg-lib is an SVG file parsing / rendering library. Prior to version 0.5.1, when parsing the attributes passed to a `use` tag inside an svg document, an attacker can cause the system to go to an infinite recursion. Depending on the system configuration and attack pattern this could exhaust the memory available to the executing process and/or to the server itself. An attacker sending multiple request to a system to render the above payload can potentially cause resource exhaustion to the point that the system is unable to handle incoming request. Version 0.5.1 contains a patch for this issue.

Weakness: CWE-674 (Uncontrolled Recursion)

## Which versions are affected by CVE-2023-50251?

2 open source packages ship an affected version, including phenx/php-svg-lib. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `phenx/php-svg-lib` | Packagist | All versions | 0.5.1 |
| `phenx/php-svg-lib` | Packagist | All versions | 0.5.1 |

Products: Dompdf Php-Svg-Lib.

## How do I fix CVE-2023-50251?

Upgrade phenx/php-svg-lib to 0.5.1 or later.

## Is CVE-2023-50251 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-50251 exists.

## Other vulnerabilities in dompdf php-svg-lib

- [CVE-2023-50252](https://insights.sbomify.com/CVE-2023-50252/): php-svg-lib unsafe attributes merge when parsing `use` tag (high 8.3)
- [CVE-2024-25117](https://insights.sbomify.com/CVE-2024-25117/): php-svg-lib lacks path validation on font through SVG inline styles (medium 6.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-50251 and fix it if it is affected.

What it is: CVE-2023-50251 is a medium-severity denial of service vulnerability in dompdf php-svg-lib, published on 12 Dec 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-50251 exists.

Affected packages and fixed versions:
- phenx/php-svg-lib (Packagist): affected all versions; fixed in 0.5.1
- phenx/php-svg-lib (Packagist): affected all versions; fixed in 0.5.1

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-2023-50251/ (Markdown: https://insights.sbomify.com/CVE-2023-50251/index.md)
```

## Sources

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

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