SSRF: unvalidated REMOTE_ADDR concatenated into cURL URL in get_country() #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
get_country()inmessage.phpconstructs a cURL URL by directly concatenating$_SERVER['REMOTE_ADDR']with no format validation:There is no check that
$ipis a valid IPv4 or IPv6 address before it is placed into the URL.Location
message.php, lines 22–38Risk
In misconfigured reverse-proxy or load-balancer setups where the application server treats a forwarded header (e.g.
X-Forwarded-For,X-Real-IP) asREMOTE_ADDR, an attacker can supply an arbitrary value. A crafted value such as127.0.0.1@internal-host/secretor a path-traversal sequence can redirect the cURL request to internal services (SSRF), potentially leaking cloud metadata endpoints (e.g.169.254.169.254), internal APIs, or other services not exposed to the internet.Suggested fix direction
Validate
$ipstrictly withfilter_var($ip, FILTER_VALIDATE_IP)and return"Unknown"for any value that doesn't pass. This ensures only well-formed IP addresses reach the URL.Severity
moderate
Found by
Automated audit by Claude Code