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

Fix DoS thumbnail generation exploit #777

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

Conversation

glubsy
Copy link

@glubsy glubsy commented Jan 25, 2021

This fixes a denial-of-service exploit that would allow the client to generate an infinite number of thumbnails and fill up the hard disk storage completely very quickly.
Since the client had control over the requested thumbnail sizes, it could make arbitrary requests for thumbnails, with an arbitrary combination of width x height. Every time the back-end did not find an already generated thumbnail with the specified dimensions, it would happily generate a new one.

  • Remove the ability of the client to decide thumbnail dimensions and only let the back-end do this by reading the configuration.
  • Limit the number of generated thumbnails per file to only one, with "landscape" dimensions (4/3). This drastically reduces the amount of disk space used for thumbnails.
  • A CSS "object-fit" property can be used to adjust displaying landscape thumbnails as squares when necessary. See https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit for more details.

* This fixes a denial-of-service exploit that would allow the client to
generate an infinite number of thumbnails and fill up the storage completely.
Since the client had control over the requested thumbnail sizes, it could make arbitrary requests for thumbnails, and every time the backend did not find an already generated thumbnail with the specified sizes, it would happily generate a new one.
* Remove the ability of the client to decide thumbnail dimensions and
only let the back-end do this by reading the configuration.
* Limit the number of generated thumbnails per file to only one, with
"landscape" dimensions (4/3).
* Use CSS "object-fit" property to adjust displaying of landscape thumbnails into squares. Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
* We now use only one thumbnail file src for both square and rational
thumbnails so remove superfluous requests.
* Set the same src for both square and landscape dom classes.
Only compute thumbnail configured dimensions on thumbnail API requests.
* Down-sampling should only be requested by the backend.
* For now remove the client-side logic entirely since it is both
superfluous and vulnerable. This can be implemented again on the
back-end if necessary.
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.

1 participant