fix(security): comprehensive bug and security cleanup#302
Open
somethingwithproof wants to merge 2 commits intoCacti:developfrom
Open
fix(security): comprehensive bug and security cleanup#302somethingwithproof wants to merge 2 commits intoCacti:developfrom
somethingwithproof wants to merge 2 commits intoCacti:developfrom
Conversation
TheWitness
requested changes
Apr 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR performs a security hardening and bug-fix sweep across the Syslog plugin, focusing on preventing destructive upgrades, reducing SQL injection surfaces, and removing unsafe client-side execution.
Changes:
- Prevents unintended table drops during setup/upgrade and fixes DST-related partition boundary calculation.
- Hardens several SQL paths by quoting/parameterizing user-controlled inputs and CRUD operations.
- Removes
eval()usage from the autocomplete callback flow and introduces CSV-safety scaffolding.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
setup.php |
Adjusts syslog_reports drop condition during setup to avoid accidental data loss. |
functions.php |
Fixes partition boundary calculation and adds a CSV-safety helper (currently problematic). |
syslog.php |
Wraps RLIKE filter input in db_qstr() to reduce SQL injection risk via rfilter. |
syslog_alerts.php |
Converts alert rule delete/enable/disable to prepared statements. |
syslog_removal.php |
Converts removal rule delete/enable/disable to prepared statements. |
syslog_reports.php |
Converts report rule delete to a prepared statement (but enable/disable still unparameterized). |
js/functions.js |
Replaces eval() callback execution with function reference lookup. |
Comments suppressed due to low confidence (1)
syslog_reports.php:329
- Only
api_syslog_report_remove()was converted to a prepared statement.api_syslog_report_disable()andapi_syslog_report_enable()still concatenate$iddirectly into SQL, which is inconsistent with the hardening in this PR and reintroduces an injection surface for future callers. Convert both tosyslog_db_execute_prepared(... WHERE id = ?)(and/orintval($id)), matching the other CRUD helpers.
syslog_db_execute_prepared("DELETE FROM `" . $syslogdb_default . "`.`syslog_reports` WHERE id = ?", array(intval($id)));
}
function api_syslog_report_disable($id) {
global $syslogdb_default;
syslog_db_execute('UPDATE `' . $syslogdb_default . "`.`syslog_reports` SET enabled='' WHERE id=" . $id);
}
function api_syslog_report_enable($id) {
global $syslogdb_default;
syslog_db_execute('UPDATE `' . $syslogdb_default . "`.`syslog_reports` SET enabled='on' WHERE id=" . $id);
}
TheWitness
previously approved these changes
Apr 9, 2026
Member
TheWitness
left a comment
There was a problem hiding this comment.
I'm going to approve this, but we will need to move that escaping to dompurify and change the way the unit tests operate as mentioned separately.
js/functions.js
Outdated
| /** | ||
| * Clear filter for statistics view | ||
| */ | ||
| // Escape HTML special characters to prevent XSS |
Member
There was a problem hiding this comment.
Should use dompurify here. It's in the base.
xmacan
approved these changes
Apr 9, 2026
xmacan
previously approved these changes
Apr 9, 2026
bmfmancini
previously approved these changes
Apr 9, 2026
- CRITICAL: prevent syslog_reports table DROP on upgrade (Cacti#300) - HIGH: parameterize domain stripping SQL (Cacti#261) - HIGH: wrap RLIKE filter values with db_qstr in syslog.php - MEDIUM: add CSV formula injection protection in exports (Cacti#256) - MEDIUM: sanitize DOM insertions with DOMPurify - LOW: parameterize admin CRUD delete/enable/disable (Cacti#252) - LOW: fix DST partition boundary using strtotime (Cacti#199) Closes Cacti#199, Cacti#252, Cacti#256, Cacti#259, Cacti#260, Cacti#261, Cacti#300 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
da6d22e
a65362d to
da6d22e
Compare
- Convert remaining db_qstr() RLIKE calls to prepared statements - Fix OR-clause parenthesization in WHERE conditions - Expand CSV injection regex to include / and \n per OWASP - Add strlen <= 255 ReDoS guard on RLIKE input - Convert setup.php raw SQL to prepared statement Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
TheWitness
reviewed
Apr 9, 2026
| $cformat = 'd' . date('Ymd', $time); | ||
| $lnow = date('Y-m-d', $time+86400); | ||
| $cformat = 'd' . gmdate('Ymd', $time); | ||
| $lnow = gmdate('Y-m-d', strtotime('+1 day', $time)); |
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
Security and bug fixes across 7 files. Each fix is minimal and targeted. All files pass php -l lint. Independently reviewed by Grok (xAI) for correctness, regressions, and remaining gaps.
Fixes
CRITICAL
if ($truncate || !$newreport)caused DROP even when truncate was false, destroying user report rules. Changed toif ($truncate)only. (Syslog table drop with no apparent reason #300)HIGH
MEDIUM
LOW
Files changed
Test plan
Closes #199, #252, #256, #259, #260, #261, #300