Vulnerability remediation

This commit is contained in:
Josh North 2021-05-28 15:31:54 -04:00
parent 2a8ee2d90f
commit 9043ccb0e2
18 changed files with 316 additions and 39 deletions

View File

@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$app_disp_lang = filter_input(INPUT_POST, 'app_disp_lang'); // GET SANITARY LANG CHOICE
setcookie ( 'app_disp_lang', $app_disp_lang, time() + 60*60*24*90); // SET LONG COOKIE
$app_disp_lang = filter_input(INPUT_POST, 'app_disp_lang', FILTER_SANITIZE_STRING); // GET SANITARY LANG CHOICE
setcookie ( 'app_disp_lang', $app_disp_lang, [
'expires' => time() + 60*60*24*90,
'secure' => true,
'httponly' => true,
'samesite' => 'None',
]);
header('Location: index.php'); // GO HOME UNTIL WE ADD REFERER LOGIC

View File

@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$site = filter_input(INPUT_POST, 'site'); // GET SANITARY SITE CHOICE
setcookie ( 'app_site', $site, time() + 60*60*24*90); // SET SITE COOKIE
$site = filter_input(INPUT_POST, 'site', FILTER_SANITIZE_STRING); // GET SANITARY SITE CHOICE
setcookie ( 'app_site', $site, [
'expires' => time() + 60*60*24*90,
'secure' => true,
'httponly' => true,
'samesite' => 'None',
]);
header('Location: index.php'); // GO HOME UNTIL WE ADD REFERER LOGIC

View File

