Your website is vulnerable to being tricked into executing uploaded malcious code because the SECURE_CONTENT_TYPE_NOSNIFF
setting is not set.
SecurityMiddleware
sets the X-Content-Type-Options
header to nosniff when SECURE_CONTENT_TYPE_NOSNIFF = True
to prevent hackers from tricking your website into executing a malicious javascript file that they uploaded via one of your forms.
This header indicates to the browser that the MIME types advertised in the Content-Type headers should not be changed (by "sniffing" the content).
The sniffing feature is the browser being helpful when a developer or server misconfiguration misidentified the Content-Type. If the browser respected an incorrect MIME type then a javascript, css, or image file would not work and the website would break. Very helpful feature. But it can be abused:
By setting SECURE_CONTENT_TYPE_NOSNIFF = True
, the browser will not infer the MIME type if the Content-Type is not set, closing this security hole.
If our GitHub code review bot spots this issue in your pull request it gives this advice:
1 | + | SECURE_CONTENT_TYPE_NOSNIFF = False |
Your website is vulnerable to being tricked into executing uploaded malcious code because the SECURE_CONTENT_TYPE_NOSNIFF
setting is not set.
- | SECURE_CONTENT_TYPE_NOSNIFF = False |
+ | SECURE_CONTENT_TYPE_NOSNIFF = True |