CVE-2021-31812: Pdfbox Infinite Loop Vulnerability

MODERATE
Advisory Identifier: GHSA-7grw-6pjh-jpc9
CVSS 5.5
CWE-834 CWE-835
Published
Advisory Summary

CVE-2021-31812 is a MODERATE (CVSS 5.5) infinite loop vulnerability (CWE-834: Excessive Iteration) affecting Pdfbox libraries in the Maven ecosystem. The issue involves infinite loop in apache pdfbox. Remediation is available by upgrading affected packages to version 2.0.24.

CVE-2021-31812 at a Glance

CVE Identifier CVE-2021-31812
GHSA Identifier GHSA-7grw-6pjh-jpc9
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-834: Excessive Iteration
Affected Product Pdfbox
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 5.5

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

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

How to Fix CVE-2021-31812

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

org.apache.pdfbox:pdfbox fixed: 2.0.24
<dependency>
    <groupId>org.apache.pdfbox</groupId>
    <artifactId>pdfbox</artifactId>
    <version>2.0.24</version>
</dependency>
org.apache.pdfbox:pdfbox-parent fixed: 2.0.24
<dependency>
    <groupId>org.apache.pdfbox</groupId>
    <artifactId>pdfbox-parent</artifactId>
    <version>2.0.24</version>
</dependency>
Verify Direct and Transitive Dependencies

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

mvn dependency:tree -Dincludes=org.apache.pdfbox

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2021-31812, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.apache.pdfbox

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

Note: The mvn dependency:tree -Dincludes=org.apache.pdfbox command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-834: Excessive Iteration, where the product performs an iteration or loop without sufficiently limiting the number of times that the loop is executed. In Pdfbox, 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

In Apache PDFBox, a carefully crafted PDF file can trigger an infinite loop while loading the file. This issue affects Apache PDFBox version 2.0.23 and prior 2.0.x versions.

CVE-2021-31812 Affected Pdfbox Versions

2 component(s)
Fixed Versions:
2.0.24
Product / Package Ecosystem Affected Versions Fixed Version
org.apache.pdfbox:pdfbox
Maven
≥ 2.0.0
< 2.0.24
2.0.24
org.apache.pdfbox:pdfbox-parent
Maven
≥ 2.0.0
< 2.0.24
2.0.24

References

NVD — CVE-2021-31812 NVD
https://nvd.nist.gov/vuln/detail/CVE-2021-31812
Pdfbox Security Information SECURITY
https://www.oracle.com/security-alerts/cpuoct2021.html
Pdfbox Security Information SECURITY
https://www.oracle.com/security-alerts/cpujul2022.html
Pdfbox Security Information SECURITY
https://www.oracle.com/security-alerts/cpujan2022.html
Pdfbox Security Information SECURITY
https://www.oracle.com/security-alerts/cpuapr2022.html
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MDJKJQOMVFDFIDS27OQJXNOYHV2O273D
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/7HHWJRFXZ3PTKLJCOM7WJEYZFKFWMNSV
lists.apache.org/thread.html/rfe26bc... WEB
https://lists.apache.org/thread.html/rfe26bcaba564deb505c32711ba68df7ec589797dcd96ff3389a8aaba@%3Cnotifications.ofbiz.apache.org%3E
lists.apache.org/thread.html/rf251f6... WEB
https://lists.apache.org/thread.html/rf251f6c358087107f8c23473468b279d59d50a75db6b4768165c78d3@%3Cannounce.apache.org%3E
lists.apache.org/thread.html/re0cacd... WEB
https://lists.apache.org/thread.html/re0cacd3fb337cdf8469853913ed2b4ddd8f8bfc52ff0ddbe61c1dfba@%3Ccommits.ofbiz.apache.org%3E
lists.apache.org/thread.html/rd4b6db... WEB
https://lists.apache.org/thread.html/rd4b6db6c3b8ab3c70f1c3bbd725a40920896453ffc2744ade6afd9fb@%3Cnotifications.ofbiz.apache.org%3E
lists.apache.org/thread.html/ra2ab0c... WEB
https://lists.apache.org/thread.html/ra2ab0ce69ce8aaff0773b8c1036438387ce004c2afc6f066626e205e@%3Cusers.pdfbox.apache.org%3E
lists.apache.org/thread.html/ra2ab0c... WEB
https://lists.apache.org/thread.html/ra2ab0ce69ce8aaff0773b8c1036438387ce004c2afc6f066626e205e%40%3Cusers.pdfbox.apache.org%3E
lists.apache.org/thread.html/r209078... WEB
https://lists.apache.org/thread.html/r2090789e4dcc2c87aacbd87d5f18e2d64dcb9f6eb7c47f5cf7d293cb@%3Cnotifications.ofbiz.apache.org%3E
lists.apache.org/thread.html/r179cc3... WEB
https://lists.apache.org/thread.html/r179cc3b6822c167702ab35fe36093d5da4c99af44238c8a754c6860f@%3Ccommits.ofbiz.apache.org%3E
lists.apache.org/thread.html/r143fd8... WEB
https://lists.apache.org/thread.html/r143fd8445e0e778f4a85187bd79438630b96b8040e9401751fdb8aea@%3Ccommits.ofbiz.apache.org%3E
lists.apache.org/thread.html/r132e9d... WEB
https://lists.apache.org/thread.html/r132e9dbbe0ebdc08b39583d8be0a575fdba573d60a42d940228bceff@%3Cnotifications.ofbiz.apache.org%3E
Pdfbox Security Information SECURITY
http://www.openwall.com/lists/oss-security/2021/06/12/1

Frequently Asked Questions

What is CVE-2021-31812?
CVE-2021-31812 is a security vulnerability in Pdfbox involving Infinite Loop in Apache PDFBox under CWE-834: Excessive Iteration.
Which Pdfbox versions are affected?
Affected versions include releases prior to 2.0.24 across affected packages: org.apache.pdfbox:pdfbox, org.apache.pdfbox:pdfbox-parent.
What version fixes CVE-2021-31812?
Upgrading to 2.0.24 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pdfbox affected?
Yes, org.apache.pdfbox:pdfbox is affected in releases prior to 2.0.24. Upgrade your dependency to 2.0.24 or later.
Is pdfbox-parent affected?
Yes, org.apache.pdfbox:pdfbox-parent is affected in releases prior to 2.0.24. Upgrade your dependency to 2.0.24 or later.
What is the CVSS score of CVE-2021-31812?
CVE-2021-31812 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-31812?
CVE-2021-31812 is classified under CWE-834: Excessive Iteration (The product performs an iteration or loop without sufficiently limiting the number of times that the loop is executed.).
How can I check Maven dependencies for CVE-2021-31812?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.apache.pdfbox'. 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-7grw-6pjh-jpc9",
  "modified" : "2022-02-08T21:22:18Z",
  "published" : "2021-06-15T15:54:29Z",
  "aliases" : [ "CVE-2021-31812" ],
  "summary" : "Infinite Loop in Apache PDFBox",
  "details" : "In Apache PDFBox, a carefully crafted PDF file can trigger an infinite loop while loading the file. This issue affects Apache PDFBox version 2.0.23 and prior 2.0.x versions.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.apache.pdfbox:pdfbox"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.0.24"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.apache.pdfbox:pdfbox-parent"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.0.24"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-31812"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuoct2021.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujul2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujan2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuapr2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MDJKJQOMVFDFIDS27OQJXNOYHV2O273D"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/7HHWJRFXZ3PTKLJCOM7WJEYZFKFWMNSV"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/rfe26bcaba564deb505c32711ba68df7ec589797dcd96ff3389a8aaba@%3Cnotifications.ofbiz.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/rf251f6c358087107f8c23473468b279d59d50a75db6b4768165c78d3@%3Cannounce.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/re0cacd3fb337cdf8469853913ed2b4ddd8f8bfc52ff0ddbe61c1dfba@%3Ccommits.ofbiz.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/rd4b6db6c3b8ab3c70f1c3bbd725a40920896453ffc2744ade6afd9fb@%3Cnotifications.ofbiz.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/ra2ab0ce69ce8aaff0773b8c1036438387ce004c2afc6f066626e205e@%3Cusers.pdfbox.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/ra2ab0ce69ce8aaff0773b8c1036438387ce004c2afc6f066626e205e%40%3Cusers.pdfbox.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r2090789e4dcc2c87aacbd87d5f18e2d64dcb9f6eb7c47f5cf7d293cb@%3Cnotifications.ofbiz.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r179cc3b6822c167702ab35fe36093d5da4c99af44238c8a754c6860f@%3Ccommits.ofbiz.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r143fd8445e0e778f4a85187bd79438630b96b8040e9401751fdb8aea@%3Ccommits.ofbiz.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r132e9dbbe0ebdc08b39583d8be0a575fdba573d60a42d940228bceff@%3Cnotifications.ofbiz.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2021/06/12/1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-834", "CWE-835" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-06-14T19:41:33Z",
    "nvd_published_at" : "2021-06-12T10:15:00Z"
  }
}