news.mlab.sh
Back to the feed
vulnerability

Critical Next.js ImageResponse Flaw Can Lead to Server Code Execution via Crafted SVG Input

Critical
Summary

A critical vulnerability in Next.js's ImageResponse feature allows attackers to execute code on a server by injecting malicious SVG input. The vulnerability, fixed in version 16.3.6, stems from a flaw in the Satori library and can be exploited by passing attacker-controlled values into SVG content. While Vercel claims hosted apps are protected, developers need to proactively check their Next.js versions and ensure they are not using vulnerable versions (16.2.0 - 16.3.5).

A critical vulnerability exists in Next.js's ImageResponse feature, allowing attackers to execute code on a server via ImageResponse, the component responsible for generating Open Graph and other social preview images. The risk arises when an application passes attacker-controlled values, such as text from the request URL, into the SVG content, attributes, or styles that ImageResponse renders. Vercel, the developer of Next.js, fixed the flaw in version 16.3.6.

This vulnerability is tied to Satori, a Vercel library used by ImageResponse. Satori's own advisory, published on the same day, indicates that certain values can reach its SVG output without proper escaping, potentially allowing attacker-controlled values to be interpreted as SVG code instead of plain text. This can then lead to vulnerabilities in other libraries Next.js depends on, ultimately resulting in code execution.

Next.js 16.2.0 through 16.3.5 are affected. Vercel states that hosted apps on their platform are protected and do not require an upgrade, but developers must independently verify their Next.js version and update to 16.3.6 if necessary. The vulnerability has been available since Next.js 16.2 was released on March 18, 2023.

To identify vulnerable applications, developers should look for `ImageResponse` imported from `next/og`. Route handlers and `opengraph-image` files are common locations for this component. As of September 23, The Hacker News found no public reports of attacks utilizing this flaw, and no public exploit code exists. Satori version 0.33.5 is recommended for developers using the library directly.

Next.js 15.5.26 adds extra security hardening for `next/og` on the 15.5 line. The vulnerability's impact depends on how the SVG output is used, and Vercel has not yet identified the specific libraries that could be exploited.

Read the full article at The Hacker News