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

How to avoid image-resize attacks from side requests ? #330

Open
Awilum opened this issue Sep 1, 2021 · 2 comments
Open

How to avoid image-resize attacks from side requests ? #330

Awilum opened this issue Sep 1, 2021 · 2 comments

Comments

@Awilum
Copy link

Awilum commented Sep 1, 2021

Hello!

I am using Glide in my Images service to manipulate images from side resources via Rest API https://flextype.org/documentation/rest-api/images
like it is https://imgix.com.

I see this example here https://glide.thephpleague.com/2.0/simple-example/

<img src="/img/users/<?=$user->id?>.jpg?w=300&h=400&fit=crop">

and it is fine to build urls in this way,

but then I read this: https://glide.thephpleague.com/2.0/config/security/
it's saying that it is not secure and we should use signatures and build URLs with help of UrlBuilderFactory.

GET /api/images/{path:.+}?VALID_ARGUMENTS&token=YOUR_IMAGES_TOKEN

I know know my YOUR_IMAGES_TOKEN but image signature is unique per each request.

And even on the current server I can't create request to the API by typing url with arguments, because it requires signature for security reason.

on https://imgix.com example, I don't see signatures (or I am wrong), how do they protect server from image-resize attacks ? any ideas ?

Is there some simple way to make secure requests without UrlBuilderFactory?
Is it possible to get signatures out of the server somehow in simple way?
Or maybe there is any other ways to protect server from image-resize attacks ?

@Art4
Copy link

Art4 commented Sep 2, 2021

We had the same problem. We solved it by defining ~10 presets and ignoring all other options in query string.

@Awilum
Copy link
Author

Awilum commented Sep 7, 2021

I start thinking about: Is it right to do all this image processing on the fly with such a nice tool (on first look) like GLIDE and Intervention (under the hood)?

If we will have a few or 10 or 100 or even more images on the page, then we will need to run all this images processing stuff for each image (especially when the cache is cold) - and it is painful for the server. The server will just go down.

I think that we should not do this processing for each image, and especially on the same server where site is running.

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

No branches or pull requests

2 participants