Skip to content

chore(deps): bump sharp to 0.35.4 for the libvips CVEs, and override next's nested copy - #735

Closed
sydevs-bot wants to merge 3 commits into
mainfrom
claude/chore-deps-sharp
Closed

sydevs-bot wants to merge 3 commits into
mainfrom
claude/chore-deps-sharp

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • sharp 0.34.5 → 0.35.4, clearing GHSA-f88m-g3jw-g9cj (four libvips CVEs). Highs drop 26 → 25.
  • A manifest bump alone does not fix it. next declares sharp: ^0.34.5 as its own optional dependency, and a caret on a 0.x line pins the minor — so the fix is out of next's range too, and it is that nested copy the image optimizer loads. An overrides entry is what clears it.
  • No behaviour change found: the one direct consumer regenerates byte-identical output.

Changes

  • package.json — ^0.34.5 → ^0.35.4. Out of range before, for the same caret reason.
  • pnpm-workspace.yaml — one overrides entry, scoped to next's declared range ('sharp@^0.34.5': '^0.35.4'), beside the transitive security pins already there. It is the only entry that crosses a minor rather than pinning a patch, so it carries its own note. The now-dead allowBuilds: sharp: true goes in the same file.
  • pnpm-lock.yaml — the resolution.

Why the override is scoped. Unscoped, ^0.35.4 on a 0.x line is a ceiling (<0.36.0) applied to every sharp in the graph forever, and pnpm applies an override with no warning. A later direct bump to 0.36 would edit package.json and change nothing, and once next ships a newer sharp we would quietly downgrade it — [email protected] already declares sharp: "^0.35.4", so the removal condition is met by a released next today. Scoped, the entry matches next 16.2.x only, leaves our own (already-bumped) direct dependency alone, and stops matching by itself once next moves. Every sibling override that fixes one vulnerable line is scoped the same way.

Preview

Test results

  • CI: ✓ green on 1c3b310, the commit before the review round — Lint, Test & Smoke, and the Railway preview deploy. CI runs again on 77a6fe2.
  • Lean gate on 77a6fe2: ✓ pnpm lint, pnpm typecheck, pnpm typecheck:tests, pnpm test:unit (126 files, 1646 tests)
  • Targeted specs: none — no source file changes, so no spec covers this diff. The evidence is the three checks under Manual verification, all run.
  • pnpm install --frozen-lockfile: ✓ completes, with no undecided-build-script error after the allowBuilds removal.
  • pnpm why sharp: ✓ one version, 0.35.4, and [email protected] resolves to it. pnpm audit: ✓ no sharp or libvips advisory; 40 → 39 total, 26 → 25 high. Both re-run on the scoped override, and both unchanged from the unscoped one.

Manual verification

Three things ran here that no spec covers. The third needs the preview:

  1. The optimizer's own call chain. next/dist/server/image-optimizer.js uses .rotate, .resize, .avif, .webp, .png, .jpeg and the sequentialRead option, and nothing else. Every one round-trips on 0.35.4. Confirmed next resolves sharp 0.35.4 / libvips 8.18.6 through its own require, not 0.34.5.
  2. scripts/generate-logo-pngs.ts, the sole direct consumer in this repo, regenerates all four PNGs byte-identically under 0.35.4.
  3. Open the /_next/image link above and confirm an optimized response rather than a 500. Worth doing in a browser that accepts AVIF, since that is the codec whose tuning changed.

Notes for reviewer

Detail

The 0.35.0 breaking changes, each checked rather than assumed.

