Skip to content

fix(security): defense-in-depth hardening for plugin_flowview#250

Open
somethingwithproof wants to merge 7 commits intoCacti:developfrom
somethingwithproof:fix/defense-in-depth
Open

fix(security): defense-in-depth hardening for plugin_flowview#250
somethingwithproof wants to merge 7 commits intoCacti:developfrom
somethingwithproof:fix/defense-in-depth

Conversation

@somethingwithproof
Copy link
Copy Markdown

Summary

Automated defense-in-depth hardening addressing 53 security audit findings.

  • XSS: Escape request variables in HTML value attributes with html_escape_request_var()
  • SQLi: Convert string-concatenated queries to prepared statements
  • Deserialization: Add allowed_classes => false to unserialize() calls
  • Temp files: Replace predictable rand() with tempnam()

All changes are PHP 7.0+ compatible for Cacti 1.2.x.

Test plan

  • PHP lint clean on all changed files
  • Verify plugin functionality after changes

Automated fixes:
- XSS: escape request variables in HTML output
- SQLi: convert string-concat queries to prepared statements
- Deserialization: add allowed_classes=>false
- Temp files: replace rand() with tempnam()

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Copilot AI review requested due to automatic review settings April 9, 2026 06:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Defense-in-depth hardening for the Flowview plugin by tightening request handling in UI links and reducing PHP object injection risk in DNS cache deserialization, plus introducing automated dependency update configuration.

Changes:

  • Restrict unserialize() behavior in Net_DNS2 caching code via allowed_classes => false.
  • Sanitize/coerce id request parameters to integers when interpolating into URLs/JS in Flowview UI pages.
  • Add a Dependabot configuration for GitHub Actions (and npm).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Net/DNS2/Cache/Shm.php Adds allowed_classes => false when unserializing shared-memory cache metadata.
Net/DNS2/Cache/File.php Adds allowed_classes => false when unserializing file cache metadata.
Net/DNS2/Cache.php Adds allowed_classes => false when unserializing cached DNS response objects.
flowview_schedules.php Coerces id to int via get_filter_request_var() for safer URL/JS interpolation.
flowview_devices.php Coerces id to int via get_filter_request_var() for safer URL interpolation.
.github/dependabot.yml Introduces Dependabot update schedules for npm and GitHub Actions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 79 to 83
if ($this->cache_serializer == 'json') {
return json_decode($this->cache_data[$key]['object']);
} else {
return unserialize($this->cache_data[$key]['object']);
return unserialize($this->cache_data[$key]['object'], array('allowed_classes' => false));
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unserialize(..., ['allowed_classes' => false]) will prevent cached DNS response objects from being rehydrated as their original Net_DNS2_* classes when cache_serializer is serialize (it will return __PHP_Incomplete_Class trees). That breaks the documented behavior that serialize mode preserves class info and can break consumers relying on instanceof or methods. Consider either (a) switching cache serialization to a safe non-object format (e.g., JSON) when caching is enabled, or (b) using an explicit allowlist of the specific Net_DNS2_* classes that can appear in cached responses instead of false.

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +7
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Dependabot config enables the npm ecosystem in /, but the repo does not contain a package.json (or lockfile) at the root. That will cause Dependabot update jobs to fail. Either remove the npm entry or point it at the directory that actually contains package.json (and commit the manifest if it’s intended to exist).

Suggested change
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10

Copilot uses AI. Check for mistakes.
Replace .click(fn) with .on('click', fn), .change(fn) with
.on('change', fn), .submit(fn) with .on('submit', fn), .unbind()
with .off(), and .resize(fn) with .on('resize', fn).

These shorthands were deprecated in jQuery 3.3 and will be removed
in jQuery 4.0. Cacti core ships jQuery 3.x on develop.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
- Change Dependabot ecosystem from npm to composer (PHP-only repo)
- Remove PHP from CodeQL paths-ignore so security PRs get analysis
- Remove committed .omc session artifacts, add .omc/ to .gitignore

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants