← back
CVE-2021-39178

XSS in Image Optimization API for Next.js versions between 10.0.0 and 11.1.0

CVSS 7.5 HIGHEPSS 1.1%CWE-79
In short

Next.js versions 10.0.0 to 11.0.0 allow attackers to inject malicious code through SVG images when the image optimization API is enabled with certain domain configurations. If a website allows users to upload or reference SVG files from configured image domains, attackers can execute arbitrary JavaScript in visitors' browsers.

Technical detail

Cross-site scripting (XSS) vulnerability in Next.js Image Optimization API affecting versions 10.0.0–11.0.0. Attack vector requires: (1) `images.domains` configured in next.config.js, (2) domain permitting user-supplied SVG uploads/references, and (3) default image loader in use (not custom loader or Vercel deployment). SVG payload embedded in image parameters bypasses sanitization, enabling arbitrary script execution in victim browsers.

Summary generated and translated by AI from the official description.
Next.js is a React framework. Versions of Next.js between 10.0.0 and 11.0.0 contain a cross-site scripting vulnerability. In order for an instance to be affected by the vulnerability, the `next.config.js` file must have `images.domains` array assigned and the image host assigned in `images.domains` must allow user-provided SVG. If the `next.config.js` file has `images.loader` assigned to something other than default or the instance is deployed on Vercel, the instance is not affected by the vulnerability. The vulnerability is patched in Next.js version 11.1.1.
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
Affected products
vercel · next.js

Want to know if your infrastructure is exposed to this?

Talk to TrueHacking →