Skip to content

Add request size limits to prevent memory exhaustion attacks #1

Description

@greatm3

Currently, the server has no limit on incoming request size. An attacker can send infinite data and crash the server through memory exhaustion.

Tasks:

  • Add MAX_REQUEST_SIZE constant (recommend 1MB = 1024 * 1024 bytes)
  • Track totalBytes in the data event handler
  • Check if totalBytes > MAX_REQUEST_SIZE before processing
  • Respond with HTTP/1.1 413 Payload Too Large when limit exceeded
  • Close connection after sending 413 response

Files to modify:

  • src/httpServer.ts - data event handler

References:

  • RFC 7230 Section 3.3.2 (Message Body Length)
  • OWASP: Denial of Service via resource exhaustion

Activity

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions