Bug 228019 - SecurityPolicyViolationEvent contains wrong/incomplete values
Summary: SecurityPolicyViolationEvent contains wrong/incomplete values
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 14
Hardware: Unspecified iOS 14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-07-16 02:05 PDT by milankeser
Modified: 2021-07-22 16:34 PDT (History)
6 users (show)

See Also:


Attachments
Comparison between safari and chrome (920.88 KB, image/png)
2021-07-16 02:05 PDT, milankeser
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description milankeser 2021-07-16 02:05:06 PDT
Created attachment 433665 [details]
Comparison between safari and chrome

SecurityPolicyViolationEvent when fired contains incomplete/wrong fields.

How to reproduce:

 1. define csp rules `connect-src` to something that will block xhrs
 2. trigger an post xhr to some endpoint, for example `https://reqbin.com/echo/post/json`
 
Observe the securitypolicyviolation event. Blocked url contains only hostname without the path
I will post a screenshot with an scenario that I have

On the left side is safari, and on the right side is chrome.
If we check the blockedURI property we can see that chrome has correct value and on safari only hostname is added. Please note that `/bf` is missing on safari for `blockedURI` + query string.
Also safari seems like it assigned that value to the documentURI but the document url where it happened was on `my localhost IP address` and not on url where xhr was sent.
Additionally documentURI seems like is randomly correct as it sometimes has the right value and sometimes has the value that should be `blockedURI`.

I am doing some comparisons to filter out the xhrs I am sending from these violations ( I am gathering some analytics ) and with incomplete `blockedURI` value I am not able as it can match any xhr if it is sent to a URL relative to the hostname.

Firefox has the correct values all the time also.
I tested this on SAFARI 14, SAFARI 13 and it seems like it happens also on apple mail application.
Comment 1 Smoley 2021-07-22 16:34:12 PDT
Thanks for filing, I tried to take a look at your example page but I'm hitting a 404 error. Is there a better link to try?
Comment 2 Radar WebKit Bug Importer 2021-07-22 16:34:23 PDT
<rdar://problem/80989579>