CVE-2023-50262: Dompdf/dompdf Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-3qx2-6f78-w2j2
CVSS 5.3
CWE-20
Published
Advisory Summary

CVE-2023-50262 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-20: Improper Input Validation) affecting Dompdf/dompdf libraries in the Packagist ecosystem. The issue involves denial of service caused by infinite recursion when parsing svg images. Remediation is available by upgrading affected packages to version 2.0.4.

CVE-2023-50262 at a Glance

CVE Identifier CVE-2023-50262
GHSA Identifier GHSA-3qx2-6f78-w2j2
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-20: Improper Input Validation
Affected Product Dompdf/dompdf
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability Low (A:L)

How to Fix CVE-2023-50262

To remediate this vulnerability, upgrade all affected Dompdf/dompdf dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

dompdf/dompdf fixed: 2.0.4
Upgrade dompdf/dompdf to 2.0.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for dompdf/dompdf

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-50262, inspect your project dependencies for Dompdf/dompdf:

inspect dependencies for dompdf/dompdf

Analyze the terminal output to locate any version of Dompdf/dompdf in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Dompdf/dompdf, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary When parsing SVG images Dompdf performs an initial validation to ensure that paths within the SVG are allowed. One of the validations is that the [SVG document does not reference itself](https://github.com/dompdf/dompdf/blob/v2.0.3/src/Image/Cache.php#L136-L153). However, a recursive chained using two or more SVG documents is not correctly validated. Depending on the system configuration and attack pattern this could exhaust the memory available to the executing process and/or to the server itself. ### Details php-svg-lib, when run in isolation, does not support SVG references for `image` elements. An SVG document can, however, be referenced and Dompdf will run that reference through the same validation. Dompdf currently includes validation to prevent self-referential `image` references, but a chained reference is not checked. A malicious actor may thus trigger infinite recursion in the validation process by chaining references between two or more SVG images. ### PoC This following sources can be used to bypass validation provided by Dompdf: recurse.html ``` <img src="one.svg"> ``` one.svg ``` <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg"> <image href="two.svg" /> </svg> ``` two.svg ``` <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg"> <image href="one.svg" /> </svg> ``` ### Impact When Dompdf parses the above payload, it will crash due after exceeding the allowed execution time or memory usage. An attacker sending multiple request to a system can potentially cause resource exhaustion to the point that the system is unable to handle incoming request.

CVE-2023-50262 Affected Dompdf/dompdf Versions

1 component(s)
Fixed Versions:
2.0.4
Product / Package Ecosystem Affected Versions Fixed Version
dompdf/dompdf
Packagist
< 2.0.4
2.0.4

References

Frequently Asked Questions

What is CVE-2023-50262?
CVE-2023-50262 is a security vulnerability in Dompdf/dompdf involving Denial of service caused by infinite recursion when parsing SVG images under CWE-20: Improper Input Validation.
Which Dompdf/dompdf versions are affected?
Affected versions include releases prior to 2.0.4 across affected packages: dompdf/dompdf.
What version fixes CVE-2023-50262?
Upgrading to 2.0.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is dompdf/dompdf affected?
Yes, dompdf/dompdf is affected in releases prior to 2.0.4. Upgrade your dependency to 2.0.4 or later.
What is the CVSS score of CVE-2023-50262?
CVE-2023-50262 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2023-50262?
CVE-2023-50262 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check Packagist dependencies for CVE-2023-50262?
Run the dependency tree command: 'inspect dependencies for dompdf/dompdf'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3qx2-6f78-w2j2",
  "modified" : "2023-12-13T23:09:04Z",
  "published" : "2023-12-13T23:09:04Z",
  "aliases" : [ "CVE-2023-50262" ],
  "summary" : "Denial of service caused by infinite recursion when parsing SVG images",
  "details" : "### Summary\nWhen parsing SVG images Dompdf performs an initial validation to ensure that paths within the SVG are allowed. One of the validations is that the [SVG document does not reference itself](https://github.com/dompdf/dompdf/blob/v2.0.3/src/Image/Cache.php#L136-L153). However, a recursive chained using two or more SVG documents is not correctly validated. Depending on the system configuration and attack pattern this could exhaust the memory available to the executing process and/or to the server itself.\n\n### Details\nphp-svg-lib, when run in isolation, does not support SVG references for `image` elements. An SVG document can, however, be referenced and Dompdf will run that reference through the same validation. Dompdf currently includes validation to prevent self-referential `image` references, but a chained reference is not checked. A malicious actor may thus trigger infinite recursion in the validation process by chaining references between two or more SVG images.\n\n### PoC\n\nThis following sources can be used to bypass validation provided by Dompdf:\n\nrecurse.html\n```\n<img src=\"one.svg\">\n```\n\none.svg\n```\n<svg width=\"200\" height=\"200\" xmlns=\"http://www.w3.org/2000/svg\">\n  <image href=\"two.svg\" />\n</svg>\n```\n\ntwo.svg\n```\n<svg width=\"200\" height=\"200\" xmlns=\"http://www.w3.org/2000/svg\">\n  <image href=\"one.svg\" />\n</svg>\n```\n\n### Impact\n\nWhen Dompdf parses the above payload, it will crash due after exceeding the allowed execution time or memory usage. An attacker sending multiple request to a system can potentially cause resource exhaustion to the point that the system is unable to handle incoming request.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "dompdf/dompdf"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/dompdf/dompdf/security/advisories/GHSA-3qx2-6f78-w2j2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-50262"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dompdf/dompdf/commit/41cbac16f3cf56affa49f06e8dae66d0eac2b593"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/dompdf/dompdf/CVE-2023-50262.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/dompdf/dompdf"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dompdf/dompdf/blob/v2.0.3/src/Image/Cache.php#L136-L153"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-12-13T23:09:04Z",
    "nvd_published_at" : "2023-12-13T21:15:09Z"
  }
}