Skip to content

Conversation

@RunDevelopment
Copy link
Contributor

resolves #1746

While investigating #1746, I was unable to reproduce any of the OOM, so I suspect that some safety mechanism in PNG defeated the malicious inputs.

However, I went one step further to ensure that similar inputs can't allocate excessive amounts of memory. Since the size of the PNG is known beforehand, I used PNGs with_limits constructor to pass in size and memory limits specific to the icon being decoded. For the memory limit, I used double the maximum uncompressed image size (512KiB). Assuming that PNG implements limits correctly, PNG OOM should never be an issue for ICO again.

Copy link
Member

@197g 197g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. We'll mostly use those as default limits. Restricting the png to the dimensions indicated in the ICO is neat for this version. I expect that #2672 will touch this in the rework (it already adds an implementation of ImageDecoder::set_limits to dispatch) but it won't hurt to start from a sane default.

@197g 197g merged commit 22ea722 into image-rs:main Dec 1, 2025
32 checks passed
@RunDevelopment RunDevelopment deleted the prevent-ico-oom-png branch December 4, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OOM in ICO decoding (found by fuzzer)

2 participants