CVE-2023-42439 (published 2023-09-15T21:15Z)

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data. A SSRF vulnerability exists starting in version 3.2.0, bypassing existing controls on the software. This can allow a user to request internal services for a full read SSRF, returning any data from the internal network. The application is using a whitelist, but the whitelist can be bypassed. The bypass will trick the application that the first host is a whitelisted address, but the browser will use `@` or `%40` as a credential to the host geoserver on port 8080, this will return the data to that host on the response. Version 4.1.3.post1 is the first available version that contains a patch.

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

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/GeoNode/geonode
commit_details: repo_url: https://github.com/GeoNode/geonode
author: Alessio Fabiani
author_date: 2023-09-14 13:17:12+02:00
msg: Merge pull request from GHSA-pxg5-h34r-7q8p

* fixes advisory

* - fix tests
repository: repo_url: https://github.com/GeoNode/geonode
repo_name: GeoNode/geonode
description: GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
repo_language: JavaScript
owner: GeoNode
file_changes: filename: tests.py
change_type: ModificationType.MODIFY
diff: @@ -213,6 +213,16 @@ class ProxyTest(GeoNodeBaseTestSupport):
         response = self.client.get(f"{self.proxy_url}?url={url}")
         self.assertEqual(response.status_code, 403)
 
+        url = f"{settings.SITEURL.rstrip('/')}@geoserver:8080/web/index.html"
+
+        response = self.client.get(f"{self.proxy_url}?url={url}")
+        self.assertEqual(response.status_code, 403)
+
+        url = f"{settings.SITEURL.rstrip('/')}%40geoserver:8080/web/index.html"
+
+        response = self.client.get(f"{self.proxy_url}?url={url}")
+        self.assertEqual(response.status_code, 403)
+
         # Legit requests using the local host (SITEURL)
         url = f"/\\@%23{urlsplit(settings.SITEURL).hostname}"
 

programming_language: Python
filename: utils.py
change_type: ModificationType.MODIFY
diff: @@ -88,6 +88,7 @@ from urllib.parse import (
     urlparse,
     urlsplit,
     urlencode,
+    urlunparse,
     parse_qsl,
     ParseResult,
 )
@@ -1907,11 +1908,27 @@ def build_absolute_uri(url):
     return url
 
 
+def remove_credentials_from_url(url):
+    # Parse the URL
+    parsed_url = urlparse(url)
+
+    # Remove the username and password from the parsed URL
+    parsed_url = parsed_url._replace(netloc=parsed_url.netloc.split("@")[-1])
+
+    # Reconstruct the URL without credentials
+    cleaned_url = urlunparse(parsed_url)
+
+    return cleaned_url
+
+
 def extract_ip_or_domain(url):
+    # Decode the URL to handle percent-encoded characters
+    _url = remove_credentials_from_url(unquote(url))
+
     ip_regex = re.compile("^(?:http://|https://)(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})")
     domain_regex = re.compile("^(?:http://|https://)([a-zA-Z0-9.-]+)")
 
-    match = ip_regex.findall(url)
+    match = ip_regex.findall(_url)
     if len(match):
         ip_address = match[0]
         try:
@@ -1920,7 +1937,7 @@ def extract_ip_or_domain(url):
         except ValueError:
             pass
 
-    match = domain_regex.findall(url)
+    match = domain_regex.findall(_url)
     if len(match):
         return match[0]
 

programming_language: Python