# I patched Next.js for the October RCEs. The lockfile kept the vulnerable sharp.

- Published: 2026-10-22
- Tags: Next.js, React, Security
- URL: https://devtrillo.com/writing/nextjs-october-2026-security-patch/

I took a Next.js 15.5 app with `sharp@0.34.5` in its lockfile, ran the upgrade the [October 14 security update](https://nextjs.org/blog/nextjs-security-update-october-14-2026) tells you to run, and checked what came out:

```text title="npm install next@15.5.28, then npm ls sharp"
lab@1.0.0
└─┬ next@15.5.28
  └── sharp@0.34.5
```

`next` is patched. `sharp` isn't, and `sharp` is where one of the two critical bugs lives. The lockfile diff looked fine: 41 lines changed, and the only one mentioning `sharp` was the version range inside `next`'s own entry.

Below: which of the October advisories reach your app, how to get the fixed `sharp` actually installed, and a CI check so the next out-of-band patch isn't a guessing game.

_Already know this? Jump to [Skip to the sharp trap](https://devtrillo.com/writing/nextjs-october-2026-security-patch/#the-15-5-trap)._

## What shipped on October 14

Vercel [pre-announced](https://nextjs.org/blog/upcoming-nextjs-security-update-october-2026) the release a week ahead, then shipped 16.4.1 and 15.5.28 on the 14th. Since then 16.4.2 has come out and is `latest` on npm as I write this.

| Advisory                                                                                         | What                                                      | Affected `next`                   |
| ------------------------------------------------------------------------------------------------ | --------------------------------------------------------- | --------------------------------- |
| [GHSA-673q-mjm6-r5xr](https://github.com/vercel/next.js/security/advisories/GHSA-673q-mjm6-r5xr) | Critical RCE, `use cache` returning multiple typed arrays | 16.0.0 – 16.4.0                   |
| [GHSA-2464-fhr4-w9xw](https://github.com/vercel/next.js/security/advisories/GHSA-2464-fhr4-w9xw) | Critical RCE, Image Optimization with SVG, glibc Linux    | 10.0.0 – 15.5.27, 16.0.0 – 16.4.0 |
| [GHSA-p3m5-59mp-jv5r](https://github.com/vercel/next.js/security/advisories/GHSA-p3m5-59mp-jv5r) | High, CPU DoS through Server Actions                      | 13.0.0 – 15.5.27, 16.0.0 – 16.4.0 |

The first and third come from React Server Components. The [upstream React advisory](https://github.com/react/react/security/advisories/GHSA-xqc2-xf4c-x3h3) for the RCE describes it as "extremely rare cases where responses transport multiple typed arrays and an attacker-controlled value". The second is a memory bug in librsvg, which `sharp` bundles. [sharp's own advisory](https://github.com/lovell/sharp/security/advisories/GHSA-wq5f-xc86-pv6w) marks everything below 0.35.5 as vulnerable.

For the `use cache` bug, the Next.js advisory says there's no workaround and you should upgrade "even if your application does not have similar functions". So the audit below doesn't decide whether you patch. It decides how worried you should be about the time before you did.

## Am I exposed?

### `use cache`

Only the 16 line has this one, and only with Cache Components on. Check the config first:

```bash title="is Cache Components on?"
grep -nE "cacheComponents" next.config.*
```

`next build` also prints `- Cache Components enabled` near the top when it is.

Then find the functions. A grep gets the ones in your code:

```bash title="every use cache and use server directive"
grep -rnE "[\"']use (cache|server)" \
  --include='*.ts' --include='*.tsx' --include='*.js' --include='*.jsx' \
  --exclude-dir=node_modules --exclude-dir=.next .
```

The pattern without a closing quote is on purpose: it also catches `"use cache: remote"` and `"use cache: private"`.

The build has a better list. In a 16.4.2 lab app with one Server Action and one cached function, `.next/server/server-reference-manifest.json` listed both:

```bash title="what the build compiled"
jq -r '.node | to_entries[] | "\(.value.filename)  \(.value.exportedName)"' \
  .next/server/server-reference-manifest.json
```

```text
app/signup/actions.ts  subscribe
lib/stats.ts  $$RSC_SERVER_CACHE_0
```

`$$RSC_SERVER_CACHE_0` is the `use cache` function. For each one, look at what it returns. Mine returned `{ values: Float32Array, mask: Uint8Array }`, which is exactly the shape in the advisory: two typed arrays in one cached response.

> **Note:** The same manifest has an `encryptionKey` field. That's the key Next uses to
> encrypt closed-over Server Action arguments. Don't paste the whole file into
> an issue or a chat.

### Image Optimization and SVG

You're in scope if the app serves `/_next/image` itself (self-hosted, `next start` or standalone) on glibc Linux. Start with the config:

```bash title="image config"
grep -nE "dangerouslyAllowSVG|unoptimized|loader" next.config.*
```

The advisory doesn't say whether `dangerouslyAllowSVG` has to be on, so I'm not going to guess. What I could see in the 16.4.0 source is that Next blocks every sharp input loader and then unblocks a short list, and `VipsForeignLoadSvg` is on that list. I diffed the image optimizer between 16.4.0 and 16.4.1, and it's byte for byte the same. The whole fix for this bug is the `sharp` version.

### Server Actions

The DoS needs App Router and at least one Server Action. The manifest above answers that: any entry that isn't a `$$RSC_SERVER_CACHE_` is an action. The advisory says apps on Pages Router, or with no Server Actions, aren't vulnerable.

## Upgrading

On 16, upgrading is enough. I took a lockfile pinned to `next@16.4.0` and `sharp@0.35.4` and ran:

```bash
npm install next@16.4.1
npm ls sharp
```

`sharp` moved to 0.35.5 and `@img/sharp-libvips-*` went from 1.3.3 to 1.3.4. That works because 16.4.1 asks for `sharp@^0.35.5`, which 0.35.4 doesn't satisfy, so npm has to re-resolve it.

## The 15.5 trap

`next@15.5.28` asks for this:

```text title="bun why sharp"
sharp@0.34.5
  └─ optional next@15.5.28 (requires ^0.34.3 || ^0.35.5)
```

0.34.5 satisfies `^0.34.3`, so a lockfile that already has it has no reason to change. I tried it with npm and pnpm, starting from `next@15.5.27` with `sharp@0.34.5` locked. `npm install next@15.5.28` and `pnpm add next@15.5.28` both left `sharp` at 0.34.5.

The [advisory](https://github.com/vercel/next.js/security/advisories/GHSA-2464-fhr4-w9xw) does warn about this, in its own way: "Fresh installs automatically get a fixed version". The word doing the work is "fresh". If your lockfile already has a 0.34.x `sharp` in it, your install isn't fresh, and 0.34.x is what you'd have if the project was set up before sharp 0.35 came out in June.

The fix is one more command, and neither the npm nor the pnpm form adds `sharp` to your `package.json`:

```bash
npm update sharp   # or: pnpm update sharp
```

The lockfile can be right and the image you deploy can still be wrong, so check what Next actually loads. `sharp` reports its bundled library versions:

```js title="scripts/check-sharp.mjs"
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
const fromNext = createRequire(require.resolve("next"));
const { versions } = fromNext("sharp");

const [major, minor, patch] = versions.sharp.split(".").map(Number);
const fixed = major > 0 || minor > 35 || (minor === 35 && patch >= 5);

console.log(`next loads sharp ${versions.sharp} (librsvg ${versions.rsvg})`);
if (!fixed) {
  console.error("sharp is older than 0.35.5, CVE-2026-96889 is not fixed");
  process.exit(1);
}
```

Resolving from `next` matters in a monorepo, where the `sharp` your app imports and the one Next loads can be different copies. Before and after `npm update sharp`:

```text
next loads sharp 0.34.5 (librsvg 2.61.2)
sharp is older than 0.35.5, CVE-2026-96889 is not fixed

next loads sharp 0.35.5 (librsvg 2.63.2)
```

librsvg 2.63.2 is the version sharp's advisory names as fixed.

## glibc, musl, and the Node binary

The advisories say RCE on glibc Linux. I ran the old 15.5.28 lockfile through `npm ci` in two official images. `node:24-slim` is Debian with glibc 2.36 and installed `@img/sharp-linux-arm64`. `node:24-alpine` is musl and installed `@img/sharp-linuxmusl-arm64`. Both loaded librsvg 2.61.2. Same old library, so I'd patch Alpine images too, even though musl isn't what the advisory describes.

sharp's advisory has one more detail: the RCE needs a `node` binary that isn't a Position Independent Executable, and "the 'official' Node.js binaries do not" use PIE. I read the ELF header of `node` in both images. In `node:24-slim` it's `ET_EXEC`, not position independent. In `node:24-alpine` it's `ET_DYN`, which is PIE. So the default Debian-based Node image is the one the advisory is describing.

If you can't ship an upgrade today, sharp's advisory gives a stopgap, `sharp.block({ operation: ["VipsForeignLoadSvg"] })`. I haven't tested where to put it so that it runs after Next's own block and unblock calls, so treat that as a lead, not a fix. The Next.js post doesn't claim Vercel mitigates the image bug on its platform either, so upgrade there the same way.

## Making the next one boring

Put the check script in CI, after install and on the same base image you deploy:

```yaml title=".github/workflows/ci.yml (step)"
- run: npm ci
- run: node scripts/check-sharp.mjs
```

It's specific to this CVE. Bump the floor when the next sharp advisory lands, or delete it once your range can't resolve below 0.35.5 anymore.

The general check is `npm audit`, and it did flag the old lockfile: GHSA-wq5f-xc86-pv6w, "Vulnerability in librsvg dependency CVE-2026-96889", under `sharp <=0.35.5-rc.1`. On 15.5, though, `npm audit --audit-level=high` exits 1 even after you fix `sharp`, because `next@15.5.28` pins `postcss@8.4.31` and audit reports that as high. The fix it suggests is `next@16.4.2`. On a 16.4.2 lab app the same command exited 0. So an audit gate works on 16, and on 15.5 it fails until you allow that one advisory.

For the pull requests, I'd let Dependabot do security updates only. Version update PRs can be switched off with `open-pull-requests-limit: 0`. Security updates have their own limit and are turned on in the repository's settings, not in this file:

```yaml title=".github/dependabot.yml"
version: 2
updates:
  - package-ecosystem: npm
    directory: /
    schedule:
      interval: weekly
    open-pull-requests-limit: 0
```

## What I'd run today

1. `npm ls next sharp`. On 16 you want 16.4.1 or later. On 15.5 you want 15.5.28, plus `sharp` 0.35.5 or later.
2. If `sharp` is below 0.35.5, run `npm update sharp`. Bumping `next` doesn't always do it.
3. Run `check-sharp.mjs` inside the image you deploy, not on your laptop.
4. List your actions and cached functions from `server-reference-manifest.json`, and look hard at any `use cache` function returning more than one typed array.

The 15.5 line is in maintenance, and an advisory that only reaches you through a transitive range will happen again. Next time, I want a CI check to go red before I've even read the advisory.
