/

CVE-2025-50180

Severity:

HIGH RISK

(7.5)

SSRF in esm.sh CDN Response Handling

CVE-2025-50180

Analyzed

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-918

Impact:

Information Disclosure via Full-Response SSRF

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A server-side request forgery (SSRF) vulnerability in esm.sh v136 allows attackers to make the service issue HTTP requests to arbitrary internal or external URLs and return the full response.

When an attacker can control where esm.sh connects on the backend, they may be able to read sensitive data from internal services that are not otherwise exposed to the public internet.

Affected context

This vulnerability affects deployments that rely on esm.sh v136 as a no-build CDN to fetch and transform remote resources on behalf of users.

The issue arises when user-controlled input is used to construct backend HTTP requests without sufficient validation or restriction of target hosts, protocols, or paths.

It becomes particularly risky in environments where the esm.sh service has network access to internal endpoints (e.g., cloud metadata services, internal APIs, management panels) that are not directly reachable from the internet.

Exploit preconditions

  • Attack surface: Public HTTP endpoints exposed by esm.sh that accept user-controlled URLs or resource identifiers.
  • Required access: Network access to the esm.sh service (typically anonymous web access; no special authentication needed if the service is public).
  • Trigger point: Submitting crafted requests that cause esm.sh to perform server-side HTTP requests to attacker-chosen destinations.
  • Why exploitation is possible: The backend logic trusts user-supplied values when forming outbound requests and does not adequately restrict internal IP ranges, hostnames, or protocols, allowing the response body from internal services to be relayed back to the attacker.

Why this happens

The root cause aligns with CWE-918: Server-Side Request Forgery (SSRF), where a server makes unintended network requests due to unvalidated user input.

In this case, esm.sh functions as an HTTP client that fetches resources on behalf of users.

Because the implementation uses attacker-influenced data to construct outbound requests without enforcing strict allowlists, network boundaries, or protocol constraints, the service can be coerced into connecting to internal services and returning their responses.

The insecure pattern is treating user input as a trusted URL/endpoint, coupled with backend network permissions that are broader than what users should be able to reach.

Potential impact

  • Access to sensitive data from internal HTTP services (e.g., configuration endpoints, internal dashboards, or admin panels).
  • Discovery of internal network structure and reachable hosts through response content and error messages.
  • Potential access to cloud provider metadata services, which may expose credentials or configuration details.
  • Facilitation of further attacks such as internal service probing or chaining with other vulnerabilities (e.g., misconfigured admin interfaces).
  • Increased risk of lateral movement within the hosting environment if sensitive tokens, keys, or internal URLs are exposed.

General mitigation guidance

Mitigation focuses on tightly controlling how user input influences outbound network requests and limiting the network reach of the service:

  • Enforce strict allowlists of permitted domains, hostnames, or registries that the CDN is allowed to contact, rejecting all other destinations by default.
  • Block or sanitize access to internal IP ranges (e.g., RFC1918 addresses, link-local, loopback, metadata IPs) and internal hostnames that should never be reachable from user-controlled requests.
  • Normalize and validate URLs before use, ensuring that protocol, hostname, and port are explicitly checked and cannot be bypassed via redirects, DNS rebinding, or URL parsing quirks.
  • Apply least-privilege networking by segmenting the service onto networks where internal-sensitive resources are not accessible, or by using firewall rules and egress filters to constrain outbound traffic.
  • Where possible, separate metadata/management networks from application-serving networks to reduce the blast radius of any SSRF-like behavior.

How teams detect issues like this

Detection typically involves a mix of code-level review and runtime monitoring:

  • Static analysis and code review: Look for code paths where user input is concatenated into URLs or request targets for HTTP clients; flag use of generic URL fetchers without host validation or allowlists.
  • Security testing: Incorporate SSRF-focused tests into CI pipelines, using automated tools or test suites that attempt to reach internal IP ranges and well-known metadata endpoints through user-controlled parameters.
  • Network monitoring: Inspect outbound traffic from the esm.sh infrastructure for unusual targets (e.g., internal IPs, cloud metadata addresses, unexpected ports) and configure alerts for suspicious patterns.
  • Policy enforcement: Use infrastructure-level controls, such as egress firewalls or service mesh policies, that disallow outbound traffic to non-approved destinations regardless of application behavior.

Sources

SourceLink
github.comgithub.com/esm-dev/esm.sh/blob/f80ff8c8d58749e77fa964abde468fc61f8bd89e/internal/fetch/fetch.go#L13
github.comgithub.com/esm-dev/esm.sh/blob/f80ff8c8d58749e77fa964abde468fc61f8bd89e/server/router.go#L511
github.comgithub.com/esm-dev/esm.sh/commit/0593516c4cfab49ad3b4900416a8432ff2e23eb0
github.comgithub.com/esm-dev/esm.sh/pull/1149
github.comgithub.com/esm-dev/esm.sh/releases/tag/v137
github.comgithub.com/esm-dev/esm.sh/security/advisories/GHSA-3c9r-837r-qqm4

Frequently asked

questions

Yes. If the esm.sh service is publicly accessible, an attacker can exploit the SSRF remotely by sending crafted HTTP requests to the exposed endpoints.

In typical CDN usage, no special privileges are required beyond the ability to make HTTP requests to the service.

If the deployment restricts access via authentication or IP allowlists, those controls would limit who can attempt exploitation but not the underlying flaw.

The most robust fix is to enforce strict outbound request policies: restrict requests to a curated allowlist of safe domains, block all internal IP ranges and sensitive hostnames, and validate/normalize URLs before use.

Coupling this with network-level egress restrictions significantly reduces the attack surface.

Design backend fetch features assuming that any user-controlled URL or host input is untrusted.

Implement allowlist-based controls, deny internal networks by default, use application and network-level egress restrictions, and include SSRF test cases and static checks as part of your regular security review and CI/CD processes.

Find out what's already
exploitable in your codebase.