-
-
Notifications
You must be signed in to change notification settings - Fork 98
Description
One of the warning messages produced by a ZAP run against 127.0.0.1 is that the "Content Security Policy (CSP) Header not set"
See #318
One way to set the CSP headers is to insert something like the following into src/moin/apps/frontend/views.py:
@frontend.after_request
def add_security_headers(resp):
resp.headers["Reporting-Endpoints"] = "csp-endpoint='http://127.0.0.1:5000/csp-report-url'"
resp.headers["Content-Security-Policy-Report-Only"] = "default-src http:; report-uri csp-report-url; report-to csp-endpoint;"
return resp
where the above needs work, pretty names, move headers to wikiconfig.py, do same/similar for admin views etc.
The first problem encountered from above is the browser tries to PUT a jason formatted report to csp-report-url resulting in a 404.
Adding a text item named csp-report-url eliminates the 404 and returns a 200, but the write fails silently in moin code with nothing updated. The silent failure is possible due to the contenttype of the browser post is application/csp-report
.
See
https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html,
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only,
google other sources