Rule n° 212 - A security mechanism restricts the origin of content.
The server sends a page containing various elements (JavaScript files, CSS, webfonts, etc.) to the browser, which will download and display everything as quickly and efficiently as possible... without questioning the legitimacy of what it is doing. The system called Content Security Policy allows the browser to indicate rules regarding the origin of this content. This makes it possible to determine exactly what it is allowed to execute or display, and thus increases security for users.
Goal
- Reduce the risk of executing or serving content that is undesirable or that comes from an unauthorized source.
Solution technique
Enable the Content-Security-Policy HTTP header with the appropriate CSP 1 directives:
- img-src for images ;
- script-src for JavaScript ;
- style-src for styles ;
- font-src for webfonts ;
- etc.
Moyen de contrôle
Use an HTTP header inspection tool to check for the presence of the Content-Security-Policy header.