security: fix RLIKE SQLi, XSS, integer casting, and dynamic dispatch#209
Open
somethingwithproof wants to merge 1 commit intoCacti:developfrom
Open
security: fix RLIKE SQLi, XSS, integer casting, and dynamic dispatch#209somethingwithproof wants to merge 1 commit intoCacti:developfrom
somethingwithproof wants to merge 1 commit intoCacti:developfrom
Conversation
Fix RLIKE SQL injection in db_functions.php by wrapping
get_request_var('rfilter') with db_qstr() instead of manual
string concatenation. This is guest-accessible when monitor.php
sets $guest_account=true.
Add html_escape() to all hidden input value attributes in
monitor_controller.php to prevent reflected XSS.
Add html_escape() to host description and hostname in email
notification body in poller_functions.php to prevent stored
XSS via rogue SNMP device responses.
Add (int) cast to integer request vars (crit, site) before
SQL concatenation in db_functions.php as defense-in-depth.
Add allowlist validation for the grouping parameter before
dynamic function dispatch in monitor_controller.php. Only
default, tree, site, and template are permitted.
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Monitor plugin against injection and XSS issues by sanitizing request-driven dynamic behavior, escaping untrusted output, and tightening SQL predicate construction in core query helpers.
Changes:
- Escapes host description/hostname in reboot notification HTML output to prevent stored XSS in email clients.
- Adds HTML escaping to hidden filter inputs to prevent reflected XSS via request parameters.
- Mitigates SQL injection in
RLIKEfiltering and adds defense-in-depth integer casting for SQL concatenation; introduces grouping allowlist before dynamic render dispatch.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
poller_functions.php |
Escapes host fields in reboot notification HTML table output. |
monitor_controller.php |
Adds grouping allowlist for dynamic renderer dispatch; escapes hidden filter input values. |
db_functions.php |
Hardens SQL where/join construction (casts numeric filters; quotes RLIKE pattern via db_qstr). |
Comments suppressed due to low confidence (1)
monitor_controller.php:115
- After computing the sanitized
$grouping, this block still checksget_request_var('grouping')when deciding whichhtml_start_box()title to use. If the request contains an invalid grouping, rendering will use$groupingbut the header/title logic will follow the raw value. Use$groupingconsistently here (orset_request_var('grouping', $grouping)) to keep behavior coherent.
$function = 'render' . ucfirst($grouping);
if (function_exists($function) && get_request_var('view') != 'list') {
if (get_request_var('grouping') == 'default' || get_request_var('grouping') == 'site') {
html_start_box(__('Monitored Devices', 'monitor'), '100%', true, 3, 'center', '');
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
db_functions.php:113by usingdb_qstr()instead of string concatenation. Guest-accessible when$guest_account=true.html_escape()to 5 hidden input value attributes inmonitor_controller.phpto prevent reflected XSShtml_escape()to host description/hostname in email notification body (poller_functions.php) to prevent stored XSS via SNMP(int)cast tocritandsiterequest vars before SQL concatenation as defense-in-depthdefault,tree,site,template) for thegroupingparameter before dynamic function dispatchTest plan