Skip to content

Limit add-chain/add-pre-chain request body size to prevent memory exh… - #1815

Open
ztzat089-ctrl wants to merge 1 commit into
google:masterfrom
ztzat089-ctrl:fix/limit-add-chain-body-size
Open

Limit add-chain/add-pre-chain request body size to prevent memory exh…#1815
ztzat089-ctrl wants to merge 1 commit into
google:masterfrom
ztzat089-ctrl:fix/limit-add-chain-body-size

Conversation

@ztzat089-ctrl

Copy link
Copy Markdown

Summary

This PR fixes an unbounded memory allocation vulnerability in the add-chain
and add-pre-chain HTTP handlers. ParseBodyAsJSONChain reads the entire
request body via io.ReadAll(r.Body) without any size limit, allowing a
malicious client to send an oversized request and exhaust server memory.

Fix

Applies http.MaxBytesReader to r.Body before it reaches
ParseBodyAsJSONChain, limiting the body to 512000 bytes (matching the
existing maxAddChainBodyBytes constant already used in
submission/proxy_server.go). The error-handling code in addChainInternal
already expected an http.MaxBytesError, but nothing triggered it on the
direct CTFE path — only the proxy path was protected.

Testing

  • go build ./trillian/ctfe/... passes
  • go test ./trillian/ctfe/... passes (all existing tests pass)

Related

Reported via Google OSS VRP, Issue Tracker #542934724.

@ztzat089-ctrl
ztzat089-ctrl requested a review from a team as a code owner August 22, 2026 23:40
@ztzat089-ctrl
ztzat089-ctrl requested review from roger2hk and removed request for a team August 22, 2026 23:40
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