Skip to main content
Menu
Advisories

Nuxt Vite server builder wildcard redirect route rules can redirect to another origin

GHSA-P4H3-4H99-9665Published Updated GitHub

Description

Under the experimental Vite server builder (@nuxt/vite-server), a wildcard redirect route rule whose target starts with ** or /** could redirect to another origin. A request path continuing with an extra / or \ after the rule's prefix (or a path that normalises to one, such as /old/x/..//evil.example) produced a protocol-relative Location header.

Impact

A wildcard redirect rule copies the rest of the request path onto its target. With this configuration:

export default defineNuxtConfig({
  server: { builder: 'vite' },
  routeRules: {
    '/old/**': { redirect: '/**' },
  },
})

the server built by nuxt build (.output/server/index.mjs) redirected a request for /old//evil.example or /old/\evil.example to //evil.example, which browsers follow to evil.example. A link to an affected site can therefore send a visitor to an origin chosen by an attacker.

Only applications that meet all of the following are affected:

  • They build with the experimental Vite server builder (server: { builder: 'vite' }), which was introduced in 4.6.0. Applications on the default Nitro server builder (@nuxt/nitro-server) do not run this code.
  • They deploy its server output. Static output (nuxt generate) and SPA builds (ssr: false) have no server and are not affected.
  • They have a wildcard redirect rule whose target starts with ** or /**, such as '/**' or '/**/x'. Targets with a path before the ** ('/new/**') stay on the same origin.

Nuxt 3 does not include the Vite server builder.

Patches

Fixed in @nuxt/vite-server 4.6.4, which nuxt 4.6.4 depends on. A run of separators (/, \ or their percent-encoded forms) at the start of the copied path now collapses to a single /, so the target stays on the origin it names.

Workarounds

Upgrade to nuxt 4.6.4. If you cannot upgrade, give wildcard redirect targets a path before the ** (for example '/new/**'), or build with the default Nitro server builder.

Affected versions

References

GitHub · nuxt/nuxt