Advisory Database
  • Advisories
  • Dependency Scanning
  1. composer
  2. ›
  3. phenx/php-svg-lib
  4. ›
  5. GHSA-97m3-52wr-xvv2

GHSA-97m3-52wr-xvv2: Dompdf's usage of vulnerable version of phenx/php-svg-lib leads to restriction bypass and potential RCE

February 22, 2024 (updated February 23, 2024)

Summary

A lack of sanitization/check in the font path returned by php-svg-lib, in the case of a inline CSS font defined, that will be used by Cpdf to open a font will be passed to a file_exists call, which is sufficient to trigger metadata unserializing on a PHAR file, through the phar:// URL handler on PHP < 8.0. On other versions, it might be used as a way to get a SSRF through, for example, ftp, not restricted by authorized protocols configured on dompdf.

Details

The problem lies on the openFont function of the lib/Cpdf.php library, when the $font variable passed by php-svg-lib isn’t checked correctly. A path is crafted through $name and $dir, which are two values that can be controlled through CSS :

$name = basename($font);
$dir = dirname($font);
[...]
$metrics_name = "$name.ufm";
[...]

if (!isset($this->fonts[$font]) && file_exists("$dir/$metrics_name")) {

Passing a font named phar:///foo/bar/baz.phar/test will set the value of $name to test and $dir to phar:///foo/bar/baz.phar, which once reconstructed will call file_exists on phar:///foo/bar/baz.phar/test.ufm. That allows to deserialize the baz.phar arbitrary file that contains a test.ufm file in the archive.

References

  • github.com/advisories/GHSA-97m3-52wr-xvv2
  • github.com/dompdf/dompdf
  • github.com/dompdf/dompdf/security/advisories/GHSA-97m3-52wr-xvv2
  • github.com/dompdf/php-svg-lib/commit/732faa9fb4309221e2bd9b2fda5de44f947133aa
  • github.com/dompdf/php-svg-lib/security/advisories/GHSA-f3qr-qr4x-j273

Code Behaviors & Features

Detect and mitigate GHSA-97m3-52wr-xvv2 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 0.5.2

Fixed versions

  • 0.5.2

Solution

Upgrade to version 0.5.2 or above.

Impact 10 CRITICAL

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-502: Deserialization of Untrusted Data
  • CWE-73: External Control of File Name or Path

Source file

packagist/phenx/php-svg-lib/GHSA-97m3-52wr-xvv2.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:30 +0000.