Skoči na vsebino

Content Security Policy

The Content Security Policy (CSP) is a security header meant to limit the impact of Cross-Site Scripting (XSS) vulnerabilities, by telling the browser an explicit list of the origins a page is allowed to load resources from (scripts, styles, images, fonts…). It does not replace fixing application vulnerabilities, but it reduces what an attacker can achieve once an injection succeeds.

Information

The ANSSI reference on this subject is the guide ANSSI-PA-009 v2.1 (2021, "Maîtriser les standards de sécurité côté navigateur"), already cited in Apache for general HTTP headers. Its section 5.3 is devoted entirely to implementing CSP (recommendations R13 to R20).

Warning!

This recommendation applies to the Web VPN virtual hosts of the Mediation Controller. It does not apply to hosts configured as a reverse proxy: the CSP header described in this chapter is calibrated for the interface specific to CyberElements Bastion, not for proxied third-party application content whose security needs may be entirely different.

Summary

# Recommendation Mediation Controller Edge Gateway
R53 Deployment of the CSP on Web VPN hosts
R54 Known product limitation: unsafe-inline and unsafe-eval
R55 Consistency with the headers protecting against clickjacking
R56 Collection of CSP violation reports (optional)

R53. Deployment of the CSP on Web VPN hosts

Applies to: Mediation Controller · Edge Gateway

Add the following directive at the end of the file /etc/ipdiva/httpd/commonParameters.extra.conf:

1
Header set Content-Security-Policy "default-src 'self' ipdiva: ; img-src 'self' data: ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ; style-src 'self' 'unsafe-inline' ; font-src 'self' ; frame-ancestors 'self' ; base-uri 'self' ; worker-src blob: ; media-src 'self' blob: ;"
1
systemctl reload apache2

This policy relies on an explicit allow list rather than on a wildcard (in line with ANSSI-PA-009, R13 and R16): default-src restricts by default to the portal's own origin and to the ipdiva: scheme, with targeted exceptions per resource type rather than a blanket opening.

It is declared through the dedicated HTTP header rather than through a <meta> tag, which matches the implementation recommended by the ANSSI (R14) and makes it possible, among other things, to consider collecting violation reports later (R56).

R54. Known product limitation: unsafe-inline and unsafe-eval

Applies to: Mediation Controller · Edge Gateway

The script-src directive of the policy above contains the keywords 'unsafe-inline' and 'unsafe-eval'.

Warning!

Known limitation of the current version of CyberElements Bastion: the portal's web interface relies on JavaScript and CSS executed inline and on functions that evaluate code at run time. Removing 'unsafe-inline' or 'unsafe-eval' from the policy breaks the portal as the product currently stands. This point is documented here as a known and tracked limitation, to be reassessed at a future evolution of the CyberElements Bastion frontend, not as an oversight or a configuration slip.

Information

The data: keyword in the img-src directive is a different and markedly less sensitive matter: it allows images encoded directly in the page (data URI) to be displayed, a common and low-risk usage, unrelated to the code execution targeted by 'unsafe-inline' and 'unsafe-eval' in script-src. The ANSSI advises against it as a matter of principle (R15), but its real security impact in this specific context is marginal compared with the two previous keywords.

Once this limitation is lifted by a product evolution, the path recommended by the ANSSI (R15, information on transition mechanisms) is to replace 'unsafe-inline' with hashes or nonces associated with each legitimate script or style, rather than lifting the exception wholesale with no alternative.

R55. Consistency with the headers protecting against clickjacking

Applies to: Mediation Controller · Edge Gateway

The frame-ancestors 'self' directive of the CSP policy and the X-Frame-Options: SAMEORIGIN header already set in Apache both protect against clickjacking, through different mechanisms.

Information

The ANSSI (PA-009, R17 and R18) recommends implementing both together, as defence in depth: frame-ancestors is the modern mechanism, but X-Frame-Options remains useful for cases where CSP would not be applied or would be misinterpreted. No further action is needed here: the two headers are already consistent with each other (self scope in both cases).

R56. Collection of CSP violation reports (optional)

Applies to: Mediation Controller · Edge Gateway

CSP makes it possible to define a collection URL to which the browser sends a report every time a resource is blocked for failing to comply with the policy. This mechanism helps detect attempted XSS exploitation or, more simply, legitimate resources blocked in error, without waiting for a user to report a malfunction.

1
Header set Content-Security-Policy "...; report-uri https://<collector>/csp-reports ;"

Warning!

The ANSSI (PA-009, R19) invites you to assess the risk before enabling this feature rather than enabling it by default: a CSP report may reveal information about a vulnerability currently being exploited, the collection point is itself a new exposure surface to secure, and its authenticity cannot be guaranteed. This recommendation is therefore classified as optional and to be validated: it assumes a dedicated collection point, separate from the portal itself, and requires deciding who exploits those reports before enabling it.

A gradual roll-out, without blocking, is possible through the Content-Security-Policy-Report-Only header in place of Content-Security-Policy: violations are reported but no resource is blocked.

Classification

To be validated (optional): Collection of CSP violation reports. See the Classification of recommendations appendix.