fix: add X-Content-Type-Options nosniff header to nginx config#40679
fix: add X-Content-Type-Options nosniff header to nginx config#40679lbajsarowicz wants to merge 1 commit intomagento:2.4-developfrom
Conversation
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
Description
Add the
X-Content-Type-Options: nosniffsecurity header alongside the existingX-Frame-Optionsheader in all applicable location blocks innginx.conf.sample.Problem
The sample Nginx configuration sets
X-Frame-Options: SAMEORIGINin multiple location blocks to prevent clickjacking, but does not setX-Content-Type-Options: nosniff. Without this header, browsers may perform MIME type sniffing on responses, potentially interpreting files as a different content type than declared.This can lead to security issues such as:
/media/Solution
Add
add_header X-Content-Type-Options "nosniff";in every location block that already setsX-Frame-Options, including:/setup/pub/and/update/pub/(admin setup/update assets)/pub/(public assets)/static/(versioned static assets, compressed files, fallback)/media/(media assets, compressed files, fallback)This follows the same pattern used for
X-Frame-Options— applied per-location rather than globally, matching Nginx'sadd_headerinheritance behavior (child blocks don't inherit parentadd_headerdirectives).References
Files Changed
nginx.conf.sample⭐ Support my work
Do you like the fix? Remember to react with "👍🏻" to get it merged faster,
Then Sponsor me on Github so I can spend more time on fixing issues like this one.
Learn more at https://github.com/sponsors/lbajsarowicz