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:
@@ -20,7 +20,7 @@
|
||||
<span class="input-group-text"><i class="fa fa-lock"></i></span>
|
||||
</div>
|
||||
|
||||
<input type="password" name="password" placeholder="Password" class="form-control" required="required" autocomplete="off">
|
||||
<input type="password" name="password" placeholder="<?php echo ($edit) ? 'Leave blank to keep current password' : 'Password'; ?>" class="form-control" <?php echo ($edit) ? '' : 'required="required"'; ?> minlength="10" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=2fa" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-12 mb-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=bitcoin" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-12 mb-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=bookmark" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-12 mb-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=email" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-12 mb-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=event" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-4">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=location" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-4">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=paypal" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-12 mb-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=phone" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-12 mb-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=skype" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-4">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=sms" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-12 mb-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=text" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-6">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=vcard" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<!-- First row -->
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=whatsapp" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-12 mb-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form class="form" action="static_qrcode.php?type=wifi" method="post" id="static_form" enctype="multipart/form-data">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php include BASE_PATH.'/forms/qrcode_options.php'; ?>
|
||||
<!-- Input forms -->
|
||||
<div class="col-sm-12 mb-2">
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<div id="err-msg"></div>
|
||||
<div class="bulk-action-wrapper">
|
||||
<form id="bulk-action" action="bulk_action.php" method="POST">
|
||||
<?php echo csrf_field(); ?>
|
||||
<div class="col-sm-12 mb-2" style="margin-left: 10px">
|
||||
<div class="row">
|
||||
<div class="col-5 col-md-2">
|
||||
@@ -100,6 +101,7 @@
|
||||
<div class="modal fade" id="delete-modal" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<form action="dynamic_qrcode.php" method="POST">
|
||||
<?php echo csrf_field(); ?>
|
||||
<!-- Modal content -->
|
||||
|
||||
<div class="modal-content">
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<div id="err-msg"></div>
|
||||
<div class="bulk-action-wrapper">
|
||||
<form id="bulk-action" action="bulk_action.php" method="POST">
|
||||
<?php echo csrf_field(); ?>
|
||||
<div class="col-sm-12 mb-2" style="margin-left: 10px">
|
||||
<div class="row">
|
||||
<div class="col-5 col-md-2">
|
||||
@@ -96,6 +97,7 @@
|
||||
<div class="modal fade" id="delete-modal" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<form action="static_qrcode.php" method="POST">
|
||||
<?php echo csrf_field(); ?>
|
||||
<!-- Modal content -->
|
||||
|
||||
<div class="modal-content">
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
<div class="modal fade" id="delete-modal" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<form action="user.php" method="POST">
|
||||
<?php echo csrf_field(); ?>
|
||||
<!-- Modal content -->
|
||||
|
||||
<div class="modal-content">
|
||||
|
||||
Reference in New Issue
Block a user