CVE-2021-39178 XSS in Image Optimization API for Next.js versions between 10.0.0 and 11.1.0

High 7.5 Published Updated

Attackers can execute arbitrary scripts via SVG images if specific image optimization configurations are enabled in Next.js applications.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2021-39178?

CVE-2021-39178 is a high-severity cross-site scripting vulnerability in Vercel Next.js, published on 30 Aug 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

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.

Weakness: CWE-79

Which versions are affected by CVE-2021-39178?

2 open source packages ship an affected version, including next. It affects 1 product.

PackageAffectedFixed in
next npmFrom 10.0.011.1.1
next npmFrom 10.0.011.1.1

Products include Vercel Next.js.

How do I fix CVE-2021-39178?

Upgrade next to 11.1.1 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2021-39178 being exploited?

There is no known exploitation of CVE-2021-39178 in the wild and no public exploit code.

All Vercel Next.js vulnerabilities

Sources

Also known as GHSA-9gr3-7897-pp7m.

Is CVE-2021-39178 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free