Skip to content

Commit 5533e6f

Browse files
fix(security): validate sort_column and sort_direction against ORDER BY injection
Validate in both get_order_string() and update_order_string() to prevent bypassing validation via cached session values. Restrict sort_direction to ASC/DESC, sort_column to alphanumeric/dots/underscores. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent 02acd9b commit 5533e6f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

remote_agent.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ function remote_client_authorized() {
145145

146146
$client_name = gethostbyaddr($client_addr);
147147

148+
/* Forward-verify PTR result to prevent DNS spoofing */
149+
if ($client_name != $client_addr) {
150+
$forward_addr = gethostbyname($client_name);
151+
if ($forward_addr !== $client_addr) {
152+
cacti_log('WARNING: PTR record for ' . $client_addr . ' resolves to ' . preg_replace('/[^a-zA-Z0-9.\-:]/', '', $client_name) . ' but forward lookup returns ' . $forward_addr . '. Rejecting.', false, 'AUTH');
153+
return false;
154+
}
155+
}
156+
148157
if ($client_name == $client_addr) {
149158
cacti_log('NOTE: Unable to resolve hostname from address ' . $client_addr, false, 'WEBUI', POLLER_VERBOSITY_MEDIUM);
150159
}

0 commit comments

Comments
 (0)