Send X-Content-Type-Options nosniff on WordPress
Why it matters
Without it, browsers may guess a file's type from its content, so an uploaded file that looks like a script or page can be run as one. The header makes them trust the declared Content-Type.
The fix
- Set it at the CDN or server (see their tabs), with a maintained security-headers plugin, or with the must-use plugin below.
- The must-use plugin covers pages WordPress renders through PHP, not uploads and other static files, which the web server serves directly; set it at the server to cover those.
wp-content/ mu-plugins/ nosniff.php
<?php /* * Plugin Name: nosniff */ add_action( 'send_headers', function () { header( 'X-Content-Type-Options: nosniff' ); } );
Related
Scan your domain to see whether this applies to you.