SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.26k stars 844 forks source link

File (detected as bmp) fails to open, consumes a lot of memory #2696

Closed skanejohan closed 4 weeks ago

skanejohan commented 4 months ago

Prerequisites

ImageSharp version

3.1.3

Other ImageSharp packages and versions

N/A

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

.net 8

Description

The attached (zipped) file, 126 bytes long, gives an out-of-memory error when I try to open it with the following code:

using FileStream stream = File.OpenRead("00271-imageworsener-leftshift");
SixLabors.ImageSharp.Image.Load(stream);

I believe there is a problem with the image dimensions - BmpDecoderCore.ReadImageHeaders sets this.infoHeader.Width and this.infoHeader.Height to very high values which tries to create a huge image in BmpDecoderCore.Decode().

Steps to Reproduce

See description.

Images

00271-imageworsener-leftshift.zip

JimBobSquarePants commented 4 months ago

Can you please re-upload the zip file. GitHub is showing varnish cache errors when I try to download it.

skanejohan commented 4 months ago

00271-imageworsener-leftshift.zip

skanejohan commented 4 months ago

Our testers reported this, and it turns out the file is from a test set used to test ImageMagick - https://github.com/rip1s/Fuzzing-ImageMagick

JimBobSquarePants commented 3 months ago

Thanks, I'll look at this today.