diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-01 23:06:55 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-13 10:32:44 +0200 |
commit | 2916e5df7e08fc588e752beaf486d907112a34ee (patch) | |
tree | 968c83adcd9a70717bda5d1d1a5e06f23a158097 /core/templates | |
parent | 009761be58c4485f29a8d3382e51fb4e1bfbeec4 (diff) | |
download | nextcloud-server-2916e5df7e08fc588e752beaf486d907112a34ee.tar.gz nextcloud-server-2916e5df7e08fc588e752beaf486d907112a34ee.zip |
feat: Provide CSP nonce as `<meta>` element
This way we use the CSP nonce for dynamically loaded scripts.
Important to notice: The CSP nonce must NOT be injected in `content` as
this can lead to value exfiltration using e.g. side-channel attacts (CSS selectors).
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'core/templates')
-rw-r--r-- | core/templates/layout.base.php | 1 | ||||
-rw-r--r-- | core/templates/layout.guest.php | 1 | ||||
-rw-r--r-- | core/templates/layout.initial-state.php | 6 | ||||
-rw-r--r-- | core/templates/layout.public.php | 1 | ||||
-rw-r--r-- | core/templates/layout.user.php | 1 |
5 files changed, 7 insertions, 3 deletions
diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php index eb88d62632e..e74cd4b8cd2 100644 --- a/core/templates/layout.base.php +++ b/core/templates/layout.base.php @@ -14,6 +14,7 @@ </title> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> <meta name="theme-color" content="<?php p($theme->getColorPrimary()); ?>"> + <meta name="csp-nonce" nonce="<?php p($_['cspNonce']); /* Do not pass into "content" to prevent exfiltration */ ?>"> <link rel="icon" href="<?php print_unescaped(image_path('core', 'favicon.ico')); /* IE11+ supports png */ ?>"> <link rel="apple-touch-icon" href="<?php print_unescaped(image_path('core', 'favicon-touch.png')); ?>"> <link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path('core', 'favicon-mask.svg')); ?>" color="<?php p($theme->getColorPrimary()); ?>"> diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index be0c36d6c53..03682a24193 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -19,6 +19,7 @@ p($theme->getTitle()); ?> </title> + <meta name="csp-nonce" nonce="<?php p($_['cspNonce']); /* Do not pass into "content" to prevent exfiltration */ ?>"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> <?php if ($theme->getiTunesAppId() !== '') { ?> <meta name="apple-itunes-app" content="app-id=<?php p($theme->getiTunesAppId()); ?>"> diff --git a/core/templates/layout.initial-state.php b/core/templates/layout.initial-state.php index 23c9be1a9c4..f2387990b12 100644 --- a/core/templates/layout.initial-state.php +++ b/core/templates/layout.initial-state.php @@ -5,7 +5,7 @@ */ ?> <div id="initial-state-container" style="display: none;"> - <?php foreach ($_['initialStates'] as $app => $initialState) { ?> - <input type="hidden" id="initial-state-<?php p($app); ?>" value="<?php p(base64_encode($initialState)); ?>"> - <?php }?> + <?php foreach ($_['initialStates'] as $app => $initialState) { ?> + <input type="hidden" id="initial-state-<?php p($app); ?>" value="<?php p(base64_encode($initialState)); ?>"> + <?php }?> </div> diff --git a/core/templates/layout.public.php b/core/templates/layout.public.php index b228801190c..90aefe0b8a8 100644 --- a/core/templates/layout.public.php +++ b/core/templates/layout.public.php @@ -14,6 +14,7 @@ p($theme->getTitle()); ?> </title> + <meta name="csp-nonce" nonce="<?php p($_['cspNonce']); /* Do not pass into "content" to prevent exfiltration */ ?>"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> <?php if ($theme->getiTunesAppId() !== '') { ?> <meta name="apple-itunes-app" content="app-id=<?php p($theme->getiTunesAppId()); ?>"> diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 475d1b89a0f..3293fc0acd7 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -29,6 +29,7 @@ p(!empty($_['application']) ? $_['application'].' - ' : ''); p($theme->getTitle()); ?> </title> + <meta name="csp-nonce" nonce="<?php p($_['cspNonce']); /* Do not pass into "content" to prevent exfiltration */ ?>"> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <?php if ($theme->getiTunesAppId() !== '') { ?> |