@ -21,8 +21,10 @@
//ini_set('session.gc_divisor', 100); // TIMES
//session_save_path('.tmp'); // TEMP
//session_start(); // START
//ini_set("session. cookie_httponly", 1);
require_once __DIR__ . '/../autoload.php'; // AUTOLOAD
use App\LobbySIO\Config\Registry;
use App\LobbySIO\Misc\Csrf; // ANTICSRF
$Users = new \App\LobbySIO\Database\Users();
if (Registry::AUTHMETHOD == 'SAML') {
//simplesaml
@ -78,8 +80,12 @@
$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');
header("X-Frame-Options: SAMEORIGIN");
header("Content-Security-Policy: frame-ancestors 'none'", false);
if (!empty($_GET['a'])) {
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful');
}
?>
<!doctype html>
<html lang="<?php echo $app_disp_lang; ?>">
@ -163,6 +169,7 @@
<!-- END NAVBAR MENU FOR ALL LOGGED IN - BOTTOM END -->
<?php endif; ?>
<form action="changelang.php" method="post" name="changelang" class="changelang">
<?php echo Csrf::getInputToken('home') ?>
<div class="input-group">
<select class="form-select btn-outline-secondary" id="app_disp_lang" name="app_disp_lang">
<?php foreach(glob('src/Language/*.ini') as $file){
@ -187,6 +194,7 @@
</div>
<div class="modal-body">
<form class="row g-3" action="changesite.php" method="post">
<?php echo Csrf::getInputToken('home') ?>
<div class="input-group">
<select class="form-select" id="site" aria-label="Site" name="site" required>
<?php foreach($SiteInfo->getSite("0", $uid, "0", "0") as $row): ?>

View File

@ -19,6 +19,7 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD

2
js/pdfmake.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -19,9 +19,11 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD
use App\LobbySIO\Misc\Csrf; // ANTICSRF
use App\LobbySIO\Config\Registry;
$Users = new \App\LobbySIO\Database\Users();
if (Registry::AUTHMETHOD == 'SAML') {
@ -74,7 +76,14 @@
require_once("inc/header.inc.php");
if ($StaticFunctions->getUserSessionStatus() == true) { // CHECK STATUS
header('Location: index.php'); // ELSE HOME
} else { ?>
} else {
header("X-Frame-Options: SAMEORIGIN");
header("Content-Security-Policy: frame-ancestors 'none'", false);
if (!empty($_GET['a'])) {
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful');
}
?>
<!-- START CONTENT -->
@ -112,6 +121,7 @@ endif;
<hr />
<br />
<form class="form-signin" action="login.php" method="post">
<?php echo Csrf::getInputToken('home') ?>
<div class="input-group input-group-lg">
<?php if (Registry::AUTHMETHOD == 'INTERNAL') { ?>
<input type="text" class="form-control" aria-describedby="button-addon2" id="username" name="username" placeholder="<?php echo $transLang['USERNAME']; ?>" required autofocus>

View File

@ -19,6 +19,7 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD

View File

@ -19,6 +19,7 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD

View File

@ -19,6 +19,7 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD

View File

@ -19,9 +19,11 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD
use App\LobbySIO\Misc\Csrf; // ANTICSRF
$StaticFunctions = new \App\LobbySIO\Misc\StaticFunctions(); // DEFAULT CLASSES
$SiteInfo = new \App\LobbySIO\Database\SiteInfo();
$Users = new \App\LobbySIO\Database\Users();
@ -46,7 +48,14 @@
require_once("inc/header.inc.php");
if ($StaticFunctions->getSessionStatus() == true) { // CHECK STATUS
header('Location: index.php'); // ELSE HOME
} else { ?>
} else {
header("X-Frame-Options: SAMEORIGIN");
header("Content-Security-Policy: frame-ancestors 'none'", false);
if (!empty($_GET['a'])) {
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful');
}
?>
<!-- START CONTENT -->
<div class="container">
@ -56,6 +65,7 @@
</div>
</div>
<form name="form-signin" class="needs-validation" action="signin_1.php" method="post" novalidate>
<?php echo Csrf::getInputToken('home') ?>
<div class="form-group form-row">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="q1" required>

View File

@ -19,9 +19,11 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD
use App\LobbySIO\Misc\Csrf; // ANTICSRF
$StaticFunctions = new \App\LobbySIO\Misc\StaticFunctions(); // DEFAULT CLASSES
$SiteInfo = new \App\LobbySIO\Database\SiteInfo();
$Users = new \App\LobbySIO\Database\Users();
@ -46,7 +48,14 @@
require_once("inc/header.inc.php");
if ($StaticFunctions->getSessionStatus() == true) { // CHECK STATUS
header('Location: index.php'); // ELSE HOME
} else { ?>
} else {
header("X-Frame-Options: SAMEORIGIN");
header("Content-Security-Policy: frame-ancestors 'none'", false);
if (!empty($_GET['a'])) {
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful');
}
?>
@ -58,6 +67,7 @@
</div>
</div>
<form name="form-signin" class="form-signin" action="signin_2.php" method="post">
<?php echo Csrf::getInputToken('home') ?>
<div class="row row-cols-1">
<div class="col">
<div class="input-group mb-3">

View File

@ -19,9 +19,11 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD
use App\LobbySIO\Misc\Csrf; // ANTICSRF
$StaticFunctions = new \App\LobbySIO\Misc\StaticFunctions(); // DEFAULT CLASSES
$SiteInfo = new \App\LobbySIO\Database\SiteInfo();
$Users = new \App\LobbySIO\Database\Users();
@ -46,17 +48,24 @@
require_once("inc/header.inc.php");
if ($StaticFunctions->getSessionStatus() == true) { // CHECK STATUS
header('Location: index.php'); // ELSE HOME
} else { ?>
} else {
header("X-Frame-Options: SAMEORIGIN");
header("Content-Security-Policy: frame-ancestors 'none'", false);
if (!empty($_GET['a'])) {
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful');
}
?>
<!-- START CONTENT -->
<?php if (!empty($_POST)) { // PROCESS POST
if (empty($_POST['carnum'])) { $carnum="";} else {$carnum=$_POST['carnum'];};
if (empty($_POST['ssanum'])) { $ssanum="";} else {$ssanum=$_POST['ssanum'];};
if (empty($_POST['firstname'])) { $firstname="";} else {$firstname=$_POST['firstname'];};
if (empty($_POST['lastname'])) { $lastname="";} else {$lastname=$_POST['lastname'];};
if (empty($_POST['company'])) { $company="";} else {$company=$_POST['company'];};
if (empty(filter_input(INPUT_POST, 'carnum', FILTER_SANITIZE_STRING))) { $carnum="";} else {$carnum=filter_input(INPUT_POST, 'carnum', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'ssanum', FILTER_SANITIZE_STRING))) { $ssanum="";} else {$ssanum=filter_input(INPUT_POST, 'ssanum', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING))) { $firstname="";} else {$firstname=filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_STRING))) { $lastname="";} else {$lastname=filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'company', FILTER_SANITIZE_STRING))) { $company="";} else {$company=filter_input(INPUT_POST, 'company', FILTER_SANITIZE_STRING);};
?>
<div class="container">
<div class="row row-cols-1">
@ -65,6 +74,7 @@
</div>
</div>
<form name="form-signin" class="form-signin" action="signin_3.php" method="post">
<?php echo Csrf::getInputToken('home') ?>
<div class="row row-cols-1">
<div class="col">
<div class="input-group mb-3">

View File

@ -19,9 +19,11 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD
use App\LobbySIO\Misc\Csrf; // ANTICSRF
$StaticFunctions = new \App\LobbySIO\Misc\StaticFunctions(); // DEFAULT CLASSES
$SiteInfo = new \App\LobbySIO\Database\SiteInfo();
$Users = new \App\LobbySIO\Database\Users();
@ -46,18 +48,25 @@
require_once("inc/header.inc.php");
if ($StaticFunctions->getSessionStatus() == true) { // CHECK STATUS
header('Location: index.php'); // ELSE HOME
} else { ?>
} else {
header("X-Frame-Options: SAMEORIGIN");
header("Content-Security-Policy: frame-ancestors 'none'", false);
if (!empty($_GET['a'])) {
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful');
}
?>
<!-- START CONTENT -->
<?php if (!empty($_POST)) { // PROCESS POST
if (empty($_POST['carnum'])) { $carnum="";} else {$carnum=$_POST['carnum'];};
if (empty($_POST['ssanum'])) { $ssanum="";} else {$ssanum=$_POST['ssanum'];};
if (empty($_POST['firstname'])) { $firstname="";} else {$firstname=$_POST['firstname'];};
if (empty($_POST['lastname'])) { $lastname="";} else {$lastname=$_POST['lastname'];};
if (empty($_POST['company'])) { $company="";} else {$company=$_POST['company'];};
if (empty($_POST['visit_type'])) { $visit_type="";} else {$visit_type=$_POST['visit_type'];};
if (empty(filter_input(INPUT_POST, 'carnum', FILTER_SANITIZE_STRING))) { $carnum="";} else {$carnum=filter_input(INPUT_POST, 'carnum', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'ssanum', FILTER_SANITIZE_STRING))) { $ssanum="";} else {$ssanum=filter_input(INPUT_POST, 'ssanum', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING))) { $firstname="";} else {$firstname=filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_STRING))) { $lastname="";} else {$lastname=filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'company', FILTER_SANITIZE_STRING))) { $company="";} else {$company=filter_input(INPUT_POST, 'company', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'visit_type', FILTER_SANITIZE_STRING))) { $visit_type="";} else {$visit_type=filter_input(INPUT_POST, 'visit_type', FILTER_SANITIZE_STRING);};
?>
<div class="container">
<div class="row row-cols-1">
@ -66,6 +75,7 @@
</div>
</div>
<form name="form-signin" class="form-signin" action="signin_4.php" method="post">
<?php echo Csrf::getInputToken('home') ?>
<div class="accordion" id="accordionExample">
<div class="accordion-item">
<h5 class="accordion-header" id="headingOne">

View File

@ -19,9 +19,11 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD
use App\LobbySIO\Misc\Csrf; // ANTICSRF
$StaticFunctions = new \App\LobbySIO\Misc\StaticFunctions(); // DEFAULT CLASSES
$SiteInfo = new \App\LobbySIO\Database\SiteInfo();
$Users = new \App\LobbySIO\Database\Users();
@ -46,21 +48,28 @@
require_once("inc/header.inc.php");
if ($StaticFunctions->getSessionStatus() == true) { // CHECK STATUS
header('Location: index.php'); // ELSE HOME
} else { ?>
} else {
header("X-Frame-Options: SAMEORIGIN");
header("Content-Security-Policy: frame-ancestors 'none'", false);
if (!empty($_GET['a'])) {
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful');
}
?>
<!-- START CONTENT -->
<?php if (!empty($_POST)) { // PROCESS POST
if (empty($_POST['carnum'])) { $carnum="";} else {$carnum=$_POST['carnum'];};
if (empty($_POST['ssanum'])) { $ssanum="";} else {$ssanum=$_POST['ssanum'];};
if (empty($_POST['firstname'])) { $firstname="";} else {$firstname=$_POST['firstname'];};
if (empty($_POST['lastname'])) { $lastname="";} else {$lastname=$_POST['lastname'];};
if (empty($_POST['company'])) { $company="";} else {$company=$_POST['company'];};
if (empty($_POST['visit_type'])) { $visit_type="";} else {$visit_type=$_POST['visit_type'];};
if (empty($_POST['v_signature'])) { $v_signature="";} else {$v_signature=$_POST['v_signature'];};
if (empty($_POST['e_signature'])) { $e_signature="";} else {$e_signature=$_POST['e_signature'];};
if (empty($_POST['escort'])) { $escort="";} else {$escort=$_POST['escort'];};
if (empty(filter_input(INPUT_POST, 'carnum', FILTER_SANITIZE_STRING))) { $carnum="";} else {$carnum=filter_input(INPUT_POST, 'carnum', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'ssanum', FILTER_SANITIZE_STRING))) { $ssanum="";} else {$ssanum=filter_input(INPUT_POST, 'ssanum', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING))) { $firstname="";} else {$firstname=filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_STRING))) { $lastname="";} else {$lastname=filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'company', FILTER_SANITIZE_STRING))) { $company="";} else {$company=filter_input(INPUT_POST, 'company', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'visit_type', FILTER_SANITIZE_STRING))) { $visit_type="";} else {$visit_type=filter_input(INPUT_POST, 'visit_type', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'v_signature', FILTER_SANITIZE_STRING))) { $v_signature="";} else {$v_signature=filter_input(INPUT_POST, 'v_signature', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'e_signature', FILTER_SANITIZE_STRING))) { $e_signature="";} else {$e_signature=filter_input(INPUT_POST, 'e_signature', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'escort', FILTER_SANITIZE_STRING))) { $escort="";} else {$escort=filter_input(INPUT_POST, 'escort', FILTER_SANITIZE_STRING);};
?>
<div class="container">
<div class="row row-cols-1">
@ -69,6 +78,7 @@
</div>
</div>
<form name="form-signin" class="form-signin" action="signin_display.php" method="post">
<?php echo Csrf::getInputToken('home') ?>
<div class="row row-cols-1">
<div class="col">
<input type="hidden" name="siteid" id="siteid" value="<?php echo $siteid; ?>" />

View File

@ -19,9 +19,11 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD
use App\LobbySIO\Misc\Csrf; // ANTICSRF
$StaticFunctions = new \App\LobbySIO\Misc\StaticFunctions(); // DEFAULT CLASSES
$SiteInfo = new \App\LobbySIO\Database\SiteInfo();
$Users = new \App\LobbySIO\Database\Users();
@ -47,15 +49,22 @@
require_once("inc/header.inc.php");
if ($StaticFunctions->getSessionStatus() == true) { // CHECK STATUS
header('Location: index.php'); // ELSE HOME
} else { ?>
} else {
header("X-Frame-Options: SAMEORIGIN");
header("Content-Security-Policy: frame-ancestors 'none'", false);
if (!empty($_GET['a'])) {
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful');
}
?>
<!-- START CONTENT -->
<?php if (!empty($_POST)) { // PROCESS POST
if (empty($_POST['carnum'])) { $carnum="";} else {$carnum=$_POST['carnum'];};
if (empty($_POST['ssanum'])) { $ssanum="";} else {$ssanum=$_POST['ssanum'];};
echo $VisitActions->newVisit($_POST['firstname'], $_POST['lastname'], $_POST['company'], $_POST['visit_type'], $StaticFunctions->getUTC(), $_POST['v_signature'], $_POST['siteid'], "1", $_POST['e_signature'], $_POST['escort'], $carnum, $ssanum);
if (empty(filter_input(INPUT_POST, 'carnum', FILTER_SANITIZE_STRING))) { $carnum="";} else {$carnum=filter_input(INPUT_POST, 'carnum', FILTER_SANITIZE_STRING);};
if (empty(filter_input(INPUT_POST, 'ssanum', FILTER_SANITIZE_STRING))) { $ssanum="";} else {$ssanum=filter_input(INPUT_POST, 'ssanum', FILTER_SANITIZE_STRING);};
echo $VisitActions->newVisit(filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING), filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_STRING), filter_input(INPUT_POST, 'company', FILTER_SANITIZE_STRING), filter_input(INPUT_POST, 'visit_type', FILTER_SANITIZE_STRING), $StaticFunctions->getUTC(), filter_input(INPUT_POST, 'v_signature', FILTER_SANITIZE_STRING), filter_input(INPUT_POST, 'siteid', FILTER_SANITIZE_STRING), "1", filter_input(INPUT_POST, 'e_signature', FILTER_SANITIZE_STRING), filter_input(INPUT_POST, 'escort', FILTER_SANITIZE_STRING), $carnum, $ssanum);
?>
<div class="container">
<div class="row row-cols-1">
@ -73,7 +82,7 @@
</thead>
<tbody>
<tr>
<td><?php echo $timenow; ?><br><?php echo $transLang[$VisitTypeInfo->getVisitTypeInfo($_POST['visit_type'])[0]["visittypes_name"]]; ?></td><td><?php echo $_POST['company']; ?></td><td><?php echo $_POST['lastname']; ?>, <?php echo $_POST['firstname']; ?><br><img src="<?php echo $_POST['v_signature']; ?>" width="200" height="50" /></td><td><?php if (!empty($_POST['escort'])): echo $_POST['escort']; endif; ?><br /><?php if (!empty($_POST['e_signature'])): ?><img src="<?php echo $_POST['e_signature']; ?>" width="200" height="50" /><?php endif; ?></td>
<td><?php echo $timenow; ?><br><?php echo $transLang[$VisitTypeInfo->getVisitTypeInfo(filter_input(INPUT_POST, 'visit_type', FILTER_SANITIZE_STRING))[0]["visittypes_name"]]; ?></td><td><?php echo filter_input(INPUT_POST, 'company', FILTER_SANITIZE_STRING); ?></td><td><?php echo filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_STRING); ?>, <?php echo filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING); ?><br><img src="<?php echo filter_input(INPUT_POST, 'v_signature', FILTER_SANITIZE_STRING); ?>" width="200" height="50" /></td><td><?php if (!empty(filter_input(INPUT_POST, 'escort', FILTER_SANITIZE_STRING))): echo filter_input(INPUT_POST, 'escort', FILTER_SANITIZE_STRING); endif; ?><br /><?php if (!empty(filter_input(INPUT_POST, 'e_signature', FILTER_SANITIZE_STRING))): ?><img src="<?php echo filter_input(INPUT_POST, 'e_signature', FILTER_SANITIZE_STRING); ?>" width="200" height="50" /><?php endif; ?></td>
</tr>
</tbody>
</table>

