CVE-2017-20151 (published 2022-12-30T12:15Z)

A vulnerability classified as problematic was found in iText RUPS. This vulnerability affects unknown code of the file src/main/java/com/itextpdf/rups/model/XfaFile.java. The manipulation leads to xml external entity reference. The patch is identified as ac5590925874ef810018a6b60fec216eee54fb32. It is recommended to apply a patch to fix this issue. VDB-217054 is the identifier assigned to this vulnerability.

CVSS v3 base score: 9.8, CRITICAL (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-611
cwe_name: Improper Restriction of XML External Entity Reference
description: The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
extended_description: 
            XML documents optionally contain a Document Type Definition (DTD), which, among other features, enables the definition of XML entities. It is possible to define an entity by providing a substitution string in the form of a URI. The XML parser can access the contents of this URI and embed these contents back into the XML document for further processing.
            By submitting an XML file that defines an external entity with a file:// URI, an attacker can cause the processing application to read the contents of a local file. For example, a URI such as "file:///c:/winnt/win.ini" designates (in Windows) the file C:\Winnt\win.ini, or file:///etc/passwd designates the password file in Unix-based systems. Using URIs with other schemes such as http://, the attacker can force the application to make outgoing requests to servers that the attacker cannot reach directly, which can be used to bypass firewall restrictions or hide the source of attacks such as port scanning.
            Once the content of the URI is read, it is fed back into the application that is processing the XML. This application may echo back the data (e.g. in an error message), thereby exposing the file contents.
         
         

Fix information:
repo_url: https://github.com/itext/rups
commit_details: repo_url: https://github.com/itext/rups
author: Valera Goman
author_date: 2017-08-01 17:23:29+03:00
msg: Prevent XXE-vulnerability

DEV-1863
repository: repo_url: https://github.com/itext/rups
repo_name: itext/rups
description: [DEPRECATED - please use i7j-rups instead] RUPS is an abbreviation for Reading and Updating PDF Syntax. RUPS is a tool built on top of iText® that allows you to look inside a PDF document and browse the different PDF objects and content streams.
repo_language: Java
owner: itext
file_changes: filename: XfaFile.java
change_type: ModificationType.MODIFY
diff: @@ -47,6 +47,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.StringReader;
 
 import org.dom4j.Document;
 import org.dom4j.DocumentException;
@@ -55,6 +56,9 @@ import org.dom4j.io.SAXReader;
 import org.dom4j.io.XMLWriter;
 
 import com.itextpdf.rups.io.OutputStreamResource;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 /** Class that deals with the XFA file that can be inside a PDF file. */
 public class XfaFile implements OutputStreamResource {
@@ -76,6 +80,7 @@ public class XfaFile implements OutputStreamResource {
 		resource.writeTo(baos);
 		ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
 		SAXReader reader = new SAXReader();
+		reader.setEntityResolver(new SafeEmptyEntityResolver());
 		xfaDocument = reader.read(bais);
 	}
 
@@ -98,4 +103,10 @@ public class XfaFile implements OutputStreamResource {
         XMLWriter writer = new XMLWriter(os, format);
         writer.write(xfaDocument);
 	}
+
+	private static class SafeEmptyEntityResolver implements EntityResolver {
+		public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+			return new InputSource(new StringReader(""));
+		}
+	}
 }

programming_language: Java