Skip to content

fix(http): limit inbound request body size to 1MB - #4441

Open
stevenvegt wants to merge 2 commits into
masterfrom
fix/request-body-limit
Open

fix(http): limit inbound request body size to 1MB#4441
stevenvegt wants to merge 2 commits into
masterfrom
fix/request-body-limit

Conversation

@stevenvegt

Copy link
Copy Markdown
Member

Adds an inbound request body size limit of 1MB on both the public and internal interfaces, returning 413 (Request Entity Too Large) when exceeded. Until now nothing capped inbound bodies: the only body limits in the repository are outbound (http/client), and the deployment documentation's claim that "the Nuts node will also limit the size of request bodies" was false. The documentation now states the actual limit.

The limit is deliberately not configurable. The heaviest legitimate request is an OAuth POST carrying a Verifiable Presentation; a deliberately heavy case (5 JWT-encoded credentials, each with an RSA-4096 x5c chain of 4 certificates) computes to roughly 133 kB, and the two-VP jwt-bearer flow to roughly 260 kB, so 1MB keeps several times headroom over anything real. It also matches the client_max_body_size 1M the deployment documentation already recommends configuring on a reverse proxy, so node and proxy guidance agree.

Implementation: echo's middleware.BodyLimit installed through MultiEcho.Use with the other global middleware in Engine.Configure, after the request logger so rejected requests still produce a request log entry.

Testing: new TestEngine_RequestBodyLimit asserts a 512 kB body is accepted (200), a 2 MB body is rejected with 413 on the public interface, and a 2 MB body is rejected with 413 on a route bound to the internal interface. Before the fix, both 2 MB requests returned 200.

Nothing capped inbound request bodies: the only body limits in the
repository are outbound (http/client), so any caller could POST an
arbitrarily large body to any endpoint on either interface. The
deployment documentation also claimed the node limits request body
sizes, which was not the case until now.

Install echo's BodyLimit middleware on all interfaces, fixed at 1MB,
returning 413 when exceeded. A deliberately heavy Verifiable
Presentation (5 JWT credentials, each with an RSA-4096 x5c chain of
4 certificates) is around 133 kB, so 1MB leaves roughly 7x headroom,
and matches the client_max_body_size the documentation recommends
for reverse proxies.

Assisted-by: AI
@qltysh

qltysh Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

0 new issues

Tool Category Rule Count

@qltysh

qltysh Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
Coverage rating: B Coverage rating: B
http/engine.go100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

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.

1 participant