Repository navigation
chore(deps): bump sharp to 0.35.4 for the libvips CVEs, and override next's nested copy - #735
sydevs-bot wants to merge 3 commits into
Conversation
|
🚅 Deployed to the SahajCloud-pr-735 environment in sahajcloud
1 service not affected by this PR
|
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 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 saysnext"pinssharp: 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.4on a0.xline is a ceiling that will silently cap a future bump and downgrade a futurenext—[email protected]already shipssharp: "^0.35.4". (thread)consider—pnpm-workspace.yaml:11:allowBuilds: sharp: trueis now dead — 0.35.4 ships noinstallscript. (file-level thread)consider—package.json:77→next.config.mjs:70-87: thelimitInputChannelsrow enumerates two of threeremotePatterns, 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 readssharp: 0.35.4(@types/[email protected])atpnpm-lock.yaml:10635;lockfileVersion: '9.0'andsettings:unchanged; only sharp and its@img/*platform packages changed version. - Registry, for every claim about
next:[email protected]and@16.2.11both declaresharp: "^0.34.5";[email protected]declares"^0.35.4".[email protected]has aninstallscript,0.35.4has none; its@types/nodepeer is optional. - The 0.35.4 tarball, for the consumer call chain:
sequentialReadstill accepted,failOnErrorgone (unused here),limitInputChannelspresent and defaulting to 5. pnpm auditon 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), andw=384/w=640served 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/webpstill returnedimage/png— so the AVIF-retuning caveat stayed unverified either way; plausibly Next's "original is smaller" path.q=60returns 400, which is Next 16'simages.qualitiesdefault and unrelated to this diff. ci.yml:pnpm/action-setup@v4with 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
|
All four review threads answered, two commits pushed. Ready for review.
Body corrected: Resolution is unchanged. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
@sydevs-bot Could we bump |
|
Yes — and it would subsume #732 too. But it is a bigger call than this PR, so it is yours. Measured, not inferred.
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 ⚠ Settle first: in that state Which shape? Keep #735 + #732, or replace both with one 🤖 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
77a6fe2 to
283685c
Compare
|
@sydevs-bot Create a new PR which resolves all of these issues together by updating |
|
Done — #741 replaces this PR and #732. Closing this as superseded. Why one
One finding here does not carry over. Removing Gate on #741: lint, typecheck ×2, unit 1669, integration 1199, and 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
…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]>
Summary
sharp0.34.5 → 0.35.4, clearing GHSA-f88m-g3jw-g9cj (four libvips CVEs). Highs drop 26 → 25.nextdeclaressharp: ^0.34.5as its own optional dependency, and a caret on a0.xline pins the minor — so the fix is out of next's range too, and it is that nested copy the image optimizer loads. Anoverridesentry is what clears it.Changes
package.json—^0.34.5→^0.35.4. Out of range before, for the same caret reason.pnpm-workspace.yaml— oneoverridesentry, 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-deadallowBuilds: sharp: truegoes in the same file.pnpm-lock.yaml— the resolution.Why the override is scoped. Unscoped,
^0.35.4on a0.xline 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 editpackage.jsonand change nothing, and oncenextships a newer sharp we would quietly downgrade it —[email protected]already declaressharp: "^0.35.4", so the removal condition is met by a releasednexttoday. Scoped, the entry matches next 16.2.x only, leaves our own (already-bumped) direct dependency alone, and stops matching by itself oncenextmoves. Every sibling override that fixes one vulnerable line is scoped the same way.Preview
Test results
1c3b310, the commit before the review round — Lint, Test & Smoke, and the Railway preview deploy. CI runs again on77a6fe2.77a6fe2: ✓pnpm lint,pnpm typecheck,pnpm typecheck:tests,pnpm test:unit(126 files, 1646 tests)pnpm install --frozen-lockfile: ✓ completes, with no undecided-build-script error after theallowBuildsremoval.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:
next/dist/server/image-optimizer.jsuses.rotate,.resize,.avif,.webp,.png,.jpegand thesequentialReadoption, and nothing else. Every one round-trips on 0.35.4. Confirmednextresolves sharp 0.35.4 / libvips 8.18.6 through its ownrequire, not 0.34.5.scripts/generate-logo-pngs.ts, the sole direct consumer in this repo, regenerates all four PNGs byte-identically under 0.35.4./_next/imagelink 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
pnpm auditstill reports the advisory throughnext > sharp, and the PR would claim a fix it had not made. chore(deps): next 16.2.6 carries a reachable Server Actions DoS, and sharp needs an out-of-range bump #721 predicted a manifest edit alone; that turned out not to be enough.pnpm-workspace.yaml, and pnpm will not tell you otherwise. pnpm 11 moved every setting out of thepackage.jsonpnpmfield, and now ignores an override left there with a warning rather than an error — it reads as applied and silently is not. Verified by trying that first:pnpm whystill showed two versions.nexttoo, which is the entire point, but it is a versionnextdid not choose. The 0.35.0 breaking changes are checked against both consumers above; the residual risk was Next behaviour no local run can exercise, which the green preview deploy now covers as far as boot and build go.iqmetrics, so/_next/imageAVIF output at a givenqualitywill differ in size and encoding from before. Visual quality should be equal or better; byte sizes will move.next16.2.11 half is chore(deps): bump next to 16.2.11 for the reachable Server Actions DoS #732. That PR also touchespnpm-lock.yaml, so whichever merges second needs a lockfile rebase — cheap, but not automatic.ci.ymlpins".ci.ymlusespnpm/action-setup@v4with no version, so it readspackageManagerfrompackage.json—[email protected], which is what generated this lockfile.Detail
The 0.35.0 breaking changes, each checked rather than assumed.
.node-versionis 22.17.0,engines.nodeis>=22.0.0.installscript removedallowBuilds.sharpwastrue. 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.failOnErrorconstructor property removedpaletteBitDepthdropped from metadatasharpenproperties removed.sharpen().format.jp2krenamedformat.jp2limitInputChannels, new, default 5/_next/image.next.config.mjs:70-87declares threeremotePatterns: the R2 delivery host,**.cloudflarestream.comandimg.shields.io. R2 is the only user-controlled one, and it serves what the Images collection stored —Images.ts:25allows 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.iqPayload never receives sharp.
grep -rn sharp src/returns onlycsharpin the OpenAPI plugin's language list, andsrc/payload.config.tspasses nosharpkey — 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.next16.2.6 declaressharponly 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 momentnext'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