CVE-2025-6087: OpenNext for Cloudflare (opennextjs-cloudflare) has a SSRF vulnerability via /_next/image endpoint
7.8
Basic Information
Technical Details
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
@opennextjs/cloudflare | npm | < 1.3.0 | 1.3.0 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability (CVE-2025-6087) was an SSRF issue in the @opennextjs/cloudflare
package, specifically affecting how the /_next/image
endpoint handled external image URLs.
The analysis of the provided commit patch (36119c0f490c95b3d4f6e826d745b728c80625ab) reveals that the root cause was an uncontrolled call to the native fetch
API within the main request handler of the Cloudflare worker (packages/cloudflare/src/cli/templates/worker.ts
).
Before the patch, when the /_next/image?url=<external_url>
endpoint was accessed, the fetch
method in worker.ts
would directly take the external_url
and execute fetch(external_url, ...)
. This allowed an attacker to make the server request arbitrary URLs, leading to SSRF. The server would then proxy the content from the attacker-controlled URL under the victim site's domain.
The patch addressed this by:
- Introducing a new function
fetchImage
inpackages/cloudflare/src/cli/templates/init.ts
. - This
fetchImage
function now includes logic to validate the remote URL against a list ofremotePatterns
(configured via Next.js image configuration and passed during the build process bypackages/cloudflare/src/cli/build/open-next/compile-init.ts
). - The main
fetch
handler inworker.ts
was modified to call this newfetchImage
function instead of directly fetching the URL.
The vulnerable function is therefore the original fetch
method in packages/cloudflare/src/cli/templates/worker.ts
because it contained the logic that directly processed the user-supplied URL without adequate validation, making the fetch(imageUrl, ...)
call the SSRF sink. The other modified files and new functions (fetchImage
, matchRemotePattern
, compileInit
) are part of the mitigation, either by providing the validation logic or the configuration for it.