Security hardening: CSRF, rate limiting, session/password policy, audit log
Fixes critical pre-existing issues found during review: bulk_action.php had no auth check at all (unauthenticated download/delete of any qrcode) and built a table name from unwhitelisted user input (SQL injection); the QR generator classes wrote files from unvalidated filename/format, allowing path traversal and arbitrary file writes. Also pins chillerlan/php-qrcode to 5.0.5 since master now requires PHP 8.4, breaking the PHP 8.3 build. - CSRF tokens on all POST forms and the bulk_action.php JSON endpoint - Login rate limiting (5 attempts / 15 min) via new login_attempts table - Hardened sessions: httponly/samesite cookies, 30 min idle timeout, session regeneration on login - Forced password change for the default superadmin/superadmin account - Server-side validation in Users/DynamicQrcode/Qrcode classes - Audit log table for auth, user, and qrcode actions - Checked-in db schema (db/init.sql, migrations/) instead of relying on an opaque prebuilt db image - Production docker-compose with Nginx + php-fpm instead of the PHP dev server
This commit is contained in:
+5
-2
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'config/config.php';
|
||||
require_once 'includes/bootstrap.php';
|
||||
require_once BASE_PATH . '/includes/auth_validate.php';
|
||||
require_once BASE_PATH . '/lib/Users/Users.php';
|
||||
|
||||
@@ -9,6 +8,9 @@ $user_instance = new Users();
|
||||
if ($_SESSION['type'] !== 'super')
|
||||
$user_instance->failure('Only a "super admin" account can access the admin listing page', 'Location: index.php');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
csrf_verify_or_die();
|
||||
}
|
||||
|
||||
$edit = false;
|
||||
if($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["edit"]) && $_GET["edit"] == "true" && isset($_GET["id"])) {
|
||||
@@ -83,6 +85,7 @@ if($_SERVER["REQUEST_METHOD"] === "POST" && !isset($_POST["edit"])) {
|
||||
<h3 class="card-title">Enter the requested data</h3>
|
||||
</div>
|
||||
<form class="well form-horizontal" action="" method="post" id="contact_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<div class="card-body">
|
||||
<?php include BASE_PATH . '/forms/form_users.php'; ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user