Skip to content

[V4] Fix WebP container boundaries and odd-length metadata - #3256

Merged
JimBobSquarePants merged 3 commits into
release/4.1.xfrom
fix/webp-container-boundaries-v4
Oct 27, 2026
Merged

JimBobSquarePants merged 3 commits into
release/4.1.xfrom
fix/webp-container-boundaries-v4

Conversation

@JimBobSquarePants

Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Backports #3233 to release/4.1.x.

The WebP decoder now ignores reserved VP8X fields and bytes after the declared RIFF payload. Odd-length ICC, EXIF and XMP chunks retain their exact payloads and skip their padding separately.

Boundary checks remain in the WebP parser. Required chunks must fit inside RIFF, and decoded frame image chunks must also fit inside ANMF. Unknown chunks are skipped with widened sizes. Animation counts only frames toward MaxFrames and retains metadata read before ANIM. Readers and partially decoded images are disposed on failure. BufferedReadStream and the public API are unchanged.

Only IgnoreImageData permits the existing EOF recovery for incomplete compressed payloads. Required headers and parent boundaries remain mandatory. Incomplete ICC framing remains fatal; EXIF and XMP keep their existing ancillary recovery rules.

All affected container and metadata tests use stored files. The local libwebp reference verifies still pixels, extracted animation frames, metadata payloads and invalid parent boundaries. Tolerances and references are unchanged.

Release checks pass on .NET 8 and .NET 10: the WebP and selected format regressions, plus the final still/animation metadata cases.

Fixes #3245

jafin and others added 3 commits October 27, 2026 16:14
…odd-length metadata chunks

Readers must ignore the reserved VP8X flag bits, so they are no longer
validated. Chunks are now read only up to the end of the RIFF payload,
so bytes after it are ignored rather than parsed as more chunks, and
unknown chunks larger than the payload end the parsing instead of
becoming a negative skip. A stream that ends inside a chunk header,
a 24 bit field or the VP8L header now throws
InvalidImageContentException.

Metadata chunks with an odd payload length are read without the RIFF
padding byte, which is skipped before the next chunk.
@JimBobSquarePants
JimBobSquarePants marked this pull request as ready for review October 27, 2026 06:40
@JimBobSquarePants
JimBobSquarePants merged commit 96bab51 into release/4.1.x Oct 27, 2026
11 checks passed
@JimBobSquarePants
JimBobSquarePants deleted the fix/webp-container-boundaries-v4 branch October 27, 2026 06:40
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.

WebP decoder rejects files with reserved VP8X bits set or bytes after the RIFF payload, and keeps the padding byte of odd-length metadata chunks

2 participants