The vulnerability is a Server-Side Request Forgery (SSRF) located in Mailpit's Link Check API and Screenshot Proxy functionality. The root cause is the application's failure to validate user-provided URLs before making HTTP requests. Specifically, the linkcheck.doHead and handlers.ProxyHandler functions used a standard Go http.Client without any restrictions on the target IP addresses.
An attacker could send an email containing specially crafted URLs pointing to internal network resources (e.g., 127.0.0.1, private IP ranges, or cloud metadata endpoints like 169.254.169.254). By triggering the Link Check API for this email, the attacker could cause the Mailpit server to make HTTP requests to these internal addresses. Because the API returns the status codes of these requests, it provides a clear feedback mechanism for the attacker to scan the internal network, identify services, and potentially access sensitive information.
The patch addresses this by implementing a safeDialContext for the http.Client. This new dialer resolves the hostname to an IP address and uses a helper function, tools.IsInternalIP, to check if the IP is a loopback, private, or otherwise reserved address. If an internal IP is detected, the request is blocked by default, thus mitigating the SSRF vulnerability. The identified vulnerable functions are the key components of the exploitation path, from the API entry point down to the function making the unsafe request.