Skip to content

hardening: migrate RLIKE to db_qstr and improve input handling#762

Open
somethingwithproof wants to merge 4 commits intoCacti:developfrom
somethingwithproof:fix/hardening-prepared-statements
Open

hardening: migrate RLIKE to db_qstr and improve input handling#762
somethingwithproof wants to merge 4 commits intoCacti:developfrom
somethingwithproof:fix/hardening-prepared-statements

Conversation

@somethingwithproof
Copy link

@somethingwithproof somethingwithproof commented Mar 20, 2026

Summary

Hardening

  • Convert all RLIKE string interpolation to db_qstr() (11 locations)
  • Migrate notify_lists.php bulk operations from db_execute with string
    concatenation to db_execute_prepared with parameter binding
  • Convert DELETE plugin_thold_threshold_contact to prepared statement
  • Add intval() guards to get_request_var() values concatenated into
    WHERE clauses in thold.php and thold_graph.php (data_template_id,
    thold_template_id, site_id, host_id)
  • Use sanitize_unserialize_selected_items for form data deserialization
  • Apply html_escape to drp_action hidden form fields

CI

  • Convert test stub indentation from spaces to tabs (php-cs-fixer)
  • Drop unreachable --min=80 coverage threshold (plugin source files
    cannot be loaded without the Cacti framework)

No behavioral changes. Defense-in-depth hardening only.

Linter reverted thold_graph.php and thold_webapi.php changes from the
previous commit. Re-apply: db_qstr() for all RLIKE patterns in thold_graph,
sanitize_unserialize_selected_items in thold_webapi.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
- Convert all RLIKE string interpolation to db_qstr() across
  notify_lists.php, thold.php, thold_graph.php (11 locations)
- Use sanitize_unserialize_selected_items for form data deserialization
  in thold_webapi.php
- Apply html_escape to drp_action hidden form fields in notify_lists.php

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
TheWitness
TheWitness previously approved these changes Mar 23, 2026
@TheWitness
Copy link
Member

@somethingwithproof, please fix the automation and this is ready to merge.

…verage gate

Convert test stub and security test files from spaces to tabs to
match the project's php-cs-fixer configuration. Remove --min=80
coverage threshold from CI; the plugin source files cannot be loaded
without the Cacti framework, making 80% unit test coverage
unreachable.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…val guards

- Convert notify_lists.php associate/disassociate bulk queries from
  db_execute with string concatenation to db_execute_prepared with
  parameter binding
- Convert DELETE plugin_thold_threshold_contact to prepared statement
- Add intval() guards to get_request_var() values concatenated into
  WHERE clauses in thold.php and thold_graph.php (data_template_id,
  thold_template_id, site_id, host_id)

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