The security vulnerability is a bypass of the same-origin policy check in the Nuxt development server middleware used by @nuxt/webpack-builder and @nuxt/rspack-builder. The analysis of the provided patches (commits e351de94 and 77187ee4) reveals the root cause.
The patches show that a function named isSameOriginRequest was removed from packages/webpack/src/webpack.ts and replaced with a more secure implementation in a new file, packages/webpack/src/utils/same-origin.ts.
The vulnerable implementation of isSameOriginRequest contained a critical flaw. If a request was received without an Origin or Referer header, the function would immediately return true, effectively trusting the request as being from a same-origin source. The vulnerability description details how an attacker can construct a cross-origin request (e.g., using a <script> tag with referrerpolicy="no-referrer" from a non-trustworthy origin) that arrives at the dev server without any Sec-Fetch-Site, Origin, or Referer headers.
The vulnerable function would process this header-deficient request and incorrectly permit it, leading to source code leakage.
The patch rectifies this by changing the logic. The new implementation, when faced with the same scenario (no Origin or Referer), no longer defaults to true. Instead, it checks if the server is bound to a loopback address (localhost, 127.0.0.1, etc.). Access is only granted if the host is a loopback address, effectively closing the loophole that allowed attacks over a local network when using --host.