/

CVE-2026-39955

Severity:

CRITICAL RISK

(9.8)

Pre-auth SQL Injection (CWE-89) in Cacti graph_view.php

CVE-2026-39955

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database Compromise and Application Takeover

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Cacti versions 1.2.30 and earlier contain a pre-authentication SQL injection vulnerability in graph_view.php due to unsafe input validation with FILTER_VALIDATE_REGEXP.

An attacker can send crafted requests to manipulate database queries before login, potentially leading to data exposure, modification, or full application compromise.

Affected context

The vulnerability occurs in Cacti's web interface, specifically within the graph_view.php functionality that handles user-supplied parameters for viewing performance graphs.

It is present when requests are processed using FILTER_VALIDATE_REGEXP without strict anchoring or sanitization, allowing attacker-controlled data to influence SQL query construction.

Deployments exposing Cacti to untrusted networks or shared environments are at higher risk, especially when the application connects to a database with broad privileges.

Exploit preconditions

  • Attack surface: HTTP(S) requests to the Cacti web interface, targeting graph_view.php.
  • Required access: None; exploitation can occur pre-authentication from any client able to reach the application.
  • Trigger point: Processing of crafted query parameters that pass through FILTER_VALIDATE_REGEXP and into SQL query building.
  • Why exploitation is possible: The regular expression validation is unanchored and insufficiently strict, so attacker-controlled input can introduce additional SQL tokens or clauses that are concatenated into dynamic queries without parameterization.

Why this happens

The underlying bug is a classic SQL injection pattern where user input is incorporated into SQL statements without proper parameterization or escaping.

Cacti relies on FILTER_VALIDATE_REGEXP for input validation, but the regex is unanchored and does not fully constrain allowable characters and patterns.

As a result, user-supplied data can alter the structure of the SQL query rather than being treated as pure data, mapping directly to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

Potential impact

  • An attacker may read sensitive data from Cacti's database, including configuration and monitoring information.
  • An attacker may modify or delete monitoring data and configuration entries.
  • An attacker could create or alter administrative accounts indirectly through the database.
  • An attacker can potentially execute further attacks on the underlying system if the database user has extended privileges (e.g., file access or stored procedures).
  • The monitoring environment and associated infrastructure could be misconfigured or blinded, impacting operational visibility.

General mitigation guidance

Mitigation generally focuses on eliminating dynamic SQL that directly incorporates user input and strengthening validation boundaries.

Recommended patterns include:

  • Using parameterized queries or prepared statements for all database access paths, treating inputs strictly as parameters.
  • Applying allowlist-based validation for request parameters, with anchored regular expressions that explicitly constrain acceptable formats.
  • Segregating database privileges so the application account has minimal rights necessary for its operation.
  • Introducing defensive layers such as application firewalls or query builders that make injection structurally difficult.
  • Designing monitoring endpoints so that unauthenticated users have limited or no direct interaction with query-building logic.

How teams detect issues like this

Detection typically combines code-level inspection and runtime monitoring.

Approaches include:

  • Static analysis rules that flag concatenated SQL strings and uses of unparameterized queries, especially in request-handling code.
  • Code review practices that require anchored, allowlist-style regular expressions and prohibit trusting regex validation alone for SQL safety.
  • Security testing (e.g., dynamic application security testing) that attempts standard SQL injection payloads against unauthenticated endpoints like graph_view.php.
  • Logging and anomaly detection for unusual query patterns or errors emanating from the database when handling web requests.
  • Policy enforcement in CI/CD pipelines ensuring all new data-access code uses parameterization and approved validation utilities.

Sources

SourceLink
github.comgithub.com/Cacti/cacti/commit/4c09efaebf3a9faec66969d0b5c4aceaf397f37f
github.comgithub.com/Cacti/cacti/security/advisories/GHSA-gp82-qhrg-crv7

Frequently asked

questions

Yes. The issue is pre-authentication, meaning any user who can reach the Cacti web interface can attempt exploitation without valid credentials.

The attacker only needs network access to the Cacti web interface. No local or prior authenticated access is required.

The most robust fix pattern is to replace concatenated SQL with parameterized queries and adopt strict, allowlist-based input validation, ensuring request parameters cannot alter query structure.

Prevention relies on secure design and enforcement: consistently use prepared statements, define clear validation rules for every input, limit database privileges, and integrate automated checks and code reviews that flag any dynamic SQL built from user-controlled data.

Find out what's already
exploitable in your codebase.