-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent CSP reports being sent if I handle the SecurityPolicyViolation event. #255
Comments
@andypaicu, I am sure, will be thrilled beyond words to look into what we'd have to do to make this work. I suspect it shouldn't be terribly difficult? |
/cc @ckerschb, who's poking at this in Firefox. |
Even if you can not block it, it would be really great if you can inform the client that there was something blocked. There should be an event called "securitypolicyviolation" but i did not get this to work with thunderbird nigthly. |
That sounds reasonable to me. It shouldn't be hard to put something in place to block the report before going out if the event is handled in the browser. Let us first get SecurityPolicyViolation events into Firefox :-) FWIW, SecurityPolicyViolation Events should be available for FF59, see https://bugzilla.mozilla.org/show_bug.cgi?id=1037335 |
With SecurityPolicyViolation events in place, the |
Or instead don't use CSP's built-in reporting, and then use the violation events to send your own filtered reports. |
I'd prefer the |
Making the @andypaicu, you up for doing that work? |
Having a cancellable |
@koto Nothing in particular, just lack of bandwith. |
To prevent the security reports from being sent, you can leave out the report-uri and report-to directives. The securitypolicyviolation event will still fire, even if it's a report-only policy. Then you can listen to securitypolicyviolation events on the client side and post your own reports conditionally with the information from the securitypolicyviolation event. |
@Elisheva-Jacobson True, though that script would be subject to the CSP restrictions, right? So it may not be able to communicate with the reporting service. |
That script would still be subject to the csp restrictions, but there's no reason that it should not be able to communicate with the reporting service, unless you make it inline or load it from a third-party domain. |
I'm trying to deal with this to support the (IMHO) broken behavior of Firefox documented in https://bugzilla.mozilla.org/show_bug.cgi?id=1459872. Note this is an open bug filed 7 years ago. I have several SVG animations that trigger this violation, and this overwhelms my CSP reports (because every animation frame generates the event multiple times). I can eliminate most of this by:
Where testanimate is an SVG element to which an animation is attached. |
This is a kludge, but may be a useful kludge. In the splash page, I have:
In my cspreport controller, I have:
In my CSP header:
Firefox reports the cause of (some) violated directives if they are annotated with 'report-sample'. This results in the fill color applied by the filter to show up in the 'script-sample' field of the CSP report. I'm willing to take a chance on some bad actor jacking my site and making it all PapayaWhip, so I suppress this. |
I'd like to be able to intercept CSP reports and process/handle them on the client side prior to sending.
CSP reporting is very noisy and right now looking at real numbers from https://report-uri.io a significant quantity of reports are discarded by filters at our edge. Depending on the exact filters configured by the user it can quite reasonably be 40%-80% of reports discarded.
The ability to handle these client side by applying filtering to prevent them being sent would be a significant advantage. Reducing noise improves the usefulness of CSP reports and not sending them saves network activity on the client. This would make it easier for hosts to deploy reporting.
The text was updated successfully, but these errors were encountered: