I am playing with image uploads to a website and I found out about these decompression bomb attacks that can take place when it's allowed to upload png
files (and some other). Since I am going to change the uploaded images, I want to make sure I don't become a victim of this attack. So when it comes to checking if a png
file is a bomb, can I just read the file's headers and make sure that width and height are not more than the set limit, like 4000x4000 or whatever? Is it a valid method? Or what is the better way to go?
相关问题
- How to get the background from multiple images by
- “Zero out” sensitive String data in Swift
- How to create PNG images with more than 72dpi usin
- Try to load image with Highgui.imread (OpenCV + An
- CV2 Image Error: error: (-215:Assertion failed) !s
相关文章
- Warning : HTML 1300 Navigation occured?
- Where does this quality loss on Images come from?
- How do I append metadata to an image in Matlab?
- Read 16-bit PNG image file using Python
- Converting svg to png with inkscape command line f
- Security concerns about CORS
- How do I prevent SQL injection with ColdFusion
- C# Saving huge images
Besides large width and height, decompression bombs can also have excessively large iCCP chunks, zTXt, chunks, and iTXt chunks. By default, libpng defends against those to some degree.
Your "imagemagick" tag indicates that you are you asking how to do it with ImageMagick. ImageMagick's default width and height limits are very large: "convert -list resource" says
Image width and height limits in ImageMagick come from the commandline "-limit" option, which I suppose can also be conveyed via some equivalent directive in the various ImageMagick APIs. ImageMagick inherits the limits on iCCP chunks, etc., from libpng.
Forged smaller width and height values in the IHDR chunk don't fool either libpng or ImageMagick. They just issue an "Extra compressed data" warning and skip the remainder of the IDAT data without decompressing it.