hardening: prepared statements, path containment, and output escaping - #153
Open
somethingwithproof wants to merge 10 commits into
Open
hardening: prepared statements, path containment, and output escaping#153somethingwithproof wants to merge 10 commits into
somethingwithproof wants to merge 10 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the RouterConfigs Cacti plugin by reducing injection/XSS risk and tightening a few correctness issues across UI pages, upgrade logic, and credential handling.
Changes:
- Convert several SQL calls to prepared statements and cast numeric parameters where applicable.
- Escape user-/device-sourced output in UI views (device debug/config, accounts, device types, compare selectors).
- Add stricter file-path handling for backup reads and safer credential decoding (
unserializewithallowed_classes=false), plus small typo/HTML tag fixes.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
Text/Exception/Pear.php |
Replace legacy isset() ternaries with ?? and fix “unkown” typo. |
setup.php |
Parameterize realm migration and plugin version update queries; use ??= for poller interval default. |
router-download.php |
Use ??= / ?? for cleaner defaults in CLI option parsing. |
router-devtypes.php |
Escape rendered fields; parameterize paging query; safer ID handling in action list rendering. |
router-devices.php |
Fix mismatched heading tag; escape debug output and parameterize device lookup in edit path. |
router-compare.php |
Escape option labels, normalize option values, add file path validation and fix wrong backup-id message. |
include/functions.php |
Harden IN-clause ID handling; safer credential decode; add file-path validation + escape config output. |
This was referenced Apr 11, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Add targeted tests for prepared statement migration, output escaping, auth guard presence, CSRF token validation, redirect safety, and PHP 7.4 compatibility. Tests use source-scan patterns that verify security invariants without requiring the Cacti database. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
somethingwithproof
force-pushed
the
fix/hardening-150
branch
from
July 14, 2026 10:47
90f104e to
9921742
Compare
netniV
previously approved these changes
Aug 16, 2026
Member
|
@somethingwithproof There are a bunch of conflicts on this PR. |
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
# Conflicts: # include/functions.php # router-accounts.php # router-devtypes.php
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.
Security fixes for the Router Configs UI. Scoped to plugin code; the Pest scaffold that was in this branch has been dropped, and the vendored Horde exception class is left untouched.
intvalon the device IN-list, replacing interpolated ids.basename()on the filename, thenrealpath()compared against the base directory plus a separator. A bare prefix test also accepts a sibling such asbackups-evil.html_escapeon device hostname, address, directory, filename, and the rendered config body.unserialize()withallowed_classes => falseplus a structure check on the decoded credential, and the debug log that printed its shape is gone.The apt line drops
libapache2-mod-php, which conflicts with the version setup-php installs.Note for release planning: these are post-authentication issues, reachable by any account holding the Router Configs realm, but SQL injection and arbitrary file read are not low impact. The diff is already public, so the useful move is to land and ship rather than close.