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

Reporting in Chrome broken when form-action CSP directive exists #2557

Open
foolip opened this issue Jul 26, 2018 · 18 comments · Fixed by #2558
Open

Reporting in Chrome broken when form-action CSP directive exists #2557

foolip opened this issue Jul 26, 2018 · 18 comments · Fixed by #2558

Comments

@foolip
Copy link
Member

foolip commented Jul 26, 2018

Starting from https://webcompat.com/issues/new?label=type-google (HTTPS) and being logged in to the site using my GitHub account, I see a "Report as foolip" button alongside the "Report Anonymously" button. Using that button doesn't work, the whole form is fading in/out (intentional, I presume) but nothing happens. In the Chrome devtools console:

Refused to send form data to 'http://webcompat.com/' because it violates the following Content Security Policy directive: "form-action 'self'".

In other words, a problem of mixing http and https.

@foolip
Copy link
Member Author

foolip commented Jul 26, 2018

I also tried from https://webcompat.com/ and using "Report Anonymously", same problem.

@miketaylr red alert?

@miketaylr
Copy link
Member

dang. ok, i'll revert and investigate.

@miketaylr
Copy link
Member

dang. ok, i'll revert and investigate.

rather, deploy the last version.

@miketaylr
Copy link
Member

Refused to send form data to 'http://webcompat.com/'

Why are we trying to submit to the http endpoint...

@foolip
Copy link
Member Author

foolip commented Jul 26, 2018

Don't know if you already deployed, but I just tested on Firefox and the problem doesn't manifest there. So possibly this is also an interop issue :)

@foolip
Copy link
Member Author

foolip commented Jul 26, 2018

Interesting, my 3 attempts actually did successfully file issues:

I'll close them. Good news is that the type-google label worked!

@miketaylr
Copy link
Member

@foolip yeah, just barely re-deployed. Unsure if it was before or after you tested though.

b1bfaf5 is when we added the form-action CSP bits.

(site note: staging.webcompat.com is a place where we can file test bugs, fyi -- can manually deploy patches or branches there independent from production).

@miketaylr
Copy link
Member

cc @laghee (since this relates to the CSP stuff)

@foolip
Copy link
Member Author

foolip commented Jul 26, 2018

staging.webcompat.com is a place where we can file test bugs, fyi

Oh, I'll do that next time :) Which repo do the bugs end up in?

@softvision-sergiulogigan
Copy link
Collaborator

@miketaylr
Copy link
Member

Interesting... this does reproduce on staging in Chrome. I had tested before deploying in Firefox on staging.

screen shot 2018-07-26 at 2 22 46 pm

Time to investigate form-action CSP interop...

@miketaylr
Copy link
Member

miketaylr commented Jul 26, 2018

from MDN

Whether form-action should block redirects after a form submission is debated and browser implementations of this aspect are inconsistent (e.g. Firefox 57 doesn't block the redirects whereas Chrome 63 does).

That would make sense if we're trying to submit the form on HTTP and relying on nginx doing the 301 to HTTPS... but why would we be submitting to http? The form action is /issues/new... 😕

@miketaylr
Copy link
Member

We might consider removing the form-action directive from our CSP until we figure this out... otherwise it means Chrome users can't report bugs (which would be silly for a compat site :P). If I can't figure it out in a few hours, I'll back that out.

@foolip
Copy link
Member Author

foolip commented Jul 26, 2018

Thanks @miketaylr, much appreciated!

@laghee
Copy link
Contributor

laghee commented Jul 26, 2018

@miketaylr Any chance it's related to flask's url_for? https://stackoverflow.com/questions/34802316/make-flasks-url-for-use-the-https-scheme-in-an-aws-load-balancer-without-mess Maybe specifying PREFERRED_URL_SCHEME would change behavior?

@miketaylr
Copy link
Member

Any chance it's related to flask's url_for?

That's a good guess... but right now the form action is hard-coded to the relative/issues/new. And if you try to log out what formEl.action is before we call formEl.submit(), it shows the https endpoint. But somehow form-action is still complaining about trying to submit to http...

@miketaylr
Copy link
Member

OK, I've deployed the temporary bandaid patch (which just removes form-action) and deployed that, but we should try to figure out what the real bug is here... I'm still not 100% sure this isn't some strange Chrome bug. Testing with Charles Proxy, I didn't see any traffic trying to hit the http endpoint, or a redirect of any kind.

@miketaylr miketaylr reopened this Jul 26, 2018
@miketaylr miketaylr changed the title Unable to report issue on webcompat.com using "Report as foolip" Reporting in Chrome broken when form-action CSP directive exists Jul 26, 2018
@karlcow
Copy link
Member

karlcow commented Jul 27, 2018

Maybe some contexts here.
w3c/webappsec-csp#8
see for example

The current situation where Chrome/Safari block redirects and Firefox does not makes deploying form-action very tricky.

302 and 307 seem to have different behaviors btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants