With a fully encrypted website not only a heavy SEO and trust benefit is gained. In addition a website can be monitored against fraudulent or even malicious content. Whilst, this solution does not provide any protection, turning all website visitors into an active radar enables a website owner to get aware of CSP-Violations at the moment's notice.
A in browser security system to prevent attacks like XSS (Cross Site Scripting) or others like implementing malware. It's major purpose is to whitelist assets such as images, JavaScript, CSS, fonts etc. to being loaded from desired domains. In addition certain obvious functions like eval, inlining or data can be stopped from being executed too.
Check out the following resources if this topic is new:
- CSP Quick Reference Guide
- Content Security Policy in Wikipedia
- CSP on Google's Web Fundamentals
- OWASP CSP Wiki
- CSP Policy Generator from Report URI
- SP Policy Generator from CSP is awesome
- CSP Validator
- CSP Validator from Google
- Upon a browser (a real end user) recognizes a CSP violation, it automatically sends an XHR to the report URI defined in the CSP-Response Header
- The file, if found and access rights are correct, receives it
- Cookies are processed to extract the Google Analytics UA-ID
- If no UA-ID was found a fallback ID (must been defined) is used
- Extract requesting domain from URI (Note: Could be used for switch/case lookup of UA-ID)
- Generate and send Google Analytics event
- Send email for immediate notifications with CSP-Violation
- Write CSP-Violation into local log
- Immediately getting aware of violations against Content Security Policy
- Analyzing impact of blocked content on the customer experience
- Remain informed on a multiple author website if some implement insecure content
- Prevent injections i.e. from browser plugins which slow down your website
Blocked-uri: https://data1.routenplaner-karten.com Violated-directive: script-src https://timbrado.de data: 'unsafe-inline' 'unsafe-eval' https://*.timbrado.de https://*.google-analytics.com https://*.googletagmanager.com https://*.google.com https://*.googleapis.com https://*.gstatic.com https://*.jquery.com https://*.videopress.com*
More example with good exmplanations by nico3333fr/CSP-useful
CSP definition for Nginx which leverages $server_name
- A fully encrypted website
- FTP-Access to website
- CSP-response headers been send
Note: Upon first implementing a CSP I highly recommend to set CSP-Response headers to report only!
- Save csp-report-file.php into website root
- Modify sender and recipient address as well as the Google Analytics ID
Note: If the PHP-file is not saved in the root directory adjust the Report-URI in the CSP-Header accordingly!
Forcibly violate a CSP-Policy by i.e. integrating an iframe form YouTube.
0.1 Initialization
- Setting up centralized logging
- Send an event to each recognized Google Analytics Property by creating a loop
Mike Wiegand - atMedia Online Marketing
See also the list of Acknowledgments where their work greatly contributed to this project.
This project is licensed under the MIT License - see the LICENSE.md file for details