The vulnerability is a Server-Side Request Forgery (SSRF) in the /http(s) route of esm.sh, identified as CVE-2026-27730. The core of the issue lies in the isLocalhost function in server/utils.go, which uses inadequate string-based checks to validate hostnames. This allows attackers to bypass the protection by using DNS services like nip.io to create hostnames (e.g., 127.0.0.1.nip.io) that resolve to internal or localhost IP addresses but pass the string validation.
The vulnerable workflow originates in the esmRouter function (server/router.go), which handles the request, calls the flawed isLocalhost check, and then proceeds to fetch content from the user-specified URL using the fetch.FetchClient.
The provided patch (0593516c4cfab49ad3b4900416a8432ff2e23eb0) attempts to mitigate the SSRF risk. The main change is to restrict HTTP redirects. The fetch.NewClient function is updated to accept an allowedHosts map and configures the HTTP client to reject any redirects to hosts not on this list. The esmRouter is changed to supply this allowedHosts map, containing only the host from the user's initial request.
However, the patch does not fix the root cause in isLocalhost. It only addresses SSRF attacks that occur via an HTTP redirect. The vulnerability of a direct request to a malicious, DNS-aliased hostname, as demonstrated in the proof-of-concept, appears to remain. The identified functions are those directly involved in the vulnerable flow and the subsequent mitigation attempt.