Skip to content

Security: cap request bodies on the sign-in and password routes - #606

Merged
SandObserver merged 2 commits into
mainfrom
security/cap-auth-request-bodies
Nov 2, 2026
Merged

SandObserver merged 2 commits into
mainfrom
security/cap-auth-request-bodies

Conversation

@SandObserver

@SandObserver SandObserver commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add AUTH_BODY_LIMIT (32 KB) in api/src/router.js and let readBody take a per-route limit.
  • Read the login, set-password and toggle bodies with AUTH_BODY_LIMIT instead of the general 2 MB limit. An oversized body gets 400 from the API.
  • Add an nginx location ^~ /api/auth/ with client_max_body_size 32k, so oversized auth bodies get 413 before they reach the API.

Testing
All green. Added 5 tests: an oversized body on login, set-password and toggle gets 400, the largest real body still fits, and the nginx limit matches AUTH_BODY_LIMIT.

Changelog

Security

  • Refuse sign-in and password requests larger than 32 KB, so parallel large requests to these routes can no longer exhaust the container's memory.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.

The login, set-password and toggle routes read up to the general 1 MB body
limit before any session check. Parallel large bodies could exhaust the API's
memory. nginx and the API now both refuse auth bodies above 32 KB.
@SandObserver
SandObserver merged commit 2d5c79f into main Nov 2, 2026
8 checks passed
@SandObserver
SandObserver deleted the security/cap-auth-request-bodies branch November 2, 2026 23:10
stackyard-release Bot pushed a commit that referenced this pull request Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Security fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant