Skip to content

fix(api): reject oversized JSON and idle HTTP connections #1137

Closed

Description

@frahlg

The HTTP server caps header time only. Request bodies can trickle forever, and readJSON truncates at 1 MiB instead of failing.

Found on master 6eadec3f.

What happens

go/cmd/ftw/main.go and bootstrap.go set ReadHeaderTimeout: 10s and nothing else: no ReadTimeout, WriteTimeout, or IdleTimeout.

readJSON uses io.LimitReader(r.Body, 1<<20). Oversized JSON is truncated, then json.Unmarshal either 400s opaquely or succeeds on a complete prefix. The leftover body stays on the connection. ftw-updater already uses http.MaxBytesReader.

What a fix needs

  • ReadTimeout / WriteTimeout / IdleTimeout on both the boot server and the main server.
  • readJSON through http.MaxBytesReader; fail when the cap is hit, do not unmarshal a prefix.
  • Tests for a body just under 1 MiB, just over, and the MaxBytesReader error path.

This is independent of DuckDB (#1129) and of the history points cap.

Activity

  1. added a commit that references this issue on Sep 8, 2026
    55549bb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions