Skip to content

fix filter SQLi and add CSRF protection to servcheck request handling #92

Description

@somethingwithproof

Two request-security fixes found in a review of the plugin (the first on this repo).

SQL injection via the filter search (CA, proxy, credential pages)

servcheck_ca.php, servcheck_proxy.php, and servcheck_credential.php registered the filter request variable as FILTER_DEFAULT (no sanitization) and concatenated it raw into a LIKE clause, so a servcheck-realm user could inject SQL through the filter GET parameter (the CA query was also malformed). servcheck_test.php already does this correctly with sanitize_search_string; this aligns the other three and additionally builds the LIKE value with db_qstr, closing the injection regardless of the sanitizer, and fixing the broken CA search.

CSRF on the enable / disable / purge GET actions

servcheck_test.php ran enable, disable, and purge (which deletes a check's log history) from a plain GET with no CSRF check — a crafted link could disable monitoring or purge history when an authenticated admin loaded it. The action now validates csrf_guard()->validate() against the __csrf_magic token, which the action links carry via csrf_get_tokens() (Cacti's own CSRF API; csrf_check() only guards POST).
Both post-auth (servcheck admin realm). php -l and php-cs-fixer clean; no behaviour change for a normal search or a legitimately-clicked action.


Tracking issue for #90, which carries the fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions