From ff621bce350f537ee5653556ababb4c84fb1461a Mon Sep 17 00:00:00 2001 From: Josh North Date: Wed, 11 Aug 2021 20:12:35 -0400 Subject: [PATCH] CSP tweaks again, login uid fix, mild cleanup --- inc/footer.inc.php | 6 ++-- inc/header.inc.php | 80 ++++++++++++++++++++++------------------------ index.php | 32 +++++++++---------- printvwf.php | 48 ++++++++++++++-------------- reports.php | 6 ++-- signin.php | 8 ++--- signout.php | 2 +- 7 files changed, 90 insertions(+), 92 deletions(-) diff --git a/inc/footer.inc.php b/inc/footer.inc.php index eb2b094..aaf8260 100755 --- a/inc/footer.inc.php +++ b/inc/footer.inc.php @@ -31,14 +31,14 @@ - - + - + diff --git a/inc/header.inc.php b/inc/header.inc.php index 4f789be..e8541e9 100644 --- a/inc/header.inc.php +++ b/inc/header.inc.php @@ -57,7 +57,8 @@ } else { $sessuserid='2'; } - $session_user = $Users->getUserInfo($sessuserid, "1", "0"); } + } + $session_user = $Users->getUserInfo((int)$sessuserid, "1", "0"); if (isset($session_user)) { // GET UID OR SET TO KIOSK $uid = $session_user["0"]["users_id"];} else { $uid = "2"; } $app_disp_lang = filter_input(INPUT_COOKIE, 'app_disp_lang'); // SETUP LANGUAGE @@ -80,18 +81,15 @@ $timeplus = new DateTime($StaticFunctions->getUTC(), new DateTimeZone('UTC')); // DUMB WAY TO CALCULATE SOME TIMES $timeplus->setTimezone(new DateTimeZone("$timezone")); $timenow = $timeplus->format('Y-m-d H:i:s'); - $_SESSION['nonce']= base64_encode(random_bytes(32)); - $noncestring="nonce-".$_SESSION['nonce']; - $urlsrc=basename($_SERVER['PHP_SELF']); - header("X-Frame-Options: SAMEORIGIN"); - header("X-Content-Type-Options: nosniff"); - //header("Content-Security-Policy: default-src '$urlsrc'; script-src '$urlsrc'"); - header("Content-Security-Policy: default-src '$noncestring' 'self'; script-src '$noncestring' 'self' ; script-src-elem '$noncestring' 'self'; script-src-attr '$noncestring' 'self'; style-src '$noncestring' 'self'; style-src-elem '$noncestring' 'self'; style-src-attr '$noncestring' 'self'; img-src '$noncestring' 'self' data:; connect-src '$noncestring' 'self'; frame-src '$noncestring' 'self'; font-src '$noncestring' 'self'; media-src '$noncestring' 'self'; object-src '$noncestring' 'self'; manifest-src '$noncestring' 'self'; worker-src '$noncestring' 'self'; prefetch-src '$noncestring' 'self'; form-action '$noncestring' 'self'; frame-ancestors '$noncestring' 'self'"); - //header("Content-Security-Policy: script-src 'self' 'unsafe-inline'; script-src-elem 'self'; script-src-attr 'self'; style-src 'self'; style-src-elem 'self'; style-src-attr 'self'; img-src 'self'; connect-src 'self'; frame-src 'self'; font-src 'self'; media-src 'self'; object-src 'self'; manifest-src 'self'; worker-src 'self'; prefetch-src 'self'; form-action 'self'; frame-ancestors 'self'; default-src 'self'", false); - if (!empty($_GET['a'])) { - echo '
' . print_r($_POST, true) . '
'; - echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful'); - } + $_SESSION['nonceStr'] = base64_encode(random_bytes(32)); + $nonceHeader="nonce-".$_SESSION['nonceStr']; + $urlsrc=basename(filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_URL)); + header("X-Frame-Options: SAMEORIGIN"); + header("X-Content-Type-Options: nosniff"); + header("Content-Security-Policy: default-src '$nonceHeader' 'self'; script-src '$nonceHeader' 'self' ; script-src-elem '$nonceHeader' 'self'; script-src-attr '$nonceHeader' 'self'; style-src '$nonceHeader' 'self'; style-src-elem '$nonceHeader' 'self'; style-src-attr '$nonceHeader' 'self'; img-src '$nonceHeader' 'self' data:; connect-src '$nonceHeader' 'self'; frame-src '$nonceHeader' 'self'; font-src '$nonceHeader' 'self'; media-src '$nonceHeader' 'self'; object-src '$nonceHeader' 'self'; manifest-src '$nonceHeader' 'self'; worker-src '$nonceHeader' 'self'; prefetch-src '$nonceHeader' 'self'; form-action '$nonceHeader' 'self'; frame-ancestors '$nonceHeader' 'self'"); + if (!empty($_GET['a'])) { + echo '
' . print_r($_POST, true) . '
'; + echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful'); } ?> @@ -102,33 +100,33 @@ - + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + <?php echo $StaticFunctions->getTitle($app_current_pagename, $app_disp_lang); ?> @@ -137,7 +135,7 @@