benji.monster/node_modules/dont-sniff-mimetype
2020-01-03 21:48:09 +01:00
..
dist upload site 2020-01-03 21:48:09 +01:00
CHANGELOG.md upload site 2020-01-03 21:48:09 +01:00
LICENSE upload site 2020-01-03 21:48:09 +01:00
package.json upload site 2020-01-03 21:48:09 +01:00
README.md upload site 2020-01-03 21:48:09 +01:00

"Don't infer the MIME type" middleware

Build Status

Some browsers will try to "sniff" mimetypes. For example, if my server serves file.txt with a text/plain content-type, some browsers can still run that file with <script src="file.txt"></script>. Many browsers will allow file.js to be run even if the content-type isn't for JavaScript.

Browsers' same-origin policies generally prevent remote resources from being loaded dangerously, but vulnerabilities in web browsers can cause this to be abused. Some browsers, like Chrome, will further isolate memory if the X-Content-Type-Options header is seen.

There are some other vulnerabilities, too.

This middleware prevents Chrome, Opera 13+, IE 8+ and Firefox 50+ from doing this sniffing. The following example sets the X-Content-Type-Options header to its only option, nosniff:

const nosniff = require('dont-sniff-mimetype')
app.use(nosniff())

MSDN has a good description of how browsers behave when this header is sent.