Skip to content

Commit 86d3dcc

Browse files
committed
Report stored ssrf attacks correctly
1 parent 83dbcec commit 86d3dcc

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

aikido_zen/vulnerabilities/ssrf/imds.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ def is_trusted_hostname(hostname):
5151

5252
def resolves_to_imds_ip(resolved_ip_addresses, hostname):
5353
"""
54-
returns a boolean, true if the IP is an imds ip
54+
Returns the IMDS IP address as a string if it exists in resolved_ip_addresses,
55+
otherwise returns an empty string.
5556
"""
56-
# Allow access to Google Cloud metadata service as you need to set specific headers to access it
57-
# We don't want to block legitimate requests
5857
if is_trusted_hostname(hostname):
59-
return False
60-
return any(is_imds_ip_address(ip) for ip in resolved_ip_addresses)
58+
return
59+
for ip in resolved_ip_addresses:
60+
if is_imds_ip_address(ip):
61+
return ip
62+
return

aikido_zen/vulnerabilities/ssrf/inspect_getaddrinfo_result.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ def inspect_getaddrinfo_result(dns_results, hostname, port):
2424
return
2525

2626
ip_addresses = extract_ip_array_from_results(dns_results)
27-
stored_ssrf_findings = resolves_to_imds_ip(ip_addresses, hostname)
28-
if stored_ssrf_findings:
27+
imds_ip = resolves_to_imds_ip(ip_addresses, hostname)
28+
if imds_ip:
2929
return {
3030
"module": "socket",
3131
"operation": "socket.getaddrinfo",
32-
"kind": "ssrf",
32+
"kind": "stored_ssrf",
33+
"source": "",
34+
"path": "",
35+
"metadata": {"hostname": hostname, "privateIP": imds_ip},
36+
"payload": hostname,
3337
}
3438

3539
if not ip_addresses_contain_private_ip(ip_addresses):

0 commit comments

Comments
 (0)