Change Effect here
Requires Node >= 20.9.0 None. .node-version is 22.17.0, engines.node is >=22.0.0.
install script removed Nothing compiles — because 0.35 deleted the script, not because allowBuilds.sharp was true. That entry is now dead and is removed here: [email protected], @img/[email protected] and @img/[email protected] ship no scripts at all. The same change removes the source-build fallback, so an unsupported platform now fails to resolve a prebuilt rather than compiling one.
failOnError constructor property removed Unused. Neither consumer passes it.
paletteBitDepth dropped from metadata Unused. Nothing reads image metadata through sharp here.
Three sharpen properties removed Unused. Neither consumer calls .sharpen().
format.jp2k renamed format.jp2 Unused.
limitInputChannels, new, default 5 Reachable in principle through /_next/image. next.config.mjs:70-87 declares three remotePatterns: the R2 delivery host, **.cloudflarestream.com and img.shields.io. R2 is the only user-controlled one, and it serves what the Images collection stored — Images.ts:25 allows jpeg, png, webp and svg only, whose raster maximum is 4 channels (CMYK JPEG is 4, RGBA is 4). Stream thumbnails and shields.io badges produce none either. Nothing reachable exceeds 5.
Lossy AVIF retuned to SSIMULACRA2 iq See the note above — real, expected, not a break.

Payload never receives sharp. grep -rn sharp src/ returns only csharp in the OpenAPI plugin's language list, and src/payload.config.ts passes no sharp key — which is why the integration lane logs "Image resizing is enabled for one or more collections, but sharp not installed". So #721's "our upload pipeline … processes operator-supplied images" overstates the surface: uploads store originals, and the resizing that would use sharp is not wired. The reachable consumers are Next's optimizer and the logo script, and the CVE argument stands on the first.

Why an override rather than waiting for next. next 16.2.6 declares sharp only as an optional dependency, at ^0.34.5, with no peer range — so nothing in this repo can widen it, and there is no release to wait for on a known date. [email protected] does declare ^0.35.4, but moving a major-line framework version is not this PR. The scoped key names the condition for removing the entry: it stops matching the moment next's own range moves off ^0.34.5.

libvips is 8.18.6, past the 8.18.3 that sharp 0.35.0 shipped, since the @img/sharp-libvips-* packages version independently.

Refs #721

🤖 Written by the sydevs autonomous loop — see what this is

🤖 Generated with Claude Code

https://claude.ai/code/session_01UrQ5uWNdzuPCR457gN4S7k

@railway-app

railway-app Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-735 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Sep 8, 2026 at 6:09 pm UTC
1 service not affected by this PR
  • mailpit

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

Holistic assessment. This is the right shape and the right size: one behaviour, three files, no source change, exactly item 2 of #721 with the next half correctly left to #732. The override is genuinely load-bearing — I reproduced it, and pnpm audit on this branch clears GHSA-f88m-g3jw-g9cj with 39/25 high, the numbers the body claims. No cross-repo contract is touched; sharp is internal to this repo, and the diff adds no consumer-visible surface. The 370-line lockfile churn is not scope creep: lockfileVersion and the settings: block are unchanged, no other package's version moved, and the churn is @types/node threading through next/payload peer hashes because sharp 0.35 added an optional @types/node peer.

The findings are all about the override entry, not the bump. Two concern its durability — an unscoped ^0.35.4 on a 0.x line is a permanent ceiling, and the rationale beside it rests on a fact that does not hold (next declares ^0.34.5, not an exact pin). Neither changes what this PR installs today.

Findings

  • should-fix — pnpm-workspace.yaml:49: the comment says next "pins sharp: 0.34.5"; it declares ^0.34.5. Conclusion survives, stated reason does not. (thread)
  • should-fix — pnpm-workspace.yaml:54: unscoped key, unlike every sibling. ^0.35.4 on a 0.x line is a ceiling that will silently cap a future bump and downgrade a future next — [email protected] already ships sharp: "^0.35.4". (thread)
  • consider — pnpm-workspace.yaml:11: allowBuilds: sharp: true is now dead — 0.35.4 ships no install script. (file-level thread)
  • consider — package.json:77 → next.config.mjs:70-87: the limitInputChannels row enumerates two of three remotePatterns, skipping the R2 delivery host — the only user-controlled one. (thread)

