Skip to content

[BE-114] AllExceptionsFilter leaks internal exception messages on 500 responses #1256

Description

@yusuftomilola

Overview

AllExceptionsFilter.catch() (backend/src/common/filters/all-exceptions.filter.ts) falls through to message = exception.message for any non-HttpException error, then returns it in the JSON response body. A raw driver error (a Postgres constraint message, an unexpected null-reference stack trimmed to its first line, etc.) is sent straight to the API client. The only existing test for this filter, in backend/src/mxllv-common.spec.ts, is expect(filter).toBeDefined() — it never exercises the actual catch() behavior, so this was never caught.

Tasks

  • For non-HttpException errors, return a fixed generic message (e.g. 'Internal server error') in the response body while still logging the real exception.message/stack via the existing Logger.error() call.
  • Add real tests: assert an HttpException still surfaces its own message/status, and a generic Error thrown from a service surfaces only the generic message with a 500 status.
  • Audit for any place that intentionally relies on the current leaking behavior before changing it.

Acceptance Criteria

  • A thrown non-HTTP Error never puts exception.message in the HTTP response body.
  • HttpException responses are unchanged.
  • New tests cover both branches of catch().

Notes for Contributors

Comment below to be assigned.

Activity

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

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbackendbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions