Skip to content

fix: enforce max body size on CSP violation report endpoint (#27243)#27446

Open
github-actions[bot] wants to merge 1 commit into
release/2.35from
backport/27243-to-2.35
Open

fix: enforce max body size on CSP violation report endpoint (#27243)#27446
github-actions[bot] wants to merge 1 commit into
release/2.35from
backport/27243-to-2.35

Conversation

@github-actions

Copy link
Copy Markdown

Backport of #27243

Original PR: #27243 — fix: enforce max body size on CSP violation report endpoint
Merge commit: 0207a98
Requested by: @jdomeracki-coder

The `/api/v2/csp/reports` endpoint is unauthenticated and CSRF-exempt,
since it's the browser's `report-uri` target, and decoded request bodies
with no size limit. This let an attacker post arbitrarily large JSON
bodies to force unbounded heap allocation and OOM the server (Cure53
CDM-02-007).

Wraps the request body in `http.MaxBytesReader` before decoding and
returns 413 when the limit is exceeded, matching the existing convention
used by `files.go`, `aitasks.go`, and `exp_chats.go`.

Fixes: https://github.com/coder/security-disclosures/issues/171
(cherry picked from commit 0207a98)
@github-actions

Copy link
Copy Markdown
Author

Docs preview

📖 View docs preview for docs/reference/api/general.md

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.

2 participants