Lychee versionv 7.4.0 Did you check the latest Lychee version?Yes, I did Which PHP version are you using?PHP 8.4 Detailed description of the problemDuring troubleshooting some issues with my Lychee.org + matomo installation on my server, claude found possible bug in secure-headers.php. I allowed claude to prepare detailed report of the problem, and with possible fix. The connect-src directive in config/secure-headers.php is built as a flat array instead of the nested ['allow' => [...]] structure expected by the bepsvpt/secure-headers library. As a result, the directive is silently omitted from the Content-Security-Policy response header entirely, regardless of what is set in SECURITY_HEADER_CSP_CONNECT_SRC in .env. Steps to reproduce the issue
Expected BehaviourThe Actual BehaviourThe The directive is silently dropped because Root CauseIn 'connect-src' => array_merge(
['https://lycheeorg.dev/update.json'],
explode(',', (string) env('SECURITY_HEADER_CSP_CONNECT_SRC', ''))
),This produces a flat indexed array, e.g.: [
0 => 'https://lycheeorg.dev/update.json',
1 => 'https://example.com',
]The Compare with other directives in the same file that work correctly, e.g. 'img-src' => [
'allow' => array_merge(
[...],
explode(',', (string) env('SECURITY_HEADER_CSP_IMG_SRC', ''))
),
],Proposed FixWrap the 'connect-src' => [
'allow' => array_merge(
['https://lycheeorg.dev/update.json'],
array_filter(explode(',', (string) env('SECURITY_HEADER_CSP_CONNECT_SRC', '')))
),
],The additional Security Impact
WorkaroundEdit php artisan config:clear
php artisan config:cacheDiagnostics [REQUIRED]n/a Browser & System [REQUIRED]n/a Please confirm (incomplete submissions will not be addressed)
|
Replies: 1 comment 5 replies
|
Can you check with version 7.4.1 that just got released ? I was literally working on the CSP today. |
It will be in the next release or on the
edgetag in about 1h (max).