If you are allowing untrusted users to upload files, you need to ensure you are using this plugin or something like it. WordPress by and large does not validate files; it merely checks to see that the filename contains an extension the site has chosen to allow. A file name is completely arbitrary, so there is nothing to stop someone from renaming malicious.swf
to happy.jpg
.
That said, if you are only focusing on images, and only focusing on “normal” image types like JPEG and GIF, name-based trickery will be largely mooted by the thumbnail generation processes; GD or ImageMagick will be unable to detect and process a (fake) image, resulting in failure. But if you allow other types of images, like SVG, WebP, JPEG2000, etc., this won’t apply.
In terms of overhead, file validation is a very small fraction of the overall script execution, and an even smaller fraction of the resources required by the server to process the request. If you have already tweaked your server environment to handle 10,000+ simultaneous uploads, this plugin will just be a drop in the ocean.
This plugin hooks into the wp_check_filetype_and_ext
filter, which is triggered each time a new file is uploaded to WordPress (after the file is uploaded, before the file is permanently saved).
For SVG files (if SVG files have been whitelisted; they aren’t by default), the entire file is read into memory, parsed, sanitized, and re-saved. This brings with it a lot of overhead relative to doing nothing, but since the SVG format is so inherently dangerous, it can’t really be avoided.
For all other files, this plugin runs checks similar to those WordPress performs on its own, but applies them to more file types, and checks the results against a comprehensive database of MIME type aliases to help mitigate server-side inconsistencies and ensure that files that are allowed are allowed, and files that aren’t aren’t. In terms of overhead, this roughly doubles the amount of time WordPress spends validating a file, but again, validation is just a tiny fraction of the overall execution time.