Accounts: Add missing CSRF checks

This commit is contained in:
johnnyq
2026-03-02 17:35:18 -05:00
parent 3d80d1519e
commit 550980719e
2 changed files with 15 additions and 8 deletions

View File

@@ -21,8 +21,9 @@ ob_start();
</button> </button>
</div> </div>
<form action="post.php" method="post" autocomplete="off"> <form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="account_id" value="<?php echo $account_id; ?>">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>"> <input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
<input type="hidden" name="account_id" value="<?php echo $account_id; ?>">
<div class="modal-body"> <div class="modal-body">
<div class="form-group"> <div class="form-group">
<label>Account Name <strong class="text-danger">*</strong></label> <label>Account Name <strong class="text-danger">*</strong></label>

View File

@@ -8,9 +8,11 @@ defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
if (isset($_POST['add_account'])) { if (isset($_POST['add_account'])) {
enforceUserPermission('module_financial', 2);
validateCSRFToken($_POST['csrf_token']); validateCSRFToken($_POST['csrf_token']);
enforceUserPermission('module_financial', 2);
$name = sanitizeInput($_POST['name']); $name = sanitizeInput($_POST['name']);
$opening_balance = floatval($_POST['opening_balance']); $opening_balance = floatval($_POST['opening_balance']);
$currency_code = sanitizeInput($_POST['currency_code']); $currency_code = sanitizeInput($_POST['currency_code']);
@@ -28,9 +30,10 @@ if (isset($_POST['add_account'])) {
if (isset($_POST['edit_account'])) { if (isset($_POST['edit_account'])) {
enforceUserPermission('module_financial', 2);
validateCSRFToken($_POST['csrf_token']); validateCSRFToken($_POST['csrf_token']);
enforceUserPermission('module_financial', 2);
$account_id = intval($_POST['account_id']); $account_id = intval($_POST['account_id']);
$name = sanitizeInput($_POST['name']); $name = sanitizeInput($_POST['name']);
$notes = sanitizeInput($_POST['notes']); $notes = sanitizeInput($_POST['notes']);
@@ -47,9 +50,10 @@ if (isset($_POST['edit_account'])) {
if (isset($_GET['archive_account'])) { if (isset($_GET['archive_account'])) {
validateCSRFToken($_GET['csrf_token']);
enforceUserPermission('module_financial', 2); enforceUserPermission('module_financial', 2);
validateCSRFToken($_GET['csrf_token']);
$account_id = intval($_GET['archive_account']); $account_id = intval($_GET['archive_account']);
$account_name = sanitizeInput(getFieldById('accounts', $account_id, 'account_name')); $account_name = sanitizeInput(getFieldById('accounts', $account_id, 'account_name'));
@@ -67,6 +71,8 @@ if (isset($_GET['archive_account'])) {
// Not used anywhere? // Not used anywhere?
if (isset($_GET['delete_account'])) { if (isset($_GET['delete_account'])) {
validateCSRFToken($_GET['csrf_token']);
enforceUserPermission('module_financial', 3); enforceUserPermission('module_financial', 3);
$account_id = intval($_GET['delete_account']); $account_id = intval($_GET['delete_account']);