Skip to content

webp/decode: validate VP8L dimensions before decoding (upstream security fix)#21

Merged
kovidgoyal merged 1 commit into
masterfrom
copilot/webpdecode
Jul 14, 2026
Merged

webp/decode: validate VP8L dimensions before decoding (upstream security fix)#21
kovidgoyal merged 1 commit into
masterfrom
copilot/webpdecode

Conversation

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Merges golang/image@7a0cfdab into webp/decode.go.

A malicious image could pair a small VP8X header (declaring tiny dimensions) with a huge VP8L chunk. The old code decoded the entire VP8L chunk before checking dimensions, enabling a DoS via memory exhaustion.

Changes

  • Early dimension validation: When a VP8X header has been seen, peek the first 5 bytes of the VP8L chunk via bufio.Reader.Peek and run vp8l.DecodeConfig on them to extract dimensions — before calling vp8l.Decode
  • No overhead: bufio.NewReader wrapping is equivalent to what the vp8l package does internally anyway; the reader is passed through to vp8l.Decode unchanged
  • Reject early: If VP8L-declared dimensions don't match the VP8X canvas size, return errInvalidFormat immediately without decoding the payload

Merge golang/image@7a0cfdab: verify VP8L chunk dimensions before
decoding when seenVP8X is true, to prevent DoS via malicious images
with a small VP8X header but a huge VP8L chunk. Uses bufio.Peek to
read the VP8L header for validation without consuming the reader.
@kovidgoyal
kovidgoyal merged commit 87e9035 into master Jul 14, 2026
8 checks passed
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