CVE-2016-15011 (published 2023-01-06T10:15Z)

A vulnerability classified as problematic was found in e-Contract dssp up to 1.3.1. Affected by this vulnerability is the function checkSignResponse of the file dssp-client/src/main/java/be/e_contract/dssp/client/SignResponseVerifier.java. The manipulation leads to xml external entity reference. Upgrading to version 1.3.2 is able to address this issue. The identifier of the patch is ec4238349691ec66dd30b416ec6eaab02d722302. It is recommended to upgrade the affected component. The identifier VDB-217549 was 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/e-Contract/dssp
commit_details: repo_url: https://github.com/e-Contract/dssp
author: Frank Cornelis
author_date: 2016-04-26 14:44:31+02:00
msg: 5342: fix XML external entity injection
repository: repo_url: https://github.com/e-Contract/dssp
repo_name: e-Contract/dssp
description: Digital Signature Service Protocol
repo_language: Java
owner: e-Contract
file_changes: filename: SignResponseVerifier.java
change_type: ModificationType.MODIFY
diff: @@ -47,6 +47,7 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
 
 import be.e_contract.dssp.client.exception.ClientRuntimeException;
 import be.e_contract.dssp.client.exception.SubjectNotAuthorizedException;
@@ -115,6 +116,20 @@ public class SignResponseVerifier {
 		} catch (Base64DecodingException e) {
 			throw new SecurityException("no Base64");
 		}
+
+		// DOM parsing
+		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+		documentBuilderFactory.setNamespaceAware(true);
+		documentBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+		DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+		InputStream signResponseInputStream = new ByteArrayInputStream(decodedSignResponseMessage);
+		Document signResponseDocument;
+		try {
+			signResponseDocument = documentBuilder.parse(signResponseInputStream);
+		} catch (SAXParseException e) {
+			throw new SecurityException("no valid SignResponse XML");
+		}
+
 		// JAXB parsing
 		JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class,
 				be.e_contract.dssp.ws.jaxb.dss.async.ObjectFactory.class,
@@ -122,18 +137,11 @@ public class SignResponseVerifier {
 		Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
 		SignResponse signResponse;
 		try {
-			signResponse = (SignResponse) unmarshaller.unmarshal(new ByteArrayInputStream(decodedSignResponseMessage));
+			signResponse = (SignResponse) unmarshaller.unmarshal(signResponseDocument);
 		} catch (UnmarshalException e) {
 			throw new SecurityException("no valid SignResponse XML");
 		}
 
-		// DOM parsing
-		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
-		documentBuilderFactory.setNamespaceAware(true);
-		DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
-		InputStream signResponseInputStream = new ByteArrayInputStream(decodedSignResponseMessage);
-		Document signResponseDocument = documentBuilder.parse(signResponseInputStream);
-
 		// signature verification
 		NodeList signatureNodeList = signResponseDocument.getElementsByTagNameNS("http://www.w3.org/2000/09/xmldsig#",
 				"Signature");

programming_language: Java
filename: DigitalSignatureServiceMetadata.java
change_type: ModificationType.MODIFY
diff: @@ -28,6 +28,10 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
 
 import be.e_contract.dssp.ws.jaxb.dssp.DigitalSignatureServiceDescriptorType;
 import be.e_contract.dssp.ws.jaxb.metadata.EntityDescriptorType;
@@ -46,6 +50,8 @@ import be.e_contract.dssp.ws.jaxb.xmldsig.X509DataType;
  */
 public class DigitalSignatureServiceMetadata implements Serializable {
 
+	private static final long serialVersionUID = 1L;
+
 	private final static QName _X509DataTypeX509Certificate_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#",
 			"X509Certificate");
 
@@ -63,10 +69,16 @@ public class DigitalSignatureServiceMetadata implements Serializable {
 	 * @throws Exception
 	 */
 	public DigitalSignatureServiceMetadata(String metadataLocation) throws Exception {
+		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+		documentBuilderFactory.setNamespaceAware(true);
+		documentBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+		DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+		Document document = documentBuilder.parse(new URL(metadataLocation).openStream());
+
 		JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
 		Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
 		JAXBElement<EntityDescriptorType> entityDescriptorElement = (JAXBElement<EntityDescriptorType>) unmarshaller
-				.unmarshal(new URL(metadataLocation));
+				.unmarshal(document);
 		EntityDescriptorType entityDescriptor = entityDescriptorElement.getValue();
 		List<RoleDescriptorType> roleDescriptors = entityDescriptor
 				.getRoleDescriptorOrIDPSSODescriptorOrSPSSODescriptor();

programming_language: Java