Skip to content

fix(server): reduce express.json body limit from 50 mb to 512 kb [NSoC'26]#142

Open
anshul23102 wants to merge 1 commit into
Shriii19:masterfrom
anshul23102:fix/137-json-body-limit
Open

fix(server): reduce express.json body limit from 50 mb to 512 kb [NSoC'26]#142
anshul23102 wants to merge 1 commit into
Shriii19:masterfrom
anshul23102:fix/137-json-body-limit

Conversation

@anshul23102
Copy link
Copy Markdown

Description

The Express body parser was configured with a 50 MB limit. Legitimate payloads for this API (task objects, chat messages) are at most a few kilobytes. The oversized limit allowed a single request to force the server to allocate and parse 50 MB of JSON before any route handler ran. Combined with the existing rate limiter (100 req / 15 min per IP), an attacker could push up to 5 GB of data per window.

Related Issue

Closes #137

Type of Change

  • Bug fix (security)

Root Cause

The limit: "50mb" value was set on both express.json() and express.urlencoded(). No legitimate request in the application requires more than a few kilobytes.

Changes Made

File Change
backend/server.js Changed express.json({ limit: "50mb" }) to express.json({ limit: "512kb" })
backend/server.js Changed express.urlencoded({ limit: "50mb", ... }) to express.urlencoded({ limit: "512kb", ... })

Screenshots or Demo

Not applicable (backend-only change).

Testing Done

  • Task creation, chat messages, and all other endpoints work correctly with the new limit.
  • A request body larger than 512 KB is rejected by Express with 413 Payload Too Large before reaching any route handler.

Checklist

  • I have read the CONTRIBUTING.md and followed its guidelines
  • My code follows the style and formatting of this project
  • I have tested my changes locally and they work as expected
  • No unnecessary files modified outside the scope of this issue
  • There are no merge conflicts with the base branch
  • This PR is linked to the correct issue
  • I have not used any AI-generated content in this PR

NSoC Label Request

@Shriii19 could you please add the appropriate NSoC '26 label to this PR? Thank you!

…C'26]

A 50 MB body limit allowed a single HTTP request to force the server to
allocate and parse 50 MB of JSON before any route handler ran. Combined
with the existing 100 req / 15 min rate limit, an attacker could push up
to 5 GB of data per IP per window, exhausting server heap memory.

Legitimate payloads for this API (task objects, chat messages, analytics)
are at most a few kilobytes. 512 KB is more than sufficient for any real
request and eliminates the memory-exhaustion vector.

Closes Shriii19#137
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

@anshul23102 is attempting to deploy a commit to the shreemp194-gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

👋 Thank you for opening this pull request! I will review your changes and assist you soon.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security][Level 2] backend/server.js: express.json body limit of 50mb allows single requests to exhaust server memory

1 participant