Skip to content

Security: Internal error details and stack traces are returned to API clients#2145

Open
tomaioo wants to merge 1 commit intoasyncapi:masterfrom
tomaioo:fix/security/internal-error-details-and-stack-traces-
Open

Security: Internal error details and stack traces are returned to API clients#2145
tomaioo wants to merge 1 commit intoasyncapi:masterfrom
tomaioo:fix/security/internal-error-details-and-stack-traces-

Conversation

@tomaioo
Copy link
Copy Markdown

@tomaioo tomaioo commented Apr 24, 2026

Summary

Security: Internal error details and stack traces are returned to API clients

Problem

Severity: High | File: src/apps/api/middlewares/problem.middleware.ts:L31

The global problem handler serializes 5xx errors with includeStack: true and includeCause: true, then returns them in JSON responses. This can expose internal implementation details (stack traces, dependency paths, error causes), which helps attackers with reconnaissance and exploit development.

Solution

Do not include stack traces or causes in client-facing responses by default. Gate verbose error output behind a strict development-only check (e.g., NODE_ENV === 'development'), and always return sanitized generic messages in production.

Changes

  • src/apps/api/middlewares/problem.middleware.ts (modified)

The global problem handler serializes 5xx errors with `includeStack: true` and `includeCause: true`, then returns them in JSON responses. This can expose internal implementation details (stack traces, dependency paths, error causes), which helps attackers with reconnaissance and exploit development.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 24, 2026

⚠️ No Changeset found

Latest commit: c2be75c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

1 participant