Fix stack trace leaked in error response in Nuxt

Returning an error's `.stack` to the client exposes absolute file paths, dependency versions, and internal call structure. Attackers use it to map the application and to fingerprint vulnerable dependency versions. Log the stack server-side and return a generic message.

high likely Nuxt CWE-209 / OWASP A05:2021

The vulnerable pattern in Nuxt

HIGH likely Stack trace leaked in error response A05:2021 server/api/users.get.ts:19:22 17 │ throw createError({ 18 │ statusCode: 500, 19 │ statusMessage: (err as Error).stack, │ ~~~~~~~~~~~~~~~~~~~~ leaks internal stack trace to the client 20 │ }) 21 │ }

This finding comes from the Nuxt fixture in the owlwarden test suite, in GET /api/users. Stack traces expose absolute file paths, dependency versions, and internal call structure - enough to fingerprint the stack and locate other weaknesses.

The corrected handler

Throw a createError() without the internal detail; Nitro shapes the response.

console.error(err)
throw createError({
  statusCode: 500,
  statusMessage: 'Internal Server Error',
})

If you are not using Nuxt

Log the error server-side and return a generic message to the client.

Check your own repository

npx owlwarden scan
npx owlwarden explain stack-trace-leak

Runs on your machine. No account, no telemetry, no network unless you ask. In CI, SARIF uploads to code scanning and the exit code is the gate.

Other Nuxt checks

Rules with a tested Nuxt example.

stack-trace-leak for every framework / All rules / owlwarden