CVE-2022-4725 (published 2022-12-27T15:15Z)

A vulnerability was found in AWS SDK 2.59.0. It has been rated as critical. This issue affects the function XpathUtils of the file aws-android-sdk-core/src/main/java/com/amazonaws/util/XpathUtils.java of the component XML Parser. The manipulation leads to server-side request forgery. Upgrading to version 2.59.1 is able to address this issue. The name of the patch is c3e6d69422e1f0c80fe53f2d757b8df97619af2b. It is recommended to upgrade the affected component. The identifier VDB-216737 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-918
cwe_name: Server-Side Request Forgery (SSRF)
description: The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
extended_description: By providing URLs to unexpected hosts or ports, attackers can make it appear that the server is sending the request, possibly bypassing access controls such as firewalls that prevent the attackers from accessing the URLs directly. The server can be used as a proxy to conduct port scanning of hosts in internal networks, use other URLs such as that can access documents on the system (using file://), or use other protocols such as gopher:// or tftp://, which may provide greater control over the contents of requests.
         

Fix information:
repo_url: https://github.com/aws-amplify/aws-sdk-android
commit_details: repo_url: https://github.com/aws-amplify/aws-sdk-android
author: banji180
author_date: 2022-12-04 23:56:38-08:00
msg: fix(core): added fix for xml parser (#3100)

* added fix for xml parser vulnerability

* added fix for xml parser vulnerability

Co-authored-by: Banji Jolaoso <banjij@amazon.com>
repository: repo_url: https://github.com/aws-amplify/aws-sdk-android
repo_name: aws-amplify/aws-sdk-android
description: AWS SDK for Android. For more information, see our web site:
repo_language: Java
owner: aws-amplify
file_changes: filename: RegionMetadataParser.java
change_type: ModificationType.MODIFY
diff: @@ -109,9 +109,10 @@ public class RegionMetadataParser {
         Document document;
         try {
 
-            DocumentBuilderFactory factory =
-                    DocumentBuilderFactory.newInstance();
-
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+            factory.setXIncludeAware(false);
+            factory.setExpandEntityReferences(false);
             DocumentBuilder documentBuilder = factory.newDocumentBuilder();
             document = documentBuilder.parse(input);
 

programming_language: Java
filename: XpathUtils.java
change_type: ModificationType.MODIFY
diff: @@ -45,7 +45,25 @@ public class XpathUtils {
     /** Shared logger */
     private static Log log = LogFactory.getLog(XpathUtils.class);
 
-    private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+    private static DocumentBuilderFactory factory = getDocumentBuilderFactory();
+
+
+    /**
+     * Creates new documentbuilderfactory object
+     * @return DocumentBuilderFactory.
+     */
+    private static DocumentBuilderFactory getDocumentBuilderFactory() {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+            dbf.setXIncludeAware(false); // Default false for java 8. Disable XML Inclusions leading to SSRF - https://portswigger.net/web-security/xxe/lab-xinclude-attack
+            dbf.setExpandEntityReferences(false);
+            return dbf;
+        }
+        catch (ParserConfigurationException exception){
+            return null;
+        }
+    }
 
     /**
      * InputStream to Document.

programming_language: Java