View File

@ -19,9 +19,11 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD
use App\LobbySIO\Misc\Csrf; // ANTICSRF
$StaticFunctions = new \App\LobbySIO\Misc\StaticFunctions(); // DEFAULT CLASSES
$SiteInfo = new \App\LobbySIO\Database\SiteInfo();
$Users = new \App\LobbySIO\Database\Users();
@ -47,7 +49,14 @@
require_once("inc/header.inc.php");
if ($StaticFunctions->getSessionStatus() == true) { // CHECK STATUS
header('Location: index.php'); // ELSE HOME
} else { ?>
} else {
header("X-Frame-Options: SAMEORIGIN");
header("Content-Security-Policy: frame-ancestors 'none'", false);
if (!empty($_GET['a'])) {
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo 'Verification has been : ' . (Csrf::verifyToken('home') ? 'successful' : 'unsuccessful');
}
?>
@ -90,6 +99,7 @@
</div>
</div>
<form class="form-signout" method="post" onsubmit="return confirm('<?php echo $transLang['END_VISIT_WARNING']; ?>')">
<?php echo Csrf::getInputToken('home') ?>
<ul class="pagination pagination-sm"><li class="page-item disabled"><a class="page-link" href="#" tabindex="-1"><?php echo $transLang['PAGE']; ?></a></li>
<?php for ($i = 1; $i <= $page_count; $i++): ?>
<li class="page-item<?php if ($i === $page_num): echo ' active'; else: echo ' '; endif; ?>"><a class="page-link" href="<?php echo $_SERVER['PHP_SELF'] . '?pnum=' . $i; ?>"><?php echo $i; ?></a></li>

175
src/Misc/Csrf.php Normal file
View File

@ -0,0 +1,175 @@
<?php
namespace App\LobbySIO\Misc;
class Csrf
{
/**
* Generates a new token
* @return [object] token
*/
protected static function setNewToken(string $page, int $expiry) {
$token = new \stdClass();
$token->page = $page;
$token->expiry = time() + $expiry;
$token->sessiontoken = base64_encode(random_bytes(32));
$token->cookietoken = md5(base64_encode(random_bytes(32)));
setcookie ( self::makeCookieName($page), $token->cookietoken, [
'expires' => $token->expiry,
'secure' => true,
'httponly' => true,
'samesite' => 'None',
]);
return $_SESSION['csrftokens'][$page] = $token;
}
/**
* Returns a session token for a page
* @param [string] page name
* @return [object] token
*/
protected static function getSessionToken(string $page) {
return !empty($_SESSION['csrftokens'][$page]) ? $_SESSION['csrftokens'][$page] : null;
}
/**
* [getCookieToken description]
* @param [string] page name
* @return [string] token string / empty string
*/
protected static function getCookieToken(string $page) : string {
$value = self::makeCookieName($page);
return !empty($_COOKIE[$value]) ? $_COOKIE[$value] : '';
}
/**
* Centralised method to make the cookie name
* @param [string] page name
* @return [string] cookie token name / empty string
*/
protected static function makeCookieName(string $page) : string {
if (empty($page)) {
return '';
}
return 'csrftoken-' . substr(md5($page), 0, 10);
}
/**
* Confirms that the superglobal $_SESSION exists
* @return [bool] Whether the session exists or not
*/
protected static function confirmSessionStarted() : bool {
if (!isset($_SESSION)) {
trigger_error('Session has not been started.', E_USER_ERROR);
return false;
}
return true;
}
/**
* Returns a page's token.
* - Page name is required so that users can browse to multiple pages and allows for each
* page to have its own unique token
*
* @param [string] page name
* @param [int] expiry time
* @return [mixed] markup to be used in the form, false on data missing
*/
public static function getInputToken(string $page, int $expiry = 1800) {
self::confirmSessionStarted();
if (empty($page)) {
trigger_error('Page is missing.', E_USER_ERROR);
return false;
}
$token = (self::getSessionToken($page) ?? self::setNewToken($page, $expiry));
return '<input type="hidden" id="csrftoken" name="csrftoken" value="'. $token->sessiontoken .'">';
}
/**
* Verify's a request token against a session token
* @param [string] page name
* @param [string] token from the request
* @return [bool] whether the request submission is valid or not
*/
public static function verifyToken(string $page, $removeToken = false, $requestToken = null) : bool {
self::confirmSessionStarted();
// if the request token has not been passed, check POST
$requestToken = ($requestToken ?? $_POST['csrftoken'] ?? null);
if (empty($page)) {
trigger_error('Page alias is missing', E_USER_WARNING);
return false;
}
else if (empty($requestToken)) {
trigger_error('Token is missing', E_USER_WARNING);
return false;
}
$token = self::getSessionToken($page);
// if the time is greater than the expiry form submission window
if (empty($token) || time() > (int) $token->expiry) {
self::removeToken($page);
return false;
}
// check the hash matches the Session / Cookie
$sessionConfirm = hash_equals($token->sessiontoken, $requestToken);
$cookieConfirm = hash_equals($token->cookietoken, self::getCookieToken($page));
// remove the token
if ($removeToken) {
self::removeToken($page);
}
// both session and cookie match
if ($sessionConfirm && $cookieConfirm) {
return true;
}
return false;
}
/**
* Removes a token from the session
* @param [string] $page page name
* @return [bool] successfully removed or not
*/
public static function removeToken(string $page) : bool {
self::confirmSessionStarted();
if (empty($page)) {
return false;
}
unset($_COOKIE[self::makeCookieName($page)], $_SESSION['csrftokens'][$page]);
return true;
}
} // Csrf

View File

@ -19,6 +19,7 @@
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set("session. cookie_httponly", 1);
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD