Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

SNYK: Sanitize and bind ACL actions queries 21.10.x #11548

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions www/include/options/accessLists/actionsACL/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,24 @@ function multipleActionInDB($actions = array(), $nbrDup = array())
$query = "SELECT DISTINCT acl_group_id,acl_action_id FROM acl_group_actions_relations " .
" WHERE acl_action_id = '" . $key . "'";
$dbResult = $pearDB->query($query);
$query = "INSERT INTO acl_group_actions_relations VALUES (:acl_action_id, :acl_group_id)";
$statement = $pearDB->prepare($query);
while ($cct = $dbResult->fetch()) {
$query = "INSERT INTO acl_group_actions_relations VALUES ('" .
$maxId["MAX(acl_action_id)"] . "', '" . $cct["acl_group_id"] . "')";
$pearDB->query($query);
$statement->bindValue(':acl_action_id', (int) $maxId["MAX(acl_action_id)"], \PDO::PARAM_INT);
$statement->bindValue(':acl_group_id', (int) $cct["acl_group_id"], \PDO::PARAM_INT);
$statement->execute();
}

# Duplicate Actions
$query = "SELECT acl_action_rule_id,acl_action_name FROM acl_actions_rules " .
"WHERE acl_action_rule_id = '" . $key . "'";
$dbResult = $pearDB->query($query);
$query = "INSERT INTO acl_actions_rules VALUES (NULL, :acl_action_id, :acl_action_name)";
$statement = $pearDB->prepare($query);
while ($acl = $dbResult->fetch()) {
$query = "INSERT INTO acl_actions_rules VALUES (NULL, '" . $maxId["MAX(acl_action_id)"] .
"', '" . $acl["acl_action_name"] . "')";
$pearDB->query($query);
$statement->bindValue(':acl_action_id', (int) $maxId["MAX(acl_action_id)"], \PDO::PARAM_INT);
$statement->bindValue(':acl_action_name', $acl["acl_action_name"], \PDO::PARAM_STR);
$statement->execute();
}

$dbResult->closeCursor();
Expand Down Expand Up @@ -298,8 +302,10 @@ function updateGroupActions($aclActionId, $ret = array())
}
global $form, $pearDB;

$rq = "DELETE FROM acl_group_actions_relations WHERE acl_action_id = '" . $aclActionId . "'";
$dbResult = $pearDB->query($rq);
$rq = "DELETE FROM acl_group_actions_relations WHERE acl_action_id = :acl_action_id";
$statement = $pearDB->prepare($rq);
$statement->bindValue(':acl_action_id', (int) $aclActionId, \PDO::PARAM_INT);
$statement->execute();
if (isset($_POST["acl_groups"])) {
foreach ($_POST["acl_groups"] as $id) {
$rq = "INSERT INTO acl_group_actions_relations ";
Expand All @@ -325,8 +331,10 @@ function updateRulesActions($aclActionId, $ret = array())
return;
}

$rq = "DELETE FROM acl_actions_rules WHERE acl_action_rule_id = '" . $aclActionId . "'";
$dbResult = $pearDB->query($rq);
$rq = "DELETE FROM acl_actions_rules WHERE acl_action_rule_id = :acl_action_rule_id";
$statement = $pearDB->prepare($rq);
$statement->bindValue(':acl_action_rule_id', (int) $aclActionId, \PDO::PARAM_INT);
$statement->execute();

$actions = array();
$actions = listActions();
Expand Down