Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin lib SQL Injection fixes #228 #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions cms/admin.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ function setblacklist($domain="",$ip="")
function delete_blacklist()
{
$id = safe_html($_GET['del_black']);

if(!is_numeric($id))
{
// Check if "id" is a valid number
echo "<script>alert('Error finding blacklisted record');</script>";
return 0;
}

$query = "DELETE FROM `".MYSQL_DATABASE_PREFIX."blacklist` WHERE `id` = '$id'";
$result =mysqli_query($GLOBALS["___mysqli_ston"], $query) or displayerror("Unable to Delete blacklist". ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
if(mysqli_affected_rows($GLOBALS["___mysqli_ston"])>0)
Expand Down Expand Up @@ -336,6 +344,11 @@ function delDir($dirname) {
}

function getSuggestions($pattern) {

// This line prevents SQL injection by removing double
// quotes from the string
$pattern = str_replace('"', "", $pattern);

$suggestionsQuery = "SELECT IF(user_email LIKE \"$pattern%\", 1, " .
"IF(`user_fullname` LIKE \"$pattern%\", 2, " .
"IF(`user_fullname` LIKE \"% $pattern%\", 3, " .
Expand Down