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

Try showing the source(original) image if the image options cannot be processed or vips error occured #1273

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

InnaAndreeva
Copy link

I suggest showing the original image if the program can't handle options or the vips library crashes.

@InnaAndreeva InnaAndreeva force-pushed the show-source-image-on-failure branch 2 times, most recently from ba72408 to 6e129dd Compare April 30, 2024 18:58
@InnaAndreeva InnaAndreeva force-pushed the show-source-image-on-failure branch from 6e129dd to d56bb48 Compare May 2, 2024 07:30
@DarthSim
Copy link
Member

DarthSim commented May 7, 2024

Hey @InnaAndreeva!

I like the idea, but the implementation should be reworked.

  1. The error structure is not the best place to store the original image URL. In the Pro version, there are more places where the image downloading flow is used, and none of them need the original URL in the error.
  2. Fallback to the original image should happen inside the processing handler. The reason is the same as in the first point.
  3. I believe that none of the downloading errors should lead to the fallback:
    • If the downloading failed because of networking errors, then the fallback will fail too.
    • If the downloading failed because of an unknown format of the image, there is not much sense in the fallback since the browser most probably won't be able to show the "image" anyway.
    • If it failed because of a security error (too big resolution or file size), then it would be incorrect to expose users to the same threats that we are protecting imgproxy from.
  4. For the same reasons, I doubt that URL parsing errors should lead to the fallback. It can happen that imgproxy will send a few gigabytes of whatever non-image to the user.
  5. The fallback flow should utilize the streamOriginImage function. The current flow won't work with S3, GCS, Azure, etc. integrations. Also, it downloads the whole file into memory without checking and without need. This is a vulnerability for the same reason as above: an attacker can cause OOM by making imgproxy download a few gigabytes of unchecked data.

In fact, the only good and safe reason for the fallback I see is the failed processing. Or at least there should be separate configs for different stages of the request processing flow.

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.

None yet

2 participants