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

Resource limits for RAM, dimensions, and CPU time #411

Open
carbotaniuman opened this issue Jul 7, 2021 · 2 comments
Open

Resource limits for RAM, dimensions, and CPU time #411

carbotaniuman opened this issue Jul 7, 2021 · 2 comments
Labels
T-Feature Requests for a new feature to be added

Comments

@carbotaniuman
Copy link
Contributor

carbotaniuman commented Jul 7, 2021

I use oxipng to process untrusted files from uploaded users, and we currently rely on pod level resource limits in order to protect against PNG bombs. Is it possible for there to be resource limits by oxipng itself, ala ImageMagick? I'd be happy to contribute these changes to the project, but I'm not really sure where to start looking.

@shssoichiro
Copy link
Owner

Since Rust doesn't run within a VM (ala Java), I don't think there's a way to set explicit memory limits, but there could be options added to limit the width and height. There is an existing CLI option, --timeout, which will limit the wall time oxipng will spend on a file.

I'm reading that these attacks can also happen through excessively large iCCP chunks, zTXt chunks, and iTXt chunks, so ensuring oxipng protects against these (by default) would be a good addition as well.

@andrews05 andrews05 added the T-Feature Requests for a new feature to be added label Oct 10, 2023
@Winterhuman
Copy link
Contributor

Winterhuman commented Oct 25, 2023

For anyone looking for a temporary workaround, you can use systemd-run to do resource limiting, e.g.

systemd-run --user --wait -Pp MemoryHigh=5% oxipng input.png output.png

You can set -p MemoryMax=10% as well if you want the transient service to exit if its memory usage creeps too high (MemoryHigh is only a soft cap, and oxipng's memory use does tend to increase the longer it runs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Feature Requests for a new feature to be added
Projects
None yet
Development

No branches or pull requests

4 participants