Fix stack trace leaked in error response in SvelteKit

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 SvelteKit CWE-209 / OWASP A05:2021

The vulnerable pattern in SvelteKit

HIGH likely Stack trace leaked in error response A05:2021 src/routes/reports/[id]/+server.ts:12:26 10 │ } catch (err) { 11 │ // stack-trace-leak: the client learns the file layout and dependency versions. 12 │ return json({ error: (err as Error).stack }, { status: 500 }) │ ~~~~~~~~~~~~~~~~~~~~ leaks internal stack trace to the client 13 │ } 14 │ }

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

The corrected handler

Log server-side and return a generic body from the endpoint. SvelteKit's `handleError` hook is where the detail belongs.

console.error(err)
return json({ error: 'Internal Server Error' }, { status: 500 })

If you are not using SvelteKit

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 SvelteKit checks

Rules with a tested SvelteKit example.

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