Bug 171566

Summary: crossorigin="anonymous" resource loads are anonymous even for same-origin
Product: WebKit Reporter: Patrick Toomey <ptoomey3>
Component: Page LoadingAssignee: Daniel Bates <dbates>
Status: NEW ---    
Severity: Normal CC: achristensen, beidson, buildbot, cdumez, dbates, dpaddock, japhet, kj.kim, ljharb, ptoomey3, sean, webkit-bug-importer, wilander, youennf, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=171550
Attachments:
Description Flags
Patch none

Description Patrick Toomey 2017-05-02 13:37:48 PDT
A group of colleagues of mine noticed that a session cookie was not being sent with a script request that looked something like this:


<script src="./anonymous.js" crossorigin="anonymous"></script>


It looks as though Safari treats any resource request with the crossorigin="anonymous" attribute as anonymous. But, this is only meant to apply for cross-origin requests. I setup a temporary PoC test page (the contents can be seen below) that can be viewed on Heroku (https://infinite-bayou-16019.herokuapp.com). The two endpoints reflect back a JS response based on whether a cookie is sent along with the JS fetch. Chrome and Firefox send cookies for both fetches, while Safari only sends it on the non-anonymous fetch. 


  <html>
    <head>
      <script src="./non_anonymous.js"></script>
      <script src="./anonymous.js" crossorigin="anonymous"></script>
    </head>
    <body>
      <h1>Echo some cookies!</h1>
    </body>
  </html>
Comment 1 youenn fablet 2017-05-03 17:21:16 PDT
Thanks for filing this bug.
We should set credential mode to same-origin in that case, which I believe would do what you are suggesting.
Will try to look at it further.

Are you seeing that for other resource types?
Comment 2 youenn fablet 2017-05-03 22:04:41 PDT
Created attachment 309016 [details]
Patch
Comment 3 Radar WebKit Bug Importer 2018-05-01 10:11:52 PDT
<rdar://problem/39869363>