For web frontends accepting files from users
The most concerning attack vectors available to bad actors are Filename, Metadata, and Content. And the most common attack is typically a cross-site-script (XSS).
To defend against XSS and other malicious intent, we should always ensure the following:
POST
to a backend).accept
attribute on your <input>
elements in order to explicitly specify which MIME types may be uploaded.Regarding the file Content, our options for thwarting bad actors are more limited and will depend on the accepted MIME types and the general purpose of the upload. One important point to be aware of is that image
files are more high-risk given the fact that they can embed scripts.