next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Next.js vendors vulnerable [email protected] (CVE-2024-21538) in dist/compiled

Open MrLoh opened this issue 1 year ago • 8 comments

Link to the code that reproduces this issue

https://github.com/vercel/next.js/blob/38c4caf22a570868b8c1689c843044807560b4a7/packages/next/package.json#L256

To Reproduce

  1. yarn add next@latest
  2. Inspect node_modules/next/dist/compiled/cross-spawn/package.json
  3. Observe "version": "7.0.3"
  4. Run trivy fs . → CVE-2024-21538 is reported.

Current vs. Expected behavior

When building a project with Next.js 15.3.2, the published package includes a vendored copy of [email protected] under: node_modules/next/dist/compiled/cross-spawn/package.json

This is pinned here: https://github.com/vercel/next.js/blob/38c4caf22a570868b8c1689c843044807560b4a7/packages/next/package.json#L256

This version is flagged as vulnerable with severity high:

  • CVE-2024-21538
  • Fixed in cross-spawn ≥ 7.0.5 (and in 6.0.6 for the 6.x line)

Because the vulnerable manifest is shipped inside next/dist/compiled, tools like Trivy and other SCA scanners report the CVE even if the app itself uses a patched version via resolutions.

Impact:

  • Security scanners flag all images that include recent Next.js as vulnerable.
  • Users cannot override the vendored copy with resolutions since it is compiled in.
  • This blocks clean CI/CD pipelines in environments that require no known CVEs.

Expected behavior:

  • Next.js should bump its vendored cross-spawn to a fixed release (≥7.0.5).
  • Ideally the dist/compiled vendoring strategy should keep up with upstream security patches.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:52:00 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6031
  Available memory (MB): 36864
  Available CPU cores: 14
Binaries:
  Node: 20.19.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 10.13.1
Relevant Packages:
  next: 15.5.2 // Latest available version is detected (15.5.2).
  eslint-config-next: 15.3.2
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

No response

MrLoh avatar Sep 04 '25 20:09 MrLoh

Hello @MrLoh,

Thank you for raising this issue and for the clear context.

I can take this ticket and update the cross-spawn dependency to >=7.0.5 so it will no longer include the vulnerable version. Since this is strictly a dependency upgrade and doesn’t change behavior, I won’t be adding new tests. Existing integration tests will continue to cover usage.

Please let me know what your thoughts are.

Thanks!

vmaineng avatar Sep 04 '25 23:09 vmaineng

Hi @vmaineng that sounds great. I just didn't have the time to raise a PR myself yet.

MrLoh avatar Sep 05 '25 13:09 MrLoh

Apart from this fix. It might be worth raising internally if there is a better way to scan the vendored dependencies for vulnerabilities. This has been fixed for a year already.

MrLoh avatar Sep 05 '25 13:09 MrLoh

We see this a lot using 14.2.32 as well

jeffpppoint avatar Sep 08 '25 13:09 jeffpppoint

I agree, @MrLoh . We could add an automation for scheduled checks to help us catch these cases earlier.

vmaineng avatar Sep 08 '25 23:09 vmaineng

Just flagging the above CVE is if the package is exposed to arbitrary untrusted user input which it is not so is not valid for this case.

ijjk avatar Sep 08 '25 23:09 ijjk

@ijjk fair but it's pretty annoying because it gets flagged when scanning any docker images with next.js

MrLoh avatar Sep 08 '25 23:09 MrLoh

Next.js 16.4.6 ships a compiled copy of cross-spawn under next/dist/compiled/cross-spawn. The v16.4.6 source tag pins cross-spawn to 7.0.3, although the compiled package's manifest does not declare a version. Updating or overriding a separately npm-resolved copy leaves the bundled copy unchanged.

Could the maintainers clarify:

  1. Whether CVE-2026-137199 affects the bundled copy, including whether the vulnerable Windows-specific code path is present.
  2. Whether that code path is reachable during production serving, build/CLI execution, or both.
  3. Whether an officially patched stable release or supported mitigation is available for users on Next.js 16.4.6.

The bundled version is inferred from the tagged build inputs; advisory applicability and runtime reachability have not been independently established.

emon0809 avatar Dec 02 '26 19:12 emon0809