-
-
Notifications
You must be signed in to change notification settings - Fork 851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Payloads that caused a DOS attack (GIF / JPEG) #2758
Comments
Hello @ErazerBrecht, thank you for this. Upon reviewing the issues, I was unable to open the folder containing a copy of your repository on my Windows 11 machine, as File Explorer would instantly crash. It's unclear how you were able to view the output there. However, I was able to conduct an investigation on an older MacBook. Regarding the GIF issue, I have opened a pull request which has been successfully tested against your image. It's important to note that your test code has a memory leak due to not disposing of images after allocation. For the JPEG issue, the The increase in JPEG encoded output size is to be expected. The images provided have been modified to specify large dimensions, such as 59787x511 pixels. These dimensions are taken from the jpeg header, and we attempt to decode to a buffer that matches these dimensions. Consequently, when encoding, we are working with a pixel buffer that reflects the full manipulated dimensions, resulting in the encoding of a significantly larger amount of data. |
Hey @JimBobSquarePants Yeah I can just use the file explorer on Windows 11. funnyanim.gif.zip What I mean is that if I swap this part of the code:
To this:
Than it throws the exception:
For me the exception is better since it prevents a malicious actor of uploading the file. |
Thanks for the update @ErazerBrecht I think understand what must be happening with the jpeg encoder now. You can see the progress of the PR here #2759 I've solved the GIF problem by refactoring the LZW decoder to work line by line. This limits allocations for the index buffer to 64K preventing the massive allocation you were seeing. I'll have a look at the JPEG issue in the morning. I believe my inability to view the images in your repository has something to do with my usage of the new dev drive. I can see them in my standard drive. P.S you can use the |
@ErazerBrecht I've added a fix for the |
Fixed with 3.1.5 |
Prerequisites
DEBUG
andRELEASE
modeImageSharp version
3.1.4
Other ImageSharp packages and versions
Environment (Operating system, version and so on)
Windows 11
Alpine 3.19
.NET Framework version
.NET 8
Description
Hello,
GIF
When using a certain GIF we are seeing OOM's.
When debugging this locally I allocate +- 20Gb when handling that specific payload 5 times in parallel.
Payload: https://github.com/ErazerBrecht/ImageSharp.Payloads/blob/master/ImageSharp.Payloads.Gif/funnyanim.gif
Source code: https://github.com/ErazerBrecht/ImageSharp.Payloads/blob/master/ImageSharp.Payloads.Gif/Program.cs
When changing the source code to use the 'earth.gif' it works as intended and there is no spike in memory allocation.
JPEG
We have some payloads that cause resource amplification. There are very small <1460 bytes but when using Imagesharp they result into a very big result (biggest one goes to >40Mb). This only happens when specifying a quality level in the JPG encoder.
When not using one the payloads throw on a DividebyZeroException.
Payloads
https://github.com/ErazerBrecht/ImageSharp.Payloads/blob/master/ImageSharp.Payloads.Jpeg/83.jpg
https://github.com/ErazerBrecht/ImageSharp.Payloads/blob/master/ImageSharp.Payloads.Jpeg/92.jpg
https://github.com/ErazerBrecht/ImageSharp.Payloads/blob/master/ImageSharp.Payloads.Jpeg/93.jpg
Source code: https://github.com/ErazerBrecht/ImageSharp.Payloads/blob/master/ImageSharp.Payloads.Jpeg/Program.cs
Payloads were created by: https://app.intigriti.com/profile/whatevicanhaz
Sincerely,
Brecht
Steps to Reproduce
See:
https://github.com/ErazerBrecht/ImageSharp.Payloads
Images
No response
The text was updated successfully, but these errors were encountered: