0

I have a Content-Security-Policy for my Wordpress Website (LAMP-Server):

set Content-Security-Policy "base-uri 'self'; default-src 'self'; font-src 'self' data: https://fonts.gstatic.com; frame-src https://www.google.com https://www.youtube.com; img-src 'self' https://secure.gravatar.com; script-src 'self' 'unsafe-inline' ; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; object-src 'self'; form-action 'self'; frame-ancestors 'self';"

This CSP prevents me from activating any check box in Wordpress (either the check box that remembers my login or the check boxes that let me select which theme to update) (Tested with Firefox in Linux and Chrome on Android).

Without CSP everything works as expected.

Any hint on which CSP is required to make that work again is greatly appreciated.

2
  • 1
    There’s no reason a CSP should stop checkboxes from working. The likely cause is a broken script. You should check the console for errors. Commented Jan 23, 2022 at 12:41
  • Thanks for the hint with the console. Content Security Policy: Die Einstellungen der Seite haben das Laden einer Ressource auf data:image/svg+xml;utf8,%3Csvg%20xmlns%3… blockiert ("img-src"). In img src self is allowed..what am I missing here
    – Umbertones
    Commented Jan 23, 2022 at 19:27

1 Answer 1

1

Thanks to Jacob's hint I got the solution. This one is working.

Header set Content-Security-Policy "base-uri 'self'; default-src 'self'; font-src 'self' data: https://fonts.gstatic.com; frame-src https://www.google.com https://www.youtube.com; img-src data: 'self' https://secure.gravatar.com; script-src 'self' 'unsafe-inline' ; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; object-src 'self'; form-action 'self'; frame-ancestors 'self';"

The difference is the data: in the ìmg-src section.

2
  • I'm facing the same issue on my website when I try to use Elementor Page builder. Can you let me know where to add the code snippet (Header append Content-Security-Policy "default-src 'self'; script-src https:;")? For example, is that .htaccess or header.php? Thank you. Commented Oct 4, 2023 at 8:49
  • I was not very succesful in using these strings in .htaccess or similar. I have those in my apache-conf-files in /etc/apache2 (LAMP system). There it is in the virtual host section of the corresponding website. Every time you edit these strings you have to restart your apache service.
    – Umbertones
    Commented Oct 5, 2023 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.