Skip to content
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

Can't navigate on pages with a Content-Security-Policy response header. #146

Open
duhrer opened this issue Jan 10, 2024 · 6 comments
Open
Labels
bug Something isn't working

Comments

@duhrer
Copy link
Contributor

duhrer commented Jan 10, 2024

On Chrome Web Store pages such as our own listing, the extension isn't injected, so we can't control the page. We need to figure out what the limits are here and exclude additional sites using our filterControllableTabs method.

If we can find documentation on the fact that extensions don't work in the Chrome Web Store, that would be a good start.

We should also see if variants (Brave, Edge, etc.) have their own storefronts with their own issues.

@duhrer duhrer added the bug Something isn't working label Jan 10, 2024
@duhrer
Copy link
Contributor Author

duhrer commented Jan 10, 2024

I can't see that any other extension content is injected there, for now I've added a check to count web store pages as "uncontrollable" to avoid navigating there.

@duhrer
Copy link
Contributor Author

duhrer commented Jan 10, 2024

Brave uses the Chrome Web Store. Opera has its own site, which also appears to not allow extensions.

Edge has its own site, the extension doesn't work for the extension-related parts, but does work on other parts of the same site. I'm looking at the response headers for a clue about how/why a site indicates that extensions aren't allowed.

@duhrer
Copy link
Contributor Author

duhrer commented Jan 10, 2024

Turns out all of these pages have a Content-Security-Policy response header that disallows injecting code. In hindsight, this also explains why we can't control browser internal pages, which also return this request header.

I can see that there ways of bypassing this, as outlined in this stackoverflow post. In short, we can add rules to rewrite the headers and either strip the CSP headers or (hopefully) add rules that allow our code to run.

IMO we should not strip CSP headers, but I would be less concerned about adding our code to the headers for sites that have a restrictive policy, as the benefits are fairly high. Suddenly even browser internals like settings would be navigable.

This should be tested in detail on a side branch and reviewed as its own thing.

@duhrer duhrer changed the title Can't navigate on Chrome Web Store pages. Can't navigate on pages with a Content-Security-Policy response header. Jan 10, 2024
@duhrer
Copy link
Contributor Author

duhrer commented Jan 10, 2024

Looking at the declarativeNetRequest documentation, they allow setting and removing headers, but not appending them (which is what I'd have preferred).

My best guess is that we would have to remove the existing headers and ideally replace them with the defaults plus ourselves.

I'd like to try making the permissions optional if possible, once we get anything working, that's something to try.

@duhrer
Copy link
Contributor Author

duhrer commented Jan 10, 2024

On a hunch, I confirmed that the built-in "new tab" also has a Content-Security-Policy header. This explains so much.

@duhrer
Copy link
Contributor Author

duhrer commented Jan 11, 2024

I tried a bunch of things, and was finally at least able to modify some headers some of the time, but was never able to consistently confirm that my ruleset was being applied to relevant traffic when loading the chrome web store.

Even on pages where I could see that the ruleset was being applied, there was no change in behaviour. However, it's hard to say what's happening. I can see that the plugin is manipulating request headers, but don't see any change in the response headers. This is the same behaviour I see when trying every one of the example extensions I found.

It may be that there is an effect, which the developer console isn't showing me. It may also be that there's no effect because I need to get more specific about which hosts I care about. It may also be that there's no effect because they intentionally make it next to impossible to change CSP headers.

I'm going to hold off on this for now until I encounter something that makes me think there's a hope of getting this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant