Fix stack trace leaked in error response in Hapi

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

The vulnerable pattern in Hapi

HIGH likely Stack trace leaked in error response A05:2021 src/server.ts:58:34 56 │ } catch (err) { 57 │ // stack-trace-leak: h.response carries the stack to the client. 58 │ return h.response({ error: (err as Error).stack }).code(500) │ ~~~~~~~~~~~~~~~~~~~~ leaks internal stack trace to the client 59 │ } 60 │ },

This finding comes from the Hapi fixture in the owlwarden test suite. 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 let Boom shape a generic error response.

request.log(['error'], err)
throw Boom.internal('Internal Server Error')

If you are not using Hapi

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

Rules with a tested Hapi example.

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