? ? ? Pending

User tests: Successful: Unsuccessful:

avatar zero-24
zero-24
27 Jul 2019

Summary of Changes

Implement a hashbased whitelist for com_csp / plg_http_httpheaders as requested by @SniperSister

Testing Instructions

  • apply this patch
  • System -> Manage -> Content Security Policy -> Options
  • Enable the detect mode.
  • navigate the frontend and backend
  • System -> Manage -> Content Security Policy
  • publish all rules
  • System -> Manage -> Content Security Policy -> Options
  • change the mode to "Automatic"
  • check the header set by the app using the browser console network tab (hint check the first request you can see for the header)
  • System -> Manage -> Content Security Policy -> Options
  • enable the new script hashes and style hashes option
  • check the header again.

Expected result

New options for script and style hashes implemented

Actual result

No options for script and style hashes implemented

Documentation Changes Required

This needs to be documented.

Known limitation

Please note that this here is indeed feature complete in order to work out of the box any inline style / script needs to be converted to a script running from a file. This is not the case with at least the current backend template so there are still some errors in the console but 90% of the features still work the other just needs to be moved to pass the required inline scripts via the joomla api. This is also true for any other template or extension.

Open points

-[ ] en-GB review of the new language strings

@brianteeman can you please take a look into the new language strings whether they makes sense or can be improved? Thanks.

Acknowledgements

Thanks @SniperSister for suggesting the implementation of hashbased whitelists in order to overcome the limitations of the nonce and the usage of unsafe-inline.

avatar zero-24 zero-24 - open - 27 Jul 2019
avatar zero-24 zero-24 - change - 27 Jul 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 27 Jul 2019
Category Administration com_csp Language & Strings Front End Plugins
avatar brianteeman
brianteeman - comment - 27 Jul 2019

Specifying hashes makes a modern browser ignore 'unsafe-inline'

Is that really an accurate description

avatar brianteeman
brianteeman - comment - 27 Jul 2019

At least according to the linked source https://scotthelme.co.uk/content-security-policy-an-introduction/#hash then thats not how it is supposed to work

avatar SniperSister
SniperSister - comment - 27 Jul 2019

@zero-24 is correct, a browser with CSP2 support will ignore an unsafe-inline directive if hashes and/or nonces are present. That’s a built-in compatibility layer in the specification.

avatar brianteeman
brianteeman - comment - 27 Jul 2019

Surely it only "ignores" it if the hashes are checked and found to be correct

the browser will hash any inline JS or CSS and see if the digest matches a value found in the header. If it does, the content is safe for use.
The contents of any <script> tags on the page would then be hashed and compared to the value found in the CSP header. If the values matched, the script would be allowed to execute.

avatar zero-24 zero-24 - change - 27 Jul 2019
Labels Added: ? ? ?
avatar zero-24
zero-24 - comment - 27 Jul 2019

Is that really an accurate description

Can you please suggest an alternative description?

avatar brianteeman
brianteeman - comment - 27 Jul 2019

It depends if it does what you wrote or it does what Scott says you should do

avatar zero-24
zero-24 - comment - 27 Jul 2019

hmm my text is based on the chrome error message:

[Report Only] Refused to execute inline script because it violates the following Content Security Policy directive: "script-src-elem 'self' 'unsafe-inline' 'sha256-tbnnT/BTiNbMb7tp2DUzXvspk56uv/T7ZMNODFB3MMo=' 'unsafe-inline'". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list.

And in chrome and FF this also works just that way, that is what i can tell.

avatar zero-24
zero-24 - comment - 31 Jul 2019

Thanks for the feedback it is implemented now.

517a7b0 13 Sep 2019 avatar wilsonge ocd
avatar wilsonge wilsonge - change - 13 Sep 2019
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2019-09-13 12:08:35
Closed_By wilsonge
avatar wilsonge wilsonge - close - 13 Sep 2019
avatar wilsonge wilsonge - merge - 13 Sep 2019
avatar wilsonge
wilsonge - comment - 13 Sep 2019

Thanks!

Add a Comment

Login with GitHub to post a comment