Skip to content

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

Merged
BobbyHo merged 1 commit into
mainfrom
coder-plat-377-cdm-02-007
Jul 14, 2026
Merged

fix: enforce max body size on CSP violation report endpoint#27243
BobbyHo merged 1 commit into
mainfrom
coder-plat-377-cdm-02-007

Conversation

@BobbyHo

@BobbyHo BobbyHo commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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

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).

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

Fixes: coder/security-disclosures#171
@linear-code

linear-code Bot commented Jul 14, 2026

Copy link
Copy Markdown

PLAT-377

@github-actions

Copy link
Copy Markdown

Docs preview

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

@BobbyHo
BobbyHo marked this pull request as ready for review July 14, 2026 19:03
@jdomeracki-coder
jdomeracki-coder self-requested a review July 14, 2026 19:12

@jdomeracki-coder jdomeracki-coder left a comment

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.

+1

@geokat geokat left a comment

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.

lgtm 👍

@BobbyHo
BobbyHo merged commit 0207a98 into main Jul 14, 2026
59 of 60 checks passed
@BobbyHo
BobbyHo deleted the coder-plat-377-cdm-02-007 branch July 14, 2026 19:29
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants