Add decompression size limit to FITS gzip decoder#9475
Closed
myagmartseren wants to merge 1 commit intopython-pillow:mainfrom
Closed
Add decompression size limit to FITS gzip decoder#9475myagmartseren wants to merge 1 commit intopython-pillow:mainfrom
myagmartseren wants to merge 1 commit intopython-pillow:mainfrom
Conversation
gzip.decompress() was called without any size limit, allowing a crafted FITS file with a gzip bomb to cause unbounded memory allocation (OOM/DoS). Add a limit based on the expected image dimensions, similar to MAX_TEXT_CHUNK in the PNG decoder. Security: CWE-409 (Decompression Bomb)
|
Thanks, please note our security policy: https://github.com/python-pillow/Pillow/blob/main/.github/SECURITY.md I don't think the fix does what you expect it to do, as you're checking for the length of the data after decompression. |
Member
|
Thanks for the thought. I agree that this doesn't fix the problem. I'm reluctant to discuss security problems in public, but I expect that in a week or two, we will create a variation on this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Decompression Bomb in FITS Gzip Decoder (DoS)
Summary
FitsGzipDecoder.decode()callsgzip.decompress(self.fd.read())with no size limit. A crafted FITS file containing a gzip bomb (~100 KB) can decompress to gigabytes, causing OOM / denial of service.Affected Code
src/PIL/FitsImagePlugin.py, line 131:Impact
MAX_TEXT_CHUNK) and general images (has_decompression_bomb_check), FITS gzip has zero protectionFix
Add a decompression size limit based on expected image dimensions:
Classification
AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H