CVE-2020-36851: cors-anywhere vulnerable to server-side request forgery
N/A
Basic Information
Technical Details
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| cors-anywhere | npm | <= 0.4.4 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability, CVE-2020-36851, is a Server-Side Request Forgery (SSRF) in cors-anywhere. The root cause is not a specific bug, but the inherent design of the package when deployed as an open proxy without proper security configurations. The package is designed to proxy requests to any URL, and in its default configuration, it lacks restrictions on the target of these requests.
My analysis focused on identifying the core functions responsible for this proxying behavior, as these are the functions that would be exploited. By examining the code and the discussions in the associated GitHub issues (particularly issue #78, which discusses mitigating this SSRF), I pinpointed the request handling flow.
-
The process begins in the anonymous function returned by
getHandlerinlib/cors-anywhere.js. This function acts as the main request handler. It extracts the target URL from the path of the incoming request. This is the entry point for the user-controlled, malicious input. -
This handler then calls the
proxyRequestfunction, passing along the parsed URL. -
The
proxyRequestfunction takes this URL and uses it to configure thehttp-proxy, setting the URL as thetargetof the outbound request. It then initiates the request usingproxy.web().
At no point in this default flow is the target URL validated to ensure it does not point to internal services, cloud metadata endpoints, or other sensitive resources. This allows an attacker to craft a request to the cors-anywhere instance that causes the server to make a request to an arbitrary internal system.
The identified functions, getHandler.anonymous and proxyRequest, are therefore the key runtime indicators of this vulnerability. When this SSRF is exploited, these functions would appear in a stack trace or profiler output as they are directly involved in processing the malicious request and making the outbound connection.
Vulnerable functions
getHandler.anonymouslib/cors-anywhere.js
proxyRequestlib/cors-anywhere.js