What was checked

  • Ticket and scope: #721 item 2 read against the whole diff of all three files.
  • Lockfile, read rather than trusted: one sharp version resolves ([email protected], plus its (@types/[email protected]) peer variant); next's optional dependency now reads sharp: 0.35.4(@types/[email protected]) at pnpm-lock.yaml:10635; lockfileVersion: '9.0' and settings: unchanged; only sharp and its @img/* platform packages changed version.
  • Registry, for every claim about next: [email protected] and @16.2.11 both declare sharp: "^0.34.5"; [email protected] declares "^0.35.4". [email protected] has an install script, 0.35.4 has none; its @types/node peer is optional.
  • The 0.35.4 tarball, for the consumer call chain: sequentialRead still accepted, failOnError gone (unused here), limitInputChannels present and defaulting to 5.
  • pnpm audit on this branch: zero sharp/libvips advisories; 39 total, 25 high.
  • The preview, the check no local run makes: GET /_next/image?url=%2Fimages%2Fsahaj-cloud.png&w=256&q=75 → 200, a real 256×256 RGBA PNG (7,523 bytes), and w=384/w=640 served fresh (x-nextjs-cache: MISS) rather than replayed. sharp 0.35.4 decodes and resizes in the deployed Worker. I could not observe an AVIF response — Accept: image/avif,image/webp still returned image/png — so the AVIF-retuning caveat stayed unverified either way; plausibly Next's "original is smaller" path. q=60 returns 400, which is Next 16's images.qualities default and unrelated to this diff.
  • ci.yml: pnpm/action-setup@v4 with no version, so the PR's correction of #721's "pnpm 10" line is right.
  • Not checked: the Railway build log, and any AVIF-producing request.

Advisory only — approval stays with @Ardnived.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread pnpm-workspace.yaml Resolved
Comment thread pnpm-workspace.yaml Resolved
Comment thread pnpm-workspace.yaml Resolved
Comment thread package.json Resolved
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-735 September 8, 2026 14:13 Destroyed
@sydevs-bot sydevs-bot changed the title chore(deps): bump sharp to 0.35.4 for the libvips CVEs, and override next's pinned copy chore(deps): bump sharp to 0.35.4 for the libvips CVEs, and override next's nested copy Sep 8, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

