Skip to content
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

Issue with DecompressionBombWarning with high pixel images #1425

Closed
vinitkumar opened this issue Sep 22, 2023 · 1 comment · Fixed by #1426
Closed

Issue with DecompressionBombWarning with high pixel images #1425

vinitkumar opened this issue Sep 22, 2023 · 1 comment · Fixed by #1426

Comments

@vinitkumar
Copy link
Member

Filer allows for images to be uploaded to the storages. There is a setting where we can limit the size of the image. However, there is no way to prevent DecompressionBombWarning that can happen when you have added a high pixel image which Pillow can't handle.

In that case you end up with errors like this

/usr/local/lib/python3.9/site-packages/PIL/Image.py:3074: DecompressionBombWarning: Image size (94570638 pixels) exceeds limit of 89478485 pixels, could be decompression bomb DOS attack.

I believe, we should make use of the check for max allowed Pixel from Pillow and give a validation error before uploading such images as I have experience downtime in website because filer allowed such high pixel images to be uploaded and then crash the page as pillow can't handle it. Even the filers own thumb-nailing won't succeed because of this issue as it can' handle such files. I believe it is a real issue and filer is the correct place to solve this.

@fsbraun
Copy link
Member

fsbraun commented Sep 22, 2023

See also #1330.

vinitkumar pushed a commit that referenced this issue Sep 24, 2023
Filer allowed for the images for very high pixels (height * width) to be
uploaded. This would cause crash and failures when the high pixels
exceeded what is allowed by Pillow Image MAX_IMAGE_PIXELS value.

This is an issue because even though the image is possible to be created
and attached to the page, it would never work as PIL always fails to
thumbnails such high pixel image and crashes causing crash and high
memory usages in such pages.

This patch, fixes this issues in the bud as it wouldn't allow such files
to be uploaded via FILER itself. It also allows to set a lower limit
FILER_MAX_IMAGE_PIXELS so that users can limit the max pixels to value
much lower than what PIL support.

- Github Issue
    - #1425
    - #1330

Authored-by: Vinit Kumar <vinit.kumar@kidskonnect.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants