Repository navigation
fix: use prepared statements for device-reported values and require POST for admin actions - #401
Merged
TheWitness merged 2 commits intoOct 23, 2026
Conversation
The interface, interface-graph, ARP, DHCP snooping and 802.1x scanners now bind the strings a device reports instead of building them into the SQL. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Rescan, site scan, enable and disable now refuse any other method with a 405, and js/mactrack.js posts them with the CSRF token and reports failures. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
TheWitness
approved these changes
Oct 23, 2026
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.


Description
This PR changes two things. First, the interface and interface-graph inserts in
lib/mactrack_functions.phpnow use prepared statements, as do the ARP, DHCP snooping and 802.1x inserts in the Cisco, Aruba AOS-CX, Enterasys N7, H3C/3Com and Extreme scanners. The rows, columns and duplicate-key handling are unchanged. A missing sysUptime is bound as'', as the old SQL inserted it, rather than NULL. Second, rescan, site scan, enable and disable now refuse anything other than POST with a 405.js/mactrack.jssends them as POST with__csrf_magicand shows Cacti's error dialog if the request fails.Motivation and Context
Device-reported values should reach the database as bound parameters. The four admin actions change state, and Cacti checks the CSRF token on POST requests only.
How Has This Been Tested?
php -lon PHP 7.4 is clean.lib/database.php, before and after the change. I did this on PHP 7.4 and 8.3 with Cacti 1.2.14, 1.2.25 and 1.2.31, with and without a NULL sysUptime. The table contents were identical in every run.Types of changes
This touches the same two statements as #400, so whichever merges second needs a rebase.