All four review threads answered, two commits pushed. Ready for review.

  • 7e85c15 — the override is scoped to next's declared range, 'sharp@^0.34.5': '^0.35.4'. Unscoped it was a permanent <0.36.0 ceiling on every sharp in the graph, and [email protected] already declares ^0.35.4.
  • 77a6fe2 — allowBuilds: sharp: true goes. sharp 0.35.4 and its @img/* packages ship no scripts, so the entry decided nothing.

Body corrected: next declares ^0.34.5, not an exact pin — the conclusion held, the stated reason did not. The limitInputChannels row now names the R2 delivery host and answers it: Images.ts:25 allows jpeg/png/webp/svg only, max 4 channels.

Resolution is unchanged. pnpm why sharp finds one version, 0.35.4; pnpm audit reads 39 / 25 high with no sharp advisory; pnpm install --frozen-lockfile completes. Lean gate green on 77a6fe2.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@Ardnived

Ardnived commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@sydevs-bot Could we bump next instead of sharp to achieve the fix without a pin?

@Ardnived Ardnived removed the awaiting label Sep 8, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Yes — and it would subsume #732 too. But it is a bigger call than this PR, so it is yours.

Measured, not inferred. package.json already declares next: ^16.2.6, and a caret on 16.x permits 16.3.4. With next: ^16.3.4 set and the override deleted, pnpm install resolves next 16.3.4 + one sharp 0.35.4. No override.

sharp range OSV
next 16.2.6 ^0.34.5 9 advisories, 4 high
next 16.2.11 (#732) ^0.34.5 clean
next 16.3.4 ^0.35.4 clean

sharp 0.34.5 carries GHSA-f88m-g3jw-g9cj; 0.35.3 and 0.35.4 carry none.

So 16.3.4 clears the four next highs #732 targets and the libvips one, and both PRs collapse into one. The cost: a minor framework bump is not a patch, and CI here does not build the app — Railway does.

⚠ Settle first: in that state pnpm install reported ERR_PNPM_IGNORED_BUILDS: [email protected] and wrote sharp: set this to true or false into allowBuilds. It does not on this branch.

Which shape? Keep #735 + #732, or replace both with one next: ^16.3.4 PR?

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

…t's copy

sharp inherits four libvips CVEs (GHSA-f88m-g3jw-g9cj, CVE-2026-33327 /
-33328 / -35590 / -35591), patched in 0.35.0. `package.json` declared
`^0.34.5`, and a caret on a `0.x` version pins the minor, so no in-range
refresh could reach it.

Bumping the manifest alone does not clear the advisory. `next` carries
`sharp: 0.34.5` as its own optional dependency, and `pnpm why sharp` showed
both copies in the tree afterwards — with `pnpm audit` still flagging the
nested one through `next > sharp`. That nested copy is the one the image
optimizer loads, which is the reachable path the ticket named. So the fix is
the manifest bump plus an `overrides` entry, alongside the transitive pins
already there. `pnpm why` now reports one version, and `pnpm audit` reports
no sharp advisory; highs go 26 -> 25.

The override lives in `pnpm-workspace.yaml`, not `package.json`. pnpm 11
moved every setting there and now ignores a `pnpm` field in the manifest with
a warning rather than an error, so an override left behind reads as applied
and silently is not.

Checked against the 0.35.0 breaking changes:

- Node >= 20.9.0. `.node-version` is 22.17.0 and `engines.node` is `>=22.0.0`.
- The removed `install` script is not needed — the `@img/sharp-*` prebuilts
  resolve, and `allowBuilds.sharp` was already `true`.
- The removals (`failOnError`, `paletteBitDepth`, three `sharpen` properties)
  and the `format.jp2k` -> `format.jp2` rename touch nothing here.
  `next/dist/server/image-optimizer.js` calls only `.rotate`, `.resize`,
  `.avif`, `.webp`, `.png`, `.jpeg` and the `sequentialRead` option, and
  `scripts/generate-logo-pngs.ts` is the sole direct consumer in this repo.
- Payload is never handed sharp, so no upload path resizes through it.

Verified: the logo script regenerates all four PNGs byte-identically, `next`
resolves sharp 0.35.4 (libvips 8.18.6), and every format the optimizer emits
round-trips through the exact call chain it uses.

Refs #721

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ABp2XiB7GQSFE8jVPWR65J
The override was unscoped: `sharp: '^0.35.4'`. On a 0.x line a caret is a
ceiling, so that entry pins every sharp in the graph below 0.36 forever —
a later direct bump to 0.36 would edit package.json and change nothing, and
once `next` ships a newer sharp we would silently downgrade it. That is not
hypothetical: [email protected] already declares `sharp: "^0.35.4"`, so the entry's
own removal condition is met by a released next with nothing to surface it.

Scoped to `'sharp@^0.34.5'`, it matches next 16.2.x's declared range and
nothing else. Our own dependency is already ^0.35.4 and needs no override.
The entry stops matching by itself once next moves. Every sibling override
that exists to fix one vulnerable line is scoped the same way.

The comment above it also claimed next "pins sharp: 0.34.5". It declares
`^0.34.5`. The conclusion held — a caret on a 0.x cannot reach 0.35 — but
the stated reason did not, and the removal condition was written against it.

`pnpm why sharp`: one version, 0.35.4, and next's optional dependency
resolves to it. `pnpm audit`: no sharp or libvips advisory, 39 total /
25 high, unchanged from the unscoped entry.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UrQ5uWNdzuPCR457gN4S7k
This file's header says the list exists because pnpm 11 errors on any
undecided build script, so every dependency that ships one must be listed.
sharp 0.34.5 shipped `install: node install/check.js || npm run build`.
sharp 0.35.4 ships no scripts at all, and neither do @img/sharp-linux-x64
0.35.4 or @img/sharp-libvips-linux-x64 1.3.3 (checked on the registry).
So the entry now decides nothing.

The same change removes the source-build fallback: an unsupported platform
fails to resolve a prebuilt rather than compiling one. Nothing compiled
here before either, so no behaviour changes on our platforms.

`pnpm install --frozen-lockfile` completes with no undecided-build-script
error after the removal.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UrQ5uWNdzuPCR457gN4S7k
@Ardnived

Ardnived commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@sydevs-bot Create a new PR which resolves all of these issues together by updating next instead. Make sure you consider all breaking changes and other changes that should be updated in our project. Close all superseded PRs.

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Sep 9, 2026
@sydevs-bot

sydevs-bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 15:00Z address-review · attempt 1 · session · done
  • 15:00Z address-review · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Done — #741 replaces this PR and #732. Closing this as superseded.

Why one next bump clears more than both. Two critical unauthenticated RCE advisories are fixed only in 16.3.3: GHSA-2xp9-vwfh-vxw4 (Image Optimization API) and GHSA-p293-qw3h-jr36 (Windows hosts). #732's 16.2.11 sits inside both ranges, and no sharp bump reaches either.

[email protected] declares sharp: ^0.35.4 itself, so this PR's overrides entry becomes unnecessary. pnpm-workspace.yaml is untouched on #741.

One finding here does not carry over. Removing allowBuilds: sharp: true breaks pnpm install --frozen-lockfile with ERR_PNPM_IGNORED_BUILDS: [email protected] — tested on the new branch. Railpack and CI both run a frozen install, so that removal would have failed the deploy. It also settles the ⚠ from my 16.3.4 experiment above.

Gate on #741: lint, typecheck ×2, unit 1669, integration 1199, and pnpm build. Audit against main: high+critical 31 → 23, moderate 20 → 15.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot closed this Sep 9, 2026
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Sep 9, 2026
@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 9, 2026
Ardnived pushed a commit that referenced this pull request Sep 9, 2026
…and #735 (#741)

* chore(deps): bump next to 16.3.4 and sharp to 0.35.4

Supersedes #732 (next 16.2.11) and #735 (sharp 0.35.4 + an overrides
entry). One bump replaces both, and clears strictly more.

The failure this prevents: two CRITICAL advisories that neither open PR
reaches. Both are unauthenticated remote code execution, and both are
fixed only in next 16.3.3 —

  GHSA-2xp9-vwfh-vxw4  RCE in the Image Optimization API  >=16.0.0 <16.3.3
  GHSA-p293-qw3h-jr36  RCE on Windows-hosted servers      >=16.0.0 <16.3.3

16.2.11, the target of #732, is inside both ranges. No sharp bump
reaches either.

next 16.3.4 declares sharp ^0.35.4 as its own optional dependency, so
bumping our direct `sharp` to ^0.35.4 leaves one copy in the tree with
no overrides entry at all. #735 needed one only because next 16.2.x
declares ^0.34.5, a caret on a 0.x line, which pins the minor.

Measured against origin/main's lockfile on the same day:
high+critical 31 -> 23, moderate 20 -> 15. next 6 -> 0, sharp 2 -> 0.

eslint-config-next moves with next to keep the lint rules on the same
minor.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KMbSpgLANf3FccYW7xJPRv

* docs: say Next.js 16, not 15

Both lines predate this PR — main is already on next 16.2.6 — but a PR
that moves the Next minor is where a reader will check them.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KMbSpgLANf3FccYW7xJPRv

---------

Co-authored-by: sydevs-bot <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
@Ardnived Ardnived removed the awaiting label Sep 9, 2026

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-735 — 283685c3 Deployed Sep 8, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants