Skip to content

atlas-search(worker) + id-mail(worker): POST handlers read request bodies with no size cap #11331

Closed

Description

@dezren39

Problem

pkgs/atlas-search/worker/src/index.ts reads the POST /v1/search body with a bare req.json() (line ~75). There is no Content-Length check and no byte cap, so the whole body is buffered and parsed regardless of size. The route only needs { query, k }.

The gate check (gateOk) runs before the read, so only callers holding the gate token reach it. That limits exposure to authenticated callers, but a single oversized request still costs the Worker full memory and CPU before the handler can reject it.

The same bare read pattern appears in nixos/services/id-mail/worker/src/index.js (authenticate runs first, then request.json()). The pm-stack dispatch server already has the equivalent guard (content-length checked up front, then a streamed byte cap in readJsonBody), so the fleet has a tested pattern to copy.

Scope

  • pkgs/atlas-search/worker/src/index.ts: POST /v1/search.
  • nixos/services/id-mail/worker/src/index.js: the POST handler.

Proposed fix

Reject declared Content-Length above a small cap (for example 64 KiB) before reading, and read the stream with a byte cap that returns the route's existing 413/400 envelope. Add a test for oversized and drip-fed bodies on each route, and keep the existing 400 envelopes for non-JSON and non-object bodies.

Oracle

A request whose body exceeds the cap gets a 4xx envelope and the handler never parses it. A normal { query, k } body is unchanged.

Activity

  1. developing-today commented on Nov 17, 2026

    @developing-today
    Contributor
  2. added a commit that references this issue on Nov 17, 2026
  3. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    Fresh verification 2026-11-18 09:50 UTC: #11331 is CLOSED and fixed by merged PR #11435 (merge commit ea6a5f3). Current origin/main includes the fix; id-mail uses readTextUpTo(request, MAX_BODY_BYTES) with a 64 KiB cap, and atlas-search has the corresponding bounded read. No follow-on needed.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions