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
14 changes: 2 additions & 12 deletions thold.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,14 @@
case 'disable':
thold_threshold_disable(get_filter_request_var('id'));

if (isset($_SERVER['HTTP_REFERER'])) {
$return_to = $_SERVER['HTTP_REFERER'];
}else{
$return_to = 'thold.php';
}

$return_to = validate_redirect_url(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'thold.php');
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate_redirect_url() is not defined anywhere in this plugin repo, so this call will fatally error unless the hosting Cacti core version provides it. To avoid breaking installs on supported versions, either (a) bump/enforce the minimum Cacti version that includes validate_redirect_url(), or (b) guard with function_exists() and fall back to a local redirect-validator implementation.

Copilot uses AI. Check for mistakes.
header('Location: ' . $return_to . (strpos($return_to, '?') !== false ? '&':'?') . 'header=false');
Comment on lines +96 to 97
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change hardens redirects based on HTTP_REFERER, but autocreate still redirects to $_SESSION['data_return'] which is populated from HTTP_REFERER using only a regex match (e.g., an external URL ending in data_sources.php would still be accepted). For consistent open-redirect protection, validate/sanitize the referer when setting data_return and/or before issuing the Location: header in the autocreate branch.

Copilot uses AI. Check for mistakes.

exit;
case 'enable':
thold_threshold_enable(get_filter_request_var('id'));

if (isset($_SERVER['HTTP_REFERER'])) {
$return_to = $_SERVER['HTTP_REFERER'];
}else{
$return_to = 'thold.php';
}

$return_to = validate_redirect_url(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'thold.php');
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern here: calling validate_redirect_url() without ensuring it exists will cause a fatal error on Cacti versions that don't ship that helper. Consider enforcing the required Cacti version in setup.php/README or adding a function_exists() fallback.

Copilot uses AI. Check for mistakes.
header('Location: ' . $return_to . (strpos($return_to, '?') !== false ? '&':'?') . 'header=false');

exit;
Expand Down
Loading