You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e511d22
Browse filesBrowse the repository at this point in the historyBrowse files
decoding: pixel limit against decompression bombs, robustness fixes
- DecodeOptions.maxPixels / AnimationDecodeOptions.maxPixels (default
16383², like sharp): every decoder checks the size it read before
allocating (PNG, APNG, JPEG, TIFF, WebP/VP8/VP8L, TGA, GIF); animations
count every frame's canvas, GIFs also the frames' indices while
parsing. A 250-byte JPEG of 65500² and a 115 kB GIF with 5000 frames on
4000x4000 killed the process before.
- TIFF: raw samples at most 8 bytes per pixel of the limit, tiles at most
4 times the image (a damaged SamplesPerPixel took 6 GB).
- JPEG: at most 4 components (each took memory the size of the image).
- RangeErrors from damaged data become "Image: damaged or truncated
image data" (cause kept); exceeded limits stay RangeErrors (LimitError).
- PNG: rows unfiltered in place, Image.decode keeps the decoded pixels
(8000x8000: 1272 -> 785 MB), still PNGs in Animation.decode decode like
images (5.8 s -> 0.57 s), APNG frames that replace pixels copy rows.
- blur/sharpen: infinite radii throw instead of hanging, box windows are
summed in time independent of the radius (blur(1e9) took minutes).
Found with fuzzing (damaged corpus images, crafted bombs per format, bad
parameters to every public method); decoded pixels of the whole corpus
are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
0 commit comments