Miggo Logo

CVE-2025-6087: OpenNext for Cloudflare (opennextjs-cloudflare) has a SSRF vulnerability via /_next/image endpoint

7.8

CVSS Score
4.0

Basic Information

EPSS Score
0.26249%
Published
6/16/2025
Updated
6/16/2025
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:H/SI:L/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Package NameEcosystemVulnerable VersionsFirst Patched Version
@opennextjs/cloudflarenpm< 1.3.01.3.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot 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:

  1. Introducing a new function fetchImage in packages/cloudflare/src/cli/templates/init.ts.
  2. This fetchImage function now includes logic to validate the remote URL against a list of remotePatterns (configured via Next.js image configuration and passed during the build process by packages/cloudflare/src/cli/build/open-next/compile-init.ts).
  3. The main fetch handler in worker.ts was modified to call this new fetchImage 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.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

* S*rv*r-Si** R*qu*st *or**ry (SSR*) vuln*r**ility w*s i**nti*i** in t** @op*nn*xtjs/*lou**l*r* p**k***. T** vuln*r**ility st*ms *rom *n unimpl*m*nt** ***tur* in t** *lou**l*r* ***pt*r *or Op*n N*xt, w*i** *llow** un*ut**nti**t** us*rs to proxy *r*

Reasoning

T** vuln*r**ility (*V*-****-****) w*s *n SSR* issu* in t** `@op*nn*xtjs/*lou**l*r*` p**k***, sp**i*i**lly *****tin* *ow t** `/_n*xt/im***` *n*point **n*l** *xt*rn*l im*** URLs. T** *n*lysis o* t** provi*** *ommit p*t** (****************************