Skip to content

internal/format: bound header size during Parse#699

Open
sweis wants to merge 1 commit intoFiloSottile:mainfrom
sweis:claude/add-header-size-limit-HXoHp
Open

internal/format: bound header size during Parse#699
sweis wants to merge 1 commit intoFiloSottile:mainfrom
sweis:claude/add-header-size-limit-HXoHp

Conversation

@sweis
Copy link

@sweis sweis commented Mar 12, 2026

format.Parse accumulates stanza bodies with no cap on total header bytes, so
a crafted header can exhaust memory in an automated age.Decrypt caller before
any MAC is checked.

Fix: wrap the input in a counting reader that errors at 16 MiB. The payload
reader is reconstituted from bufio's overread prepended to the original input
as before; the rr == input short-circuit is removed since the wrapper makes
it unreachable.

Test: go test ./internal/format/ -run TestParseHeaderSizeLimit -v
(feeds an infinite-stanza-body reader; pre-fix this would read forever.)

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