CVE-2021-43113: Itext7 core Command Injection Vulnerability

CRITICAL
Advisory Identifier: GHSA-gv87-q66h-4277
CVSS 9.8
CWE-77
Published
Advisory Summary

CVE-2021-43113 is a CRITICAL (CVSS 9.8) command injection vulnerability (CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')) affecting Itext7 core libraries in the Maven ecosystem. The issue involves command injection in itext7-core. Remediation is available by upgrading affected packages to version 7.1.17, 5.5.13.3.

CVE-2021-43113 at a Glance

CVE Identifier CVE-2021-43113
GHSA Identifier GHSA-gv87-q66h-4277
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')
Affected Product Itext7 core
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 9.8

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:H/I:H/A:H).

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 High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2021-43113

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

com.itextpdf:itext7-core fixed: 7.1.17
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itext7-core</artifactId>
    <version>7.1.17</version>
</dependency>
com.itextpdf:itextpdf fixed: 5.5.13.3
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itextpdf</artifactId>
    <version>5.5.13.3</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=com.itextpdf

How to Check if You Are Affected

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

mvn dependency:tree -Dincludes=com.itextpdf

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

Note: The mvn dependency:tree -Dincludes=com.itextpdf 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-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), where the product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. In Itext7 core, 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

iTextPDF in iText before 7.1.17 allows command injection via a CompareTool filename that is mishandled on the gs (aka Ghostscript) command line in GhostscriptHelper.java.

CVE-2021-43113 Affected Itext7 core Versions

2 component(s)
Fixed Versions:
7.1.175.5.13.3
Product / Package Ecosystem Affected Versions Fixed Version
com.itextpdf:itext7-core
Maven
< 7.1.17
7.1.17
com.itextpdf:itextpdf
Maven
< 5.5.13.3
5.5.13.3

References

Frequently Asked Questions

What is CVE-2021-43113?
CVE-2021-43113 is a security vulnerability in Itext7 core involving Command injection in itext7-core under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Which Itext7 core versions are affected?
Affected versions include releases prior to 7.1.17, 5.5.13.3 across affected packages: com.itextpdf:itext7-core, com.itextpdf:itextpdf.
What version fixes CVE-2021-43113?
Upgrading to 7.1.17, 5.5.13.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is itext7-core affected?
Yes, com.itextpdf:itext7-core is affected in releases prior to 7.1.17. Upgrade your dependency to 7.1.17 or later.
Is itextpdf affected?
Yes, com.itextpdf:itextpdf is affected in releases prior to 5.5.13.3. Upgrade your dependency to 5.5.13.3 or later.
What is the CVSS score of CVE-2021-43113?
CVE-2021-43113 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-43113?
CVE-2021-43113 is classified under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') (The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.).
How can I check Maven dependencies for CVE-2021-43113?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.itextpdf'. 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-gv87-q66h-4277",
  "modified" : "2022-01-25T21:02:25Z",
  "published" : "2021-12-16T00:02:15Z",
  "aliases" : [ "CVE-2021-43113" ],
  "summary" : "Command injection in itext7-core",
  "details" : "iTextPDF in iText before 7.1.17 allows command injection via a CompareTool filename that is mishandled on the gs (aka Ghostscript) command line in GhostscriptHelper.java.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.itextpdf:itext7-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.1.17"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.itextpdf:itextpdf"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.5.13.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43113"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/itext/itext7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/itext/itext7/releases/tag/7.1.17"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/itext/itextpdf/releases/tag/5.5.13.3"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/01/msg00013.html"
  }, {
    "type" : "WEB",
    "url" : "https://pastebin.com/BXnkY9YY"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2023/dsa-5323"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-77" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-25T21:02:25Z",
    "nvd_published_at" : "2021-12-15T07:15:00Z"
  }
}