How does CSP improve security?
When CSP is set up and running, only whitelisted content will be ran by the User’s Browsers anything that is not on the CSP list will be refused.
This will result in an CSP Error in the console such as:
So, in the event a Magento Admin panel is compromised and a malicious user uploads an unwanted script, if CSP is set up correctly, the browser should refuse to load the content. This provides an extra layer of security and helps protects users.
Cross-site scripting (XSS) and related attacks, including as card skimmers, session hijacking, clickjacking, and more, can be prevented with a correctly set up CSP.
CSPs and built-in browser capabilities, in summary, help to prevent:
- Loading a malicious script from an attacker’s website
- A malicious inline script from sending credit card info to an attacker’s website
- Loading a malicious style that will make users click on an element that wasn’t supposed to be on a page