Skip to content

vp8l: reject images with dimensions exceeding 128 megapixels#31

Open
herdiyana256 wants to merge 1 commit into
golang:masterfrom
herdiyana256:fix/vp8l-oversized-dimensions-oom
Open

vp8l: reject images with dimensions exceeding 128 megapixels#31
herdiyana256 wants to merge 1 commit into
golang:masterfrom
herdiyana256:fix/vp8l-oversized-dimensions-oom

Conversation

@herdiyana256
Copy link
Copy Markdown

@herdiyana256 herdiyana256 commented May 5, 2026

A crafted VP8L header with width=16384 and height=16384 (the
maximum values encodable in 14-bit fields) causes decodePix to
allocate 41638416384 = 1,073,741,824 bytes (~1 GB) per Decode
call. The allocation succeeds silently: Decode returns a nil
error, so callers cannot detect or limit the resource consumption.

Attack: a 28-byte file is sufficient to trigger the allocation.
No authentication or special knowledge is required. Five concurrent
requests produce ~5.37 GB of heap pressure, enough to OOM-kill a
typical containerized service.

Fix: add a pixel-count guard in decodeHeader, before any pixel
data is read, that returns an error when width*height exceeds
1<<27 (~128 megapixels; 512 MB at 4 bytes per pixel).

This is consistent with:

A regression test is included: TestDecodeOversizedDimensions
verifies that the crafted 28-byte input returns an error without
allocating the 1 GB buffer.

Updates golang/go#78267

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 5, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

A crafted VP8L header with width=16384 and height=16384 (the maximum
values encodable in 14-bit fields) causes decodePix to allocate
4*16384*16384 = 1,073,741,824 bytes (~1 GB) per Decode call.
The allocation succeeds silently: Decode returns a nil error, so
callers cannot detect or limit the resource consumption.

Add a pixel-count guard in decodeHeader, before any pixel data is
read, that rejects images whose width*height exceeds 1<<27
(~128 megapixels, 512 MB at 4 bytes per pixel).

This is consistent with the guard added to the tiff decoder for
CVE-2026-33809 (golang/go#78267) and with the existing canvas-size
check in the VP8X code path in the webp package.

Fixes golang/go#XXXXX
@herdiyana256 herdiyana256 force-pushed the fix/vp8l-oversized-dimensions-oom branch from 313d32b to 2202243 Compare May 5, 2026 18:03
@gopherbot
Copy link
Copy Markdown
Contributor

This PR (HEAD: 2202243) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/image/+/774460.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@herdiyana256 herdiyana256 changed the title vp8l :reject images with dimensions exceeding 128 megapixels vp8l: reject images with dimensions exceeding 128 megapixels May 5, 2026
@gopherbot
Copy link
Copy Markdown
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/774460.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Copy Markdown
Contributor

Message from Gopher Robot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.


Please don’t reply on this GitHub thread. Visit golang.org/cl/774460.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Copy Markdown
Contributor

Message from herdiyanitdev:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/774460.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Copy Markdown
Contributor

Message from herdiyanitdev:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/774460.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Copy Markdown
Contributor

Message from herdiyanitdev:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/774460.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Copy Markdown
Contributor

Message from herdiyanitdev:

Patch Set 3: Code-Review+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/774460.
After addressing review feedback, remember to publish your drafts!

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