Skip to content

security: Add body size limit on ingest endpoint (DoS prevention) #293

Description

@ajianaz

What

Add configurable body size limit on the Sentry envelope ingest endpoint to prevent DoS via oversized payloads.

Why

BMAD CTO finding (P0): The ingest endpoint currently has NO body size limit. An attacker can send arbitrarily large Sentry envelopes → memory exhaustion, storage exhaustion, DoS.

BMAD CLO finding: Sentry SDK clients can send payload bombs. Must enforce hard limits.

Changes

  1. Add axum::extract::DefaultBodyLimit or Tower middleware to cap request body size
  2. Recommended limit: 1MB per event (aligns with Sentry's own limits)
  3. Make the limit configurable via Config (env var TRAPFALL_MAX_BODY_SIZE)
  4. Return 413 Payload Too Large for oversized requests
  5. Add test: send oversized envelope → verify 413 response

Testing

  • Unit test: oversized payload → 413
  • Unit test: normal payload → 200/202
  • Integration test: rapid fire many normal-sized events → no crash

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions