No Code Attached Yet bug
avatar sisko1990
sisko1990
2 Apr 2022

Steps to reproduce the issue

Install a fresh Joomla 4.1.2 version (in my case with de-DE language package during installation). Now log in as administrator and under "System" -> "Plugins" -> "System - HTTP Headers" only the following is set:
Tab "Content-Security-Policy (CSP)": "Enabled". The settings are now as shown in the picture.
csp
Then click on "Save".

Expected result

When opening the frontend, the "strict-dynamic" header is sent (incl. nonce).

Actual result

header
The option strict-dynamic (or a nonce in the header [in HTML there is the nonce]) does not appear.

System information (as much as possible)

systeminfo-2022-04-02T16 59 46+02 00.txt

avatar sisko1990 sisko1990 - open - 2 Apr 2022
avatar joomla-cms-bot joomla-cms-bot - change - 2 Apr 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 2 Apr 2022
avatar sisko1990 sisko1990 - change - 2 Apr 2022
The description was changed
avatar sisko1990 sisko1990 - edited - 2 Apr 2022
avatar sisko1990 sisko1990 - change - 2 Apr 2022
The description was changed
avatar sisko1990 sisko1990 - edited - 2 Apr 2022
avatar sisko1990
sisko1990 - comment - 30 Apr 2022

So to summarise briefly: The plugin "System - HTTP Headers" does not seem to include the "strict-dynamic" in the Joomla! website, nor the "nonce" in the header. However, the "Nonce" is correctly inserted in the HTML.
@zero-24 maybe any idea?

avatar zero-24
zero-24 - comment - 30 Apr 2022

Yes strict-dynamic is only added once you set an initial script-src rule and the nonce are added once you add the "{nonce}" placeholder.

Not sure whether we want it but we can force the nonce and the strict-dynamic option to be set in the case that option is enabled. The placeholders might also be mentiond on the descriptions to make it easier to understand?

avatar sisko1990
sisko1990 - comment - 30 Apr 2022

Ok, that you have to use "{nonce}" is not really obvious though. Have also in the plugin no documentation found to it. This should be documented somewhere in any case, otherwise you do not understand why no nonce is effective (so not present in the CSP).
stcript-src

I use the standard template "Cassiopeia", with inline scripts and inline styles the nonce is added correctly, but not with a "script src=file.js", which leads to the fact that no JavaScript is loaded at all, is that in the sense of the inventor?
html

avatar zero-24
zero-24 - comment - 30 Apr 2022

Please set script-src = 'self' {nonce} that should fix the issue by allowing the hosted JS files.

avatar sisko1990
sisko1990 - comment - 30 Apr 2022

Yes, this solves the problem, but it is not really a secure CSP header. Only the nonce in the script-src would be better. In a transitional phase, possibly also in combination with strict-dynamic. Compare: https://cspscanner.com and https://csp-evaluator.withgoogle.com - Is it intended in the plugin that the scripts are automatically equipped with a nonce in the HTML?

avatar zero-24
zero-24 - comment - 30 Apr 2022

Yes, this solves the problem, but it is not really a secure CSP header.

Why? Allowing the locally stored JS files should be ok or I'm missing something? From my understading its ignored within CSP3 anyway when there is strict-dynamic
image

Only the nonce in the script-src would be better.

Yes when you only have inline scripts. Ideally even the nonce should not be required just "script-src 'self'" when all inline stuff is converted to static js files?

Is it intended in the plugin that the scripts are automatically equipped with a nonce in the HTML?

Yes inline scripts passed to the html via the joomla api.

avatar sisko1990
sisko1990 - comment - 30 Apr 2022

Ok, then I'll make the distinction clear:

script-src 'self' 'nonce-XXX' 'strict-dynamic'

Here, as you have already written, self is ignored, but also all JavaScript files that are included via <script src="file.js"> are blocked by the CSP header, as they do not have a nonce.
(Chrome incorrectly indicates here that script-src-elem would be the problem, however, this does not occur in the CSP at all, so it falls back to script-src)
csp

script-src 'self' 'nonce-XXX'

Here, the JavaScript files that are included via <script src="file.js"> are no longer blocked. But the warning message is already obvious for locally embedded files.
evaluator

avatar zero-24
zero-24 - comment - 30 Apr 2022

Here, as you have already written, self is ignored, but also all JavaScript files that are included via <script src="file.js"> are blocked by the CSP header, as they do not have a nonce.

Ok so also <script src="file.js"> needs a nonce? Should be possible as the nonce is an option of the webapplication. Not sure form the top of my head where that is generated within joomla but as long its passed via the api there should be a place to add this.

avatar sisko1990
sisko1990 - comment - 30 Apr 2022

Ok so also <script src="file.js"> needs a nonce?

Exactly, compare also: https://content-security-policy.com/strict-dynamic/

avatar zero-24
zero-24 - comment - 30 Apr 2022

Ha ok looks like i missed it. Thats actually not part of the implementation yet

avatar zero-24
zero-24 - comment - 31 May 2022

@sisko1990 please check: #37942 and #37940 for two issues reported here. Thanks.

That should also cover all issues reported here right? Could be that we have to force add the script-src directive when nothing has been done there manually right?

avatar chmst chmst - change - 17 Feb 2023
Labels Added: bug
avatar chmst chmst - labeled - 17 Feb 2023
avatar brianteeman
brianteeman - comment - 10 Apr 2023

Looks to me that the two merged pr referenced by @zero-24 above have resolved this issue and there is nothing left to do here

avatar zero-24
zero-24 - comment - 10 Apr 2023

Yes thanks.

avatar zero-24 zero-24 - close - 10 Apr 2023
avatar zero-24 zero-24 - change - 10 Apr 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-04-10 20:45:28
Closed_By zero-24

Add a Comment

Login with GitHub to post a comment