-
Notifications
You must be signed in to change notification settings - Fork 78
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
Allow navigation to only whitelisted URLs via navigate-to #125
Comments
The idea is certainly interesting, but I suspect it will end up by the most complex CSP directive by a country mile for browsers to implement.
I think this idea is overall great for sites that run advertisements or otherwise let users embed URLs, but I think it will be difficult to make work effectively. |
If browsers would like to do something like that, they may. As written, clicking it would end up starting a navigation, blocking the request by simulating a network error response from Fetch, thereby rendering some sort of error page. We could certainly change that to block the request by treating it as a 204 (e.g. no navigation actually takes place, and you just stay on the page you were on to begin with). I don't have a strong preference, but I think navigating to an error page is a safe default.
Whether the code continues executing depends on the navigation behavior we choose above. As written, the page would be unloaded, so the script would stop executing. If we moved to a 204-style behavior, the script would continue executing.
Yes. HTTP redirects would be blocked, as we do the check in the middle of the navigation algorithm (step 6 of https://html.spec.whatwg.org/multipage/browsers.html#process-a-navigate-fetch). That algorithm recurses on itself (in step ~9) for redirect responses, so each item in the redirect chain would be tested against the policy.
Nope. Both of these would end up with the user landing on What I've heard from anti-malvertising folks is that the expected landing page is generally safe. There are certainly cases where folks are cloaking a declared landing page's intent from the advertiser in some way, but those are the minority of cases. Bad behavior generally results from sending users somewhere else entirely (and generally doesn't wait for a user to click on anything: |
Sure, they're the minority of cases now. I suspect that should Google Adwords (or whatever advertiser) start using That's not to say that I don't think that |
I've been mulling this around in my head, and I think I have an idea that might work.
This would prevent a landing page on This would require browsers to track state across page navigations, but hopefully would go a long ways towards solving both halves of the malvertising problem. |
@marumari: Thanks! This isn't a crazy idea: I think gating navigation on user gesture is a reasonable thing for a page to ask for, and was actually on my list of things to tack onto either this or feature policy or wherever it makes sense. For my own clarity, you'd basically want to set a flag on the new page that blocked navigation, and clear it if/when a user interacted with the page (similar to the heuristics we're using for the popup blocker)? /cc @hillbrad who's been watching some user-gesture-and-navigation Chrome changes warily. |
Yep, that's exactly it! |
I see The unfortunate huge problem with I didn't understand if you would need to whitelist all possible intermediate redirection URLs or is only the landing page URL that matters? |
This user gesture requirement seems OK, given that it needs to be explicitly opted into by the loading frame. The Chrome interventions make me sad because they are being imposed on all resources with no way to opt-out. |
This parameter would help close one of the few remaining data exfiltration holes not currently covered by CSP. I feel like it would serve as a useful defense in depth addition for sensitive sites. |
Is anyone interested in speccing this eventually? |
@eligrey There is some ongoing work on trying to spec this in a reasonable way, eg., https://w3c.github.io/webappsec-csp/#navigation-to, and https://lists.w3.org/Archives/Public/public-webappsec/2017Dec/0000.html. |
Most notably #290 is in progress. |
Not sure how it's related to |
It seems like there are no more objections and corrections. This fixes w3c/webappsec-csp#125.
There's been some mild discussion around whether or not to add a directive that would restrict what URLs a given page can navigate to. Let's get it started!
The text was updated successfully, but these errors were encountered: