splitbrain/dokuwiki — pull request #202 by Chris--S (2013-03-19 19:26:39+00:00)
Title: Proposal for limiting the number of crop/resize versions which can be created from one image

Mitigate against DDOS attempts by requesting fetch create large numbers of resize/cropped images potentially causing very high CPU load and filling up disk space.

Currently the code includes a hard coded limit - I set it at 20. Possibly this should be an advanced config setting or a defined constant.

There is one issue with this implementation, if one page requires multiple copies of the same resized image, the first view of that page, when the image resizing takes place, may result in the second and subsequent fetch requests returning the placeholder cachefile before its replaced with an actual image. Currently, the multiple copy requests would result in all of them resizing the image, generating the same result once each.

A placeholder cache file is necessary to avoid problems with large numbers of essentially simultaneous requests and the slow image resize/crop process. I.e. the version count check happens when the version count is below the limit, but there are actually sufficient resizes in process to go above the limit.