Content Security Policy 'unsafe-inline' 'unsafe-eval' - unsafe settings?

Discussion regarding Joomla! 3.x security issues.

Moderators: mandville, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant / FPA - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
sunny day
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Mar 11, 2014 11:26 am

Content Security Policy 'unsafe-inline' 'unsafe-eval' - unsafe settings?

Post by sunny day » Tue May 09, 2017 4:22 pm

We have a Content Security Policy set in .htaccess for a website. In order to allow google maps and google fonts to work we had to add multiple URLs. We have read that in order for Joomla to work properly script-src 'self' 'unsafe-eval' 'unsafe-inline' AND style-src 'self' 'unsafe-inline' are also required. The full policy is included below. My questions are:

(1) What is the strictest Content Security Policy possible that will allow a standard installation of Joomla to function properly and allow updates to extensions and the core without causing problems?

(2) Are 'unsafe-eval' and/or 'unsafe-inline' needed at all times or is it only necessary to include them when extensions and / or core updates are made after which they can be removed in order to strengthen security?

(3) Is the policy below better or worse than having no CSP at all?

(4) Could a hacker spoof (not sure what the correct term is) a file so that it seems like it is coming from one of the green-listed urls?

(5) Are there any obvious mistakes in the policy?

One observation is that google maps seems to require an excessive number of URL resources to work properly. If / when google change any of these URLs it will break one or more map functions in which case it could be some time before such errors are noticed and corrected by the client or site administrator. Therefore it would seem the less resources that are loaded from third party URLs the better especially from a security point of view.

Sorry for asking so many questions but any help would be appreciated. Thank you.

Code: Select all

##########Content Security Policy
Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://maps.googleapis.com/; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com/; img-src 'self' https://maps.gstatic.com https://csi.gstatic.com https://maps.googleapis.com/ https://khms0.googleapis.com/ https://khms1.googleapis.com/ https://lh3.ggpht.com/ https://cbks0.googleapis.com/ https://lh3.ggpht.com/ https://geo0.ggpht.com/ https://geo2.ggpht.com/ https://geo1.ggpht.com/ https://geo3.ggpht.com/; font-src 'self' https://fonts.gstatic.com/"
Last edited by fcoulter on Tue May 09, 2017 4:29 pm, edited 1 time in total.
Reason: breaking links - please use code tag for this kind of content, it prevents automatic insertion of links

User avatar
AndyGaskell
Joomla! Apprentice
Joomla! Apprentice
Posts: 37
Joined: Fri Oct 31, 2008 3:12 pm
Location: Aberdeen
Contact:

Re: Content Security Policy 'unsafe-inline' 'unsafe-eval' - unsafe settings?

Post by AndyGaskell » Mon Nov 06, 2017 11:59 am

There is a RFC related to this at https://github.com/joomla/joomla-cms/issues/14246

So the outcome of that might help.
My work: http://www.ssofb.co.uk.
Twitter: https://twitter.com/AndyGasman.
I'm a programmer at Software Systems: Open For Business in Aberdeen Scotland doing LAMP web development.

sunny day
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Mar 11, 2014 11:26 am

Re: Content Security Policy 'unsafe-inline' 'unsafe-eval' - unsafe settings?

Post by sunny day » Mon Nov 06, 2017 4:05 pm

Thank you for the link Andy. I'll take a look at it.


Locked

Return to “Security in Joomla! 3.x”