-
-
Notifications
You must be signed in to change notification settings - Fork 565
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
Replace inline onclick with addEventListener inside .js file to be compatible with CSP (v6) #3104
Conversation
56c3878
to
4ab2701
Compare
…mpatible with CSP Signed-off-by: Orazio <22700499+orazioedoardo@users.noreply.github.com>
I'm not too familiar with CSP but for me logging out still works on latest Firefox and Chrome even when on the new FTL branch but not on this web branch (i.e., with the existing |
CSP in the configuration of my other pull request doesn't allow inline onlick. To verify, recompile FTL with the other pull request, then visit the web interface without this pull request and observe that logout doesn't work. |
Logout shouldn't work anymore (check error in console) unless you also apply this pull request, can you confirm? |
It shouldn't though. CSP should give a violation report blocking the execution. It's the reason why I opened this pull request. |
Can confirm the same behaviour as DL6ER:
|
Just tried with the changes of my CSP branch of FTL and the onlick handler is blocked on Chrome, Firefox and Safari. Only difference is that I'm applying the headers by proxying through Nginx but the output is the same. Firefox shows another (unrelated) error regarding the SVG logo for which I will open a workaround PR once you are able to reproduce this PR. |
Do you see the same if you access http://pi.hole/admin ? |
It doesn't make a difference (as I expected). |
Are we saying here that one needs to be behind a reverse proxy in order to reproduce this? |
No, it's a response header handled by the browser. I just did it this way to avoid recompiling FTL. Also works for me by injecting the header via Chrome developer tools. Are there builds of FTL I can try? |
You can find the latest builds for Though that might not be what you mean! When testing your branches locally, I first built it in the devcontainer, and then built a new pi-hole docker image locally with |
Yeah I meant builds of my branch of FTL which I assumed you have to test it. |
Foreign branches aren't built to protect internal secrets which could otherwise be "stolen". This is a default defensive behavior with Github Actions. But I don't think this matters here, both @PromoFaux and myself pulled your changes and built FTL locally for testing. FTL sent the expected CSP headers as you can see in my dev console screenshot further up. Yet, we cannot reproduce the described behavior which makes us a bit clueless at what is going on here. |
Looks like FTL is adding "additional_header" for static files and API requests but NOT actual pages (text/html), where CSP matters the most. |
You are right, this is a bug in the webserver we embedd: CivetWeb. I've already created a bugfix PR upstream: civetweb/civetweb#1286 Thanks for pointing this out. With this fix applied, I can reproduce your observation and indeed confirm that your PR here fixes this issue. |
Thank you for your contribution to the Pi-hole Community!
Please read the comments below to help us consider your Pull Request.
We are all volunteers and completing the process outlined will help us review your commits quicker.
Please make sure you
What does this PR aim to accomplish?:
Makes the page compatible with a CSP that only allows script sourced from same origin, see pi-hole/FTL#2029.
How does this PR accomplish the above?:
Replaces inline
onclick
withaddEventListener
inside .js file.By submitting this pull request, I confirm the following:
git rebase
)