-
Notifications
You must be signed in to change notification settings - Fork 84
Description
Hi
I’m currently working on a phased plan to implement CSP for BBC online (as we’re currently rolling out HTTPS) and have come across an issue for which I have a suggestion - an amendment to the current implementation of CSP (apologies if you’ve had this suggested previously and I missed it).
We, like many other organisations of similar type and scale, want to comprehensively monitor our output to ensure it’s doing what we intended. For us, currently, CSP has a gap in just that area – namely ensuring that the CSP policies we instate are valid and thus will be enforced by compatible user agents. We can obviously pre-test (prior to deployment) our policies but we ideally want to continuously be sure they’re valid and being implemented, otherwise they’re completely ineffective. As things stand right now, achieving this ongoing policy validity monitoring is a little tricky – we could develop some tooling to help but that’d be synthetic so potentially error prone and would require infrastructure to run which means costs and peoples time and so on. Anyway, to cut to the chase, I’d love to see an addition to CSP to instruct user agents to report an invalid policy via the existing report-uri directive, perhaps something like this (invalid) example:
Content-Security-Policy: script-src 'something-invalid';
report-invalid-policy true;
report-to csp-reporting-endpoint
Which might generate a violation report like this for the above invalid policy:
{
"csp-report":
{
"document-uri": "http://www.example.com/a/b",
"referrer": "http://www.example.co.uk/a",
"policy-errors": [
"Invalid script-src directive",
"..."
],
"original-policy": "...",
"source-file": "http://static.example.co.uk",
"status-code": 200
}
}
If report-invalid-policy defaulted to “off”, current behaviour would not be affected and thus the change would be backwards compatible.
It would be sensible to recommend that user agents only report a broken policy once per session, to avoid inundating report-uri endpoints.
I believe this change would be relatively simple, backwards compatible and would negate the need for a lot of monitoring/tooling and thus time and cost for many individuals and organisations. Hopefully others might agree? I’ve made the same suggestion to the HPKP working group as this suffers the same problem from our perspective.
Cheers
Neil