hardening: enforce POST+CSRF for purge syslog devices utility - #318
hardening: enforce POST+CSRF for purge syslog devices utility#318somethingwithproof wants to merge 19 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the Syslog plugin’s destructive purge_syslog_hosts utilities action to mitigate CSRF risk by requiring a CSRF-protected POST, and updates the UI flow to submit a POST (instead of a GET link). It also adds a regression script to guard against reintroducing the insecure behavior.
Changes:
- Enforce
POSTand validate CSRF viacsrf_check(false)before executing the purge deletes. - Replace the utilities GET link with a jQuery UI confirmation dialog that submits a POST including
__csrf_magic. - Add a regression script asserting the hardening behavior and related UI/encoding expectations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| setup.php | Adds POST+CSRF enforcement for purge action; replaces purge link with a dialog-driven POST flow including CSRF token. |
| tests/regression/issue259_csrf_purge_test.php | Adds a regression script that scans setup.php for required hardening snippets and safe UI/JS encoding patterns. |
f595568 to
75e4ad6
Compare
|
@TheWitness could you take a look? This is the re-opened CSRF+POST hardening for the purge devices utility (original #265), now rebased onto develop. All merge conflicts resolved. |
c65ad70 to
e49592a
Compare
Refs Cacti#259 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…eader - Distinct raise_message IDs per failure mode (syslog_method_error, syslog_csrf_error, syslog_csrf_unavailable) so log triage can differentiate non-POST, invalid token, and missing-helper paths - Add cacti_log entry on the non-POST rejection path so the audit trail is symmetric with the other two fail-closed branches - Document csrf_check($fatal=false) arg semantics inline so future readers see the helper contract - Rename the regression test comment block to call out explicitly that it is a source-scan lint, not a behavioral test; flag follow-up for real behavioral coverage once a DB-backed test harness exists Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Three defects, all failing open or failing at setup:
- the plugin syntax check redirected find's own output rather than php's, so
PHP errors never reached the grep testing for them; the step could not fail
- MYSQL_AUTH_USR carried a literal tilde, because parameter expansion happens
after tilde expansion, so MySQL was handed a path it could not resolve
- the Cacti checkout took the default branch, which is 1.3 in development and
whose CLI installer currently fatals with an undefined __()
plugin_syslog additionally installed libapache2-mod-php${{ matrix.php }},
which Ubuntu does not package, so apt exited 100 before Cacti was reached.
Verified with actionlint, which is clean on the result.
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Drops the typed signature to match the rest of functions.php, where no function declares parameter or return types. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The install form in this file already appends header=false, and the redirect targets need it too or the XHR renders a full page into the content tab. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The issue#279 XSS fix is unrelated to the purge CSRF guard and moves to its own branch. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Every assertion passed while the purge was broken, and two of them rejected correct fixes; the guard and the fragment are now exercised for real. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Every other close tag in the tree is '; ?>'; these five were the only exceptions. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
0d234f1 to
ccf0c99
Compare
|
Renamed to On whether the Also in this push: the purge post and its redirects now carry |
Addressed in the syslog_json_safe() helper, used as syslog_json_safe(__('Devices Selected', 'syslog')).
Summary
Enforces POST and CSRF validation before the purge utility can delete unused Syslog host records.
Security behavior
Validation
Compatibility
Uses existing Cacti plugin conventions and PHP 7.4-compatible syntax.