security: add 100KB body size limit to prevent memory exhaustion #60

Merged
pook merged 2 commits from feature/body-size-limit into main 2026-04-09 06:13:32 -04:00
Owner

Summary

  • Adds Hono bodyLimit middleware (100KB max) as the first middleware in the chain, rejecting oversized payloads with 413 before any parsing occurs
  • Returns JSON error response { "error": "Payload Too Large — ..." } matching existing error format
  • Includes 4 E2E tests: oversized payload rejection on generate + questionnaire endpoints, normal payload passthrough, and JSON format verification

Test plan

  • Run bun test packages/api/tests/e2e/body-limit.test.ts against running API
  • Confirm >100KB POST to /generate/privacy-policy returns 413
  • Confirm normal-sized requests still work correctly
  • Verify error response is JSON with { error: "..." } format

🤖 Generated with Claude Code

## Summary - Adds Hono `bodyLimit` middleware (100KB max) as the first middleware in the chain, rejecting oversized payloads with 413 before any parsing occurs - Returns JSON error response `{ "error": "Payload Too Large — ..." }` matching existing error format - Includes 4 E2E tests: oversized payload rejection on generate + questionnaire endpoints, normal payload passthrough, and JSON format verification ## Test plan - [ ] Run `bun test packages/api/tests/e2e/body-limit.test.ts` against running API - [ ] Confirm >100KB POST to `/generate/privacy-policy` returns 413 - [ ] Confirm normal-sized requests still work correctly - [ ] Verify error response is JSON with `{ error: "..." }` format 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Adds Hono bodyLimit middleware as the first middleware in the chain,
rejecting payloads over 100KB with a 413 JSON error response before
any parsing occurs. Includes E2E tests confirming oversized payloads
are rejected and normal requests pass through.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

⚠️ No Test Suite Detected

Commit: 0bde8afd

No test script found in package.json. Add a test script to enable automated testing.

## ⚠️ No Test Suite Detected **Commit:** `0bde8afd` No `test` script found in `package.json`. Add a test script to enable automated testing.
feat: critical-security-without-a-request-body (agent task agent-ta)
Some checks are pending
agent-worker/pr-tests Running PR tests...
0bde8afd99
pook merged commit f15403cad2 into main 2026-04-09 06:13:32 -04:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot!60
No description provided.