da2x / save-data

WebExtension for sending the Save-Data: on HTTP request header.
https://www.daniel.priv.no/web-extensions/save-data
GNU General Public License v3.0
21 stars 4 forks source link

Breaks cross-origin requests when logged in on SoundCloud.com #5

Closed BinToss closed 2 years ago

BinToss commented 3 years ago

Disabled

image Clipboard01 webp

Enabled

image image

Networking Errors

image image image

BinToss commented 3 years ago

This seems to be due to a modification of the requests' Referrer Policy. Manually resent requests use the "unsafe-url" policy while blocked requests use the "origin" Referrer Policy. image

da2x commented 3 years ago

The extension doesn’t touch any of these headers.

Here’s all the header modifications it does: https://github.com/da2x/save-data/blob/d02ccfbfb1ff311c97b9a3d88f0d768bf1b6ee22/background.js#L27-L30

The server in question may modify what it sends back based on the presence of the header. (Which is kind of the point.) Does the problem reproduce with Chrome on Android set in data saver mode? It sends the same header as the extension.

BinToss commented 3 years ago

So, I can't actually test that with the latest Chrome for Android. It seems Data Saver was replaced with the Lite mode setting which essentially uses a Google-hosted proxy server to compress data.

da2x commented 3 years ago

Lite Mode also adds the Save-Data: on header.

BinToss commented 3 years ago

Chrome for Android with Lite mode did not experience the issue on either the desktop website or mobile website. I also tried Opera for Android with same/similar settings. No issues.

da2x commented 3 years ago

Does it also reproduce after disabling all other extensions and reloading the page?

BinToss commented 3 years ago

Yup.

I discovered now that the initial GET requests don't have headers when I'm not logged in, but they do when I am logged in. When logged in, GET requests' headers use the Origin referrer policy with an origin of https://soundcloud.com/ to request a resource from "a-v2.sndcdn.com". image

Right-clicking the failed GET request in the event log and selecting "Resend Request" changes the header to use the "unsafe-uri" referrer policy, which allows this CORS to succeed.

My findings were irrelevant. This, however, seems more relevant: image

There's still very little information to go on by inspecting the request header...

da2x commented 2 years ago

Duplicate of #6.