Skip to content

security: open redirect hardening (main)#771

Open
somethingwithproof wants to merge 1 commit intoCacti:mainfrom
somethingwithproof:security/backport-all-hardening-main
Open

security: open redirect hardening (main)#771
somethingwithproof wants to merge 1 commit intoCacti:mainfrom
somethingwithproof:security/backport-all-hardening-main

Conversation

@somethingwithproof
Copy link
Copy Markdown

Backports open redirect fixes by applying validate_redirect_url() to HTTP_REFERER redirects in thold.php.

Copilot AI review requested due to automatic review settings April 11, 2026 22:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Backports open-redirect hardening in the thold plugin by sanitizing redirects that use HTTP_REFERER in thold.php.

Changes:

  • Replaces direct $_SERVER['HTTP_REFERER'] redirects with validate_redirect_url() for the enable and disable actions.
  • Simplifies the referer/default selection logic into a single validated assignment.

$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.
$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.
Comment on lines +96 to 97
$return_to = validate_redirect_url(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'thold.php');
header('Location: ' . $return_to . (strpos($return_to, '?') !== false ? '&':'?') . 'header=false');
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants