CVE-2024-25117
JSON

6.8medium

php-svg-lib lacks path validation on font through SVG inline styles

Severity
6.8medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.93% (higher than 61% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-f3qr-qr4x-j273

Description

php-svg-lib is a scalable vector graphics (SVG) file parsing/rendering library. Prior to version 0.5.2, php-svg-lib fails to validate that font-family doesn't contain a PHAR url, which might leads to RCE on PHP < 8.0, and doesn't validate if external references are allowed. This might leads to bypass of restrictions or RCE on projects that are using it, if they do not strictly revalidate the fontName that is passed by php-svg-lib. The `Style::fromAttributes(`), or the `Style::parseCssStyle()` should check the content of the `font-family` and prevents it to use a PHAR url, to avoid passing an invalid and dangerous `fontName` value to other libraries. The same check as done in the `Style::fromStyleSheets` might be reused. Libraries using this library as a dependency might be vulnerable to some bypass of restrictions, or even remote code execution, if they do not double check the value of the `fontName` that is passed by php-svg-lib. Version 0.5.2 contains a fix for this issue.

Affected

Product or packageVersionsReported by
dompdf php-svg-lib< 0.5.2, before 0.5.2CVE List, NVD
phenx/php-svg-lib (Packagist)before 0.5.2GitHub Advisory Database

All scores

GitHub_M6.8medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L
GitHub6.8medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-73CWE-502CWE-610

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total.

What each source says

CVE List

php-svg-lib is a scalable vector graphics (SVG) file parsing/rendering library. Prior to version 0.5.2, php-svg-lib fails to validate that font-family doesn't contain a PHAR url, which might leads to RCE on PHP < 8.0, and doesn't validate if external references are allowed. This might leads to bypass of restrictions or RCE on projects that are using it, if they do not strictly revalidate the fontName that is passed by php-svg-lib. The `Style::fromAttributes(`), or the `Style::parseCssStyle()` should check the content of the `font-family` and prevents it to use a PHAR url, to avoid passing an invalid and dangerous `fontName` value to other libraries. The same check as done in the `Style::fromStyleSheets` might be reused. Libraries using this library as a dependency might be vulnerable to some bypass of restrictions, or even remote code execution, if they do not double check the value of the `fontName` that is passed by php-svg-lib. Version 0.5.2 contains a fix for this issue.

GitHub Advisory Database
Summary

php-svg-lib fails to validate that font-family doesn't contain a PHAR url, which might leads to RCE on PHP < 8.0, and doesn't validate if external references are allowed. This might leads to bypass of restrictions or RCE on projects that are using it, if they do not strictly revalidate the fontName that is passed by php-svg-lib.

Details

The Style::fromAttributes(), or the Style::parseCssStyle() should check the content of the font-family and prevents it to use a PHAR url, to avoid passing an invalid and dangerous fontName value to other libraries. The same check as done in the Style::fromStyleSheets might be reused :

                if (
                    \array_key_exists("font-family", $styles)
                    && (
                        \strtolower(\substr($this->href, 0, 7)) === "phar://"
                        || ($this->document->allowExternalReferences === false && \strtolower(\substr($this->href, 0, 5)) !== "data:")
                    )
                ) {
                    unset($style["font-family"]);
                }
PoC

Parsing the following SVG :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
    <text x="20" y="35" style="color:red;font-family:phar:///path/to/whatever.phar/blaklis;">My</text>
</svg>

will pass the phar:///path/to/whatever.phar/blaklis as $family in SurfaceCpdf::setFont, which is then passed to the canvas selectFont as a $fontName.

Impact

Libraries using this library as a dependency might be vulnerable to some bypass of restrictions, or even RCE, if they do not double check the value of the fontName that is passed by php-svg-lib

NVD (es)

php-svg-lib es una librería escalable de análisis/renderización de archivos de gráficos vectoriales (SVG). Antes de la versión 0.5.2, php-svg-lib no valida que font-family no contenga una URL PHAR, lo que podría llevar a RCE en PHP &lt; 8.0, y no valida si se permiten referencias externas. Esto podría llevar a eludir las restricciones o RCE en los proyectos que lo utilizan, si no revalidan estrictamente el nombre de fuente pasado por php-svg-lib. El `Style::fromAttributes(`), o el `Style::parseCssStyle()` deben verificar el contenido de la `font-family` y evitar que use una URL PHAR, para evitar pasar un `fontName` inválido y peligroso. valor para otras librerías. Se puede reutilizar la misma comprobación realizada en `Style::fromStyleSheets`. Las librerías que utilizan esta librería como dependencia pueden ser vulnerables a alguna elusión de restricciones, o incluso a la ejecución remota de código, si no verifican dos veces el valor de `fontName` que pasa por php-svg-lib. La versión 0.5.2 contiene una solución para este problema.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-25117 changed 2024-08-28CVE Terms of Use
GitHub Advisory DatabaseGHSA-f3qr-qr4x-j273 changed 2026-09-10CC-BY-4.0
NVDCVE-2024-25117 changed 2026-06-17Public domain