The source list for Content Security Policy directive 'frame-ancestors' contains an invalid source: ''none''
Mantis 2.21.1 with latest BBCodePlus generates Google Chrome console error
The source list for Content Security Policy directive 'frame-ancestors' contains an invalid source: ''none''. It will be ignored. Note that 'none' has no effect unless it is the only expression in the source list.
due to response header:
content-security-policy: ... frame-ancestors 'self' 'none'; ...
From what I have been able to gather, this is an unavoidable behavior. Furthermore, the BBCodePlus plugin is not the one adding the none source, which is the one with the warning. We are adding the self:
function csp_headers() {
# relax csp when processing markitup.
if ( (ON == plugin_config_get( 'process_markitup' )) && function_exists( 'http_csp_add' ) ) {
http_csp_add( 'script-src', "'self' 'unsafe-inline' 'unsafe-eval' https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js" );
http_csp_add( 'img-src', "*" );
http_csp_add( 'frame-ancestors', "'self'" );
}
}
I believe none is the default. Unfortunately (@atrol please correct me on this), http_csp_add does not remove CSP content, just appends it to the current CSP.
That's true, 'none' is default for frame-ancestors in core/http_api.php. Looks like http_csp_add is not a best choise for plugin due to side-effects caused by console error.
Not sure there is much of an option. As I understand it, it is less safe to try to handle csp by sideloading, which is why http_csp_add was introduced. I'd defer to the mantisbt team on this. Also, this is not an error, but a warning. What side-effects are you experiencing as a result of this?
Sorry, no time to have a deeper look at this.
The solution might be to introduce a special treatment in function http_csp_add if $p_type is frame-ancestors. In this case and If none is set, unset none.
Closing this one as it doesn't really originate in BBCode plus, but at the mantis csp level. Will re-open when https_csp_add is worked on to address this.
Proposed fix mantisbt/mantisbt#1554