Skip to content
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
20 changes: 19 additions & 1 deletion admin/security_center.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,25 @@

if (isset($_GET['extra_where']) && $_GET['extra_where'] !== '')
{
$where_clauses[] = $_GET['extra_where'];
$extra_where = trim($_GET['extra_where']);

// Only accept simple, safe conditions on the login attempts table (la).
// Allow comparisons like:
// la.field = 'value'
// la.field LIKE 'value%'
// and simple AND/OR chaining of those conditions.
// This rejects arbitrary SQL (UNION, JOIN, subqueries, comments, semicolons, etc.)
$clause_pattern = "/^\s*(?:la\\.[A-Za-z0-9_]+\\s*(?:=|!=|<>|<|>|<=|>=|LIKE)\\s*'[^']*'\\s*)(?:\\s+(?:AND|OR)\\s+(?:la\\.[A-Za-z0-9_]+\\s*(?:=|!=|<>|<|>|<=|>=|LIKE)\\s*'[^']*'\\s*))*$/i";

if (preg_match($clause_pattern, $extra_where))
{
$where_clauses[] = $extra_where;
}
else
{
// Unsafe extra_where ignored to prevent SQL injection attempts
$page['warnings'][] = l10n('Ignored unsafe filter parameter');
}
}

$where_sql = count($where_clauses) > 0 ? 'WHERE '.implode("\n AND ", $where_clauses) : '';
Expand Down