Skip to content

chore(security): harden report actions and theme handling#7169

Open
somethingwithproof wants to merge 13 commits into
Cacti:developfrom
somethingwithproof:fix/security-ghsa-parity-develop
Open

chore(security): harden report actions and theme handling#7169
somethingwithproof wants to merge 13 commits into
Cacti:developfrom
somethingwithproof:fix/security-ghsa-parity-develop

Conversation

@somethingwithproof

Copy link
Copy Markdown
Contributor

Summary

  • harden reports_form_actions() with per-item authorization checks before bulk mutations
  • add cacti_validate_theme() and apply it to graph theme inputs and RRD theme resolution paths
  • harden remote agent auth flow with DNS forward-verification and safer auth-cache behavior
  • update bundled DOMPurify to the latest upstream release (3.4.7)

Notes

  • scoped as hardening parity across security-sensitive paths already tightened in 1.2.x
  • no API surface changes; behavior changes are limited to rejecting unauthorized/invalid inputs

Copilot AI review requested due to automatic review settings May 28, 2026 02:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Hardens remote agent authentication, validates graph theme inputs to prevent path traversal, and adds ownership/authorization checks to report bulk actions.

Changes:

  • Rewrites remote_client_authorized() to validate against poller hostnames first (with APCu-backed result caching), and adds forward/reverse DNS checks only as a secondary path.
  • Adds a new cacti_validate_theme() helper and applies it everywhere graph themes are read from user input.
  • Adds an owner/admin authorization check to the reports bulk-action handler and switches to sanitize_unserialize_selected_items().

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
remote_agent.php Reworks remote agent auth with poller list pre-filtering and APCu cache; validates theme input.
lib/rrd.php Uses cacti_validate_theme() when resolving the rrdtheme.php path.
lib/html_reports.php Adds per-report ownership check in bulk actions; switches to sanitized unserialize.
lib/functions.php Adds cacti_validate_theme() helper that scans the themes directory.
graph_json.php Validates graph_theme request value via cacti_validate_theme().
graph_image.php Validates graph_theme request value via cacti_validate_theme().
Files not reviewed (1)
  • include/js/purify.js: Language not supported

Comment thread remote_agent.php Outdated
Comment thread lib/functions.php Outdated
Comment thread lib/html_reports.php Outdated
Comment thread remote_agent.php Outdated
Comment thread remote_agent.php
TheWitness
TheWitness previously approved these changes May 28, 2026
@somethingwithproof

Copy link
Copy Markdown
Contributor Author

Rebased onto develop (picks up #7188) and reverted the off-topic exec changes in poller_spikekill / script_server / snmpagent_persist / snmpagent_mibcache / support. Those had been switched to 1.2.x-style cacti_exec(), which is undefined on develop and was failing phpstan; restored develop's native exec() idiom. The PR now stays scoped to report actions and theme handling. phpstan level 6 and php-cs-fixer are clean locally.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Move whitelist check before the single-poller guard so single-poller
installs relying on the whitelist are not incorrectly rejected.

Narrow SELECT * to SELECT hostname; the loop only reads hostname.

Drop function_exists guards around md5/hash; both are PHP core and the
raw $cache_seed fallback is unsafe as an APCu key.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…e_theme

read_config_option can return false or null when the setting is absent.
Without the cast, a strict comparison to '' would not match, leaving
$default unset and risking a null-typed value flowing into callers.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Replace input_validate_input_number (which calls die_html_input_error
on bad input, aborting the entire bulk action) with an inline guard.
Cast $report_id to int at call sites where the signature requires int.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
- Refactored poller_spikekill.php to use array-based execution and sanitized SQL IN clauses.
- Refactored script_server.php Windows process check to use cacti_exec.
- Hardened snmpagent background process lifecycles.
- Standardized version checks in support.php and utilities.php.
- Replaced short array syntax [] with array() and verified 7.4 compatibility.
- Synchronized all hardened files to primary developer path.
…ackground()

cacti_process_execute() was called but never defined, causing a PHP fatal.
Replaced with exec_background() from lib/poller.php. Also fix pre-existing
parse error in snmpagent_persist.php ([ closed with ) instead of ]).

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
php-cs-fixer (array_syntax/list_syntax short) flagged array() introduced
on this branch; convert to [] so the coding-standards gate passes.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
poller_spikekill, script_server, snmpagent_persist/mibcache and support
had been switched to 1.2.x-style cacti_exec(), which is undefined on
develop and failed phpstan. Restore develop's native exec() idiom; these
files are outside this PR's scope (report actions and theme handling).

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
phpstan 2.2.2 added a stricter is_numeric() always-true inference that
fails on pre-existing develop code (lib/data_query.php); pin until that
is addressed upstream so CI is reproducible.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof somethingwithproof force-pushed the fix/security-ghsa-parity-develop branch from 3dc14e7 to ea87cce Compare June 14, 2026 20:43
Clears the level 6 alreadyNarrowedType error on lib/data_query.php:2591 that
develop currently emits, matching the sibling narrowing identifiers already ignored.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
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.

3 participants