Skip to content

Patch frontend dependency security advisories - #154

Merged
LZylstra merged 9 commits into
mainfrom
chore/security-deps
Nov 11, 2026
Merged

LZylstra merged 9 commits into
mainfrom
chore/security-deps

Conversation

@LZylstra

@LZylstra LZylstra commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Scope

  • Bump frontend frameworks within their current majors to pick up security patches: Next.js 15.2 → 15.5.29, Nuxt → 4.6.4, Astro 6.0 → 6.4.8, SvelteKit → 2.70.4, Svelte → 5.57.3, Vite (8.3.7 in SvelteKit, newest that's >24h old), sharp → 0.35.5, ESLint → 9.39.5
  • Regenerate all six frontend lockfiles from scratch. Most of the ~867 Dependabot alerts were in dependencies of dependencies (node-forge, tar, nanotar, devalue, seroval, etc.) that a fresh resolve clears without any direct bump
  • Add minimumReleaseAge: 1440 to every frontend's pnpm-workspace.yaml. CI installs with pnpm latest (12.x), which rejects lockfile entries published in the last 24h, and my first pass resolved locally with pnpm 10, which doesn't enforce it. Now local resolution follows the same supply-chain policy as CI
  • Replace the stale pnpm overrides with a small range-scoped set (sharp@<0.35.5, postcss@<8.5.23, postcss-selector-parser@<6.1.5, cookie@<0.7.0). The old cms/nuxt list had ~20 pins, and two of them (unhead: 2.1.12, h3: ^1.15.9) broke Nuxt 4.6, which now needs unhead v3 and h3 v2. npm overrides in package.json are mirrored to match. The Next apps also keep package.json#pnpm.overrides (and cms-i18n/nextjs's workspace file has a packages field) because Vercel's cms-nextjs project installs with pnpm 9, which only reads overrides from there
  • cms/nuxt: retarget the nitropack patch from 2.13.1 to 2.13.6 (Nuxt 4.6 needs ^2.13.6, and the fix still isn't upstream). Bump packageManager from pnpm 10.15.1 to 10.28.2, because 10.15 ignores allowBuilds, so sharp/esbuild install scripts were being skipped
  • Upgrade @nuxt/icon 1.11 → 2.6.2 in both Nuxt apps and drop cms/nuxt's direct @iconify/utils dependency and override (added in Fix issue with visual editing demo #112). @nuxt/icon 1.x was the last package on @iconify/utils 2.x, and the mix of copies made Nitro's server bundle import one from a path outside the project, so every SSR page 500ed. Now everything resolves to a single 3.1.7. The only breaking change in @nuxt/icon 2 is requiring Nuxt 4
  • cms-i18n/nuxt: move from pnpm 8.6.0 (lockfile v6) to 10.28.2 and add a pnpm-workspace.yaml. Align its Nuxt modules with cms/nuxt (@nuxtjs/seo 3 → 5, sitemap, fonts, tailwindcss, unhead 3) to get rid of the old unhead v2 / nuxt-og-image chain
  • Add cms-i18n/nextjs and cms-i18n/nuxt to the CI build matrix. They landed two days after the matrix was added in Add CI validation, release automation, and DX tooling #99 and never got wired in, even though they carried ~350 of the alerts
  • next-env.d.ts picks up the routes.d.ts reference that Next 15.5 writes on every build, so it doesn't show up as a local change for everyone

Potential Risks / Drawbacks

  • Fresh lockfiles mean every transitive dependency moved to the latest version its range allows. Everything still builds, but there's a small risk of a runtime regression somewhere the build doesn't exercise
  • sharp 0.34 → 0.35 is forced via override under Next/Astro/@nuxt/image. The build doesn't exercise runtime image optimization, so it's worth a quick look at images in a preview
  • cms-i18n/nuxt jumps two majors on @nuxtjs/seo (3 → 5). It builds and type checks the same as before, but SEO/OG output is worth a quick look
  • Anyone running cms-i18n/nuxt with corepack will now get pnpm 10 instead of 8

Tested Scenarios

  • Emulated CI's install with pnpm 12.18.0 install --frozen-lockfile for all six apps (passes the release-age and build-script checks). Both Next apps also install frozen on pnpm 9 and 10
  • Ran every frontend against the local Directus stacks (cms and cms-i18n), with main running side by side for comparison. Next/Nuxt ran as production builds, Astro/SvelteKit as dev servers
  • Routes (/, /blog, a post, /about-us, /contact, /privacy-policy, sitemap.xml, robots.txt, a 404, plus /es, /de, /fr for i18n): every status code matches main. A few routes fail the same way on both, which is pre-existing and not dependency related (SvelteKit 500s on sitemap/robots/404, and Next returns 200 for missing pages, which I'm fixing in a separate PR). Blog post pages initially failed too, but that was my local DB predating the 2.0.0 authors migration. After migrating, posts render with authors in all six apps
  • Headless Chrome screenshots of home pages: identical to main for Next, Nuxt and SvelteKit, and for both i18n apps in en, es and ar (RTL). Astro only differs by its dev toolbar
  • pnpm install --frozen-lockfile + pnpm build for all six frontends, using .env.example like CI (Directus fetches fail as expected without a running instance, but builds complete)
  • pnpm audit per app: down from ~880 alerts total to 4–7 per app, all of which are major-only fixes or have no upstream fix
  • Type checks compared against main: Nuxt errors are unchanged (all pre-existing). SvelteKit svelte-check went from 66 errors to 55, with one new one ("Type instantiation is excessively deep" in DynamicForm.svelte:47). I ruled out the superforms and Svelte versions and the arktype, effect and valibot bumps, but haven't pinned down the cause. Type-only, and CI doesn't run svelte-check

Review Notes

Vercel – starters-nuxt-new (a personal-account project) fails on this PR while the three team projects that build cms/nuxt pass. I can't see its logs or settings, so someone with access should take a look. It isn't a required check.

What's left is intentionally out of scope. I'd like to handle these as their own PRs since they need actual code changes:

  1. Astro 7: fixes a critical advisory (GHSA-26w7-cxv4-gfx2, RCE through AVIF image optimization). Should be next
  2. zod 3 → 4: fixes a high-severity memory-exhaustion advisory. Touches form schemas in every app except Astro, and might also clear the SvelteKit type error above
  3. SvelteKit 3: only two low advisories, so it can wait for the ecosystem to catch up

glob 14, minimatch 11 and esbuild 0.28 are build-time only and come in through other packages, so I'd rather let those clear on a future lockfile refresh than force majors through overrides. deepmerge has no upstream fix, so I'll dismiss those alerts.

The diff is ~27k lines, but nearly all of it is lockfiles. The interesting bits are the package.json and pnpm-workspace.yaml files and the workflow change.

Estimated review time: ~20m

🤖 Generated with Claude Code

Bump Next.js 15.5, Nuxt 4.6, Astro 6.4, SvelteKit 2.70, Vite and sharp 0.35,
regenerate lockfiles, and replace stale pnpm overrides with a minimal scoped set.
Move the Nuxt frontends to pnpm 10.28 so allowBuilds is honored, retarget the
nitropack patch to 2.13.6, and build the cms-i18n frontends in CI.
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cms-nextjs Ready Ready Preview Nov 11, 2026 11:17pm UTC
cms-nuxt Ready Ready Preview Nov 11, 2026 11:17pm UTC
cms-svelte Ready Ready Preview Nov 11, 2026 11:17pm UTC
pizza-frontend Ready Ready Preview Nov 11, 2026 11:17pm UTC
starters-nuxt-new Error Error Nov 11, 2026 11:17pm UTC
visual-editor-demo Ready Ready Preview Nov 11, 2026 11:17pm UTC

Request Review

Without the override the lockfile resolves 2.3.0, 3.1.0 and 3.1.7, and the
Nitro server bundle traces an @iconify/utils import to a path outside the
project, so every SSR page returns 500.
@nuxt/icon 1.x was the only package still on @iconify/utils 2.x. With it on
2.x every package resolves a single @iconify/utils 3.1.7, so the direct
dependency and override in cms/nuxt aren't needed.
CI installs with pnpm latest (12.x), which rejects lockfile entries
published in the last 24 hours. The lockfiles were resolved locally with
pnpm 10, which doesn't apply that policy, so CI failed on brand-new
brace-expansion, caniuse-lite and rolldown releases.

Set minimumReleaseAge: 1440 in every frontend's pnpm-workspace.yaml so
local resolution matches CI, and re-resolve the lockfiles. Pin vite to
8.3.7 in cms/sveltekit since 8.3.8 is under a day old (8.1.6 is the
patched floor).
* Fix Nuxt 4.6 build warnings, pnpm floors and CI pnpm pin

* Pin CI pnpm to 12.18.0 to keep the lockfile release-age check

@bryantgillespie bryantgillespie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

…lteKit advisory (#155)

* Render Next.js pages on the server and return 404 for missing pages

ThemeProvider returned null until it mounted, so server HTML had no page
content and notFound() never reached the response, leaving missing pages
at 200. It's now a plain next-themes wrapper, which already handles SSR
and stores the theme under the same key.

Rendering the layout on the server surfaced useVisualEditing calling
useSearchParams() without a Suspense boundary. The hook only reads the
query string inside an effect, so it reads window.location instead.

Missing blog posts rendered a 404 message with a 200 status; they now call
notFound().

* Return 404 instead of 500 for unknown SvelteKit pages

fetchPageData threw for a missing page and the catch wrapped it in a
generic error, so the catch-all route rethrew a plain Error and SvelteKit
answered 500. fetchPageData now returns null for no match, and the route
calls error(404) outside its try/catch. Real fetch failures still 500.

* Answer missing Astro blog posts with a 404 instead of a redirect

Redirecting to /404 answered 302. An empty 404 Response makes Astro render
404.astro at the requested URL. Astro.rewrite('/404') isn't allowed here
because 404.astro is prerendered and the blog route isn't.

* Serve robots.txt from every CMS frontend and add a SvelteKit sitemap

Only Nuxt served robots.txt (via @nuxtjs/seo). Next.js, Astro and SvelteKit
now return the same rules: allow all crawlers and point at /sitemap.xml.
SvelteKit was the only frontend without a sitemap; it now lists published
pages and posts like the Next.js and Astro sitemaps.

* Let cms-i18n Next.js API routes reach their handlers

The locale middleware treats any 2-3 letter first path segment as a
locale, so "/api" became a locale and every /api request was rewritten
to a page route. Form submissions failed and search never returned
results. Skip /api in the middleware like the Nuxt app does, and have
the search modal send x-locale so its links stay localized.

* Only treat Directus languages as locale prefixes in cms-i18n

Both i18n frontends treated any 2-3 letter first path segment as a
locale, so a page with a short slug like /faq rendered the home page
under a "faq" locale, unknown short paths returned 200 instead of 404,
and the language switcher dropped the page when switching languages.

getLocaleFromPath and removeLocaleFromPath now take the locale map built
from the Directus languages collection and only strip codes in it.

- Next.js: the middleware loads the map (public languages, cached for a
  minute) and the layout shares it with client components through a
  LocaleMapProvider.
- Nuxt: the server middleware loads the map (cached) and puts it on the
  request context, and useLocaleMap carries it to the client for the
  route middleware, useLocale and the language switcher.

* Set <html lang> for the current locale in cms-i18n Nuxt

@nuxtjs/seo sets <html lang>, og:locale and the canonical URL from its
site config, which always fell back to "en" and overrode the layout's
lang. The locale middleware now sets the site config's currentLocale per
request, so /es renders lang="es-ES" and /ar lang="ar-SA".

* Reject // paths in the SvelteKit starter

Mitigates GHSA-pfhg-q3qv-9q6r (open redirect through use:enhance on paths
starting with "//", which the catch-all route accepts). It's only fixed
in SvelteKit 3, so this can go once the starter upgrades.

* Fix Astro blank 404, Nuxt locale map cache, and Next 404/theme issues (#158)

---------

Co-authored-by: Bryant Gillespie <bryant@directus.io>
* Upgrade the CMS frontends to Zod 4

Clears GHSA-mrhx-c7xc-m3w5 (memory exhaustion validating oversized
constrained collections), only fixed in zod 4.6.6+.

- Next.js: @hookform/resolvers 5.9.2, whose zodResolver supports Zod 4.
  Refine callbacks get type guards since Zod 4 infers unknown, not any.
- Nuxt: @vee-validate/zod imports Zod 3 internals and only supports Zod 3,
  so forms use a small local toTypedSchema adapter. @directus/types moves
  to 18.1.0 (what Directus 12.6.1 uses), which also drops its pinned
  zod 4.1.12.
- SvelteKit: Superforms' zod4Client adapter. This also clears the
  "Type instantiation is excessively deep" error in DynamicForm.svelte.
- All builders use .optional() for optional fields instead of
  .or(z.undefined()). Zod 4 rejects a missing key for the latter, so
  server-side validation refused submissions that left optional fields
  out. Astro was already on Zod 4 and had the same problem.

* Upgrade the Astro frontend to Astro 7

Clears the remaining Astro advisories, including GHSA-26w7-cxv4-gfx2
(RCE through AVIF image optimization), only fixed in 7.x.

- astro 7.4.9, @astrojs/vercel 11.0.20, vite 8.3.7
- @astrojs/react 7.1.5: 7.1.6 imports @astrojs/internal-helpers/renderer,
  which the 0.13.1 it pins doesn't export. Fixed in 7.1.7, which is still
  inside the 24h minimum release age.
- Route caching is stable: experimental.cache moves to top-level cache,
  and experimental.queuedRendering is now the default.

* Skip malformed length rules and fix optional Nuxt file fields (#159)

---------

Co-authored-by: Bryant Gillespie <bryant@directus.io>

This branch had an error being deployed

1 failed and 5 active deployments
Preview – cms-svelte — 022e20a4 Deployed Nov 11, 2026 by vercel[bot]
Preview – cms-nextjs — 022e20a4 Deployed Nov 11, 2026 by vercel[bot]
Preview – pizza-frontend — 022e20a4 Deployed Nov 11, 2026 by vercel[bot]
Preview – visual-editor-demo — 022e20a4 Deployed Nov 11, 2026 by vercel[bot]
Preview – cms-nuxt — 022e20a4 Deployed Nov 11, 2026 by vercel[bot]
Preview – starters-nuxt-new — 022e20a4 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants