Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

collector: limit request body size to prevent OOM#369

Open
johanr-8 wants to merge 1 commit into
google:masterfrom
johanr-8:fix/collector-unbounded-read
Open

collector: limit request body size to prevent OOM#369
johanr-8 wants to merge 1 commit into
google:masterfrom
johanr-8:fix/collector-unbounded-read

Conversation

@johanr-8

Copy link
Copy Markdown

The collector handler reads the entire POST body using ioutil.ReadAll
with no size limit. An attacker can send an arbitrarily large body to
exhaust server memory and crash the server with a single unauthenticated
POST request.

Fix: wrap the body reader with io.LimitReader before reading,
capping input at 1MB which is well above any legitimate CSP or
Reporting API payload size.


import (
"encoding/json"
"io/ioutil"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add an import for "io". Ideally, run goimports.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants