/

CVE-2026-27470

Severity:

HIGH RISK

(8.8)

SQL Injection in ZoneMinder getNearEvents Status Endpoint

CVE-2026-27470

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Authenticated SQL Injection Leading to Arbitrary Query Execution

Severity:

HIGH RISK

(8.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

ZoneMinder versions 1.36.37 and below and 1.37.61 through 1.38.0 contain a second-order SQL injection vulnerability in web/ajax/status.php within the getNearEvents() function.

Although event fields such as Name and Cause are initially stored using parameterized queries, they are later retrieved and concatenated directly into SQL WHERE clauses, allowing an authenticated user with Events edit and view permissions to execute arbitrary SQL queries.

Affected context

This vulnerability exists in ZoneMinder's web interface logic used to fetch "nearby" events via web/ajax/status.php and the getNearEvents() function.

It affects deployments where:

  • Users can authenticate and have Events edit and view permissions
  • Event metadata (Name, Cause) comes from user-controlled or semi-trusted input
  • The application later builds SQL WHERE clauses by concatenating these stored values into query strings

The issue is second-order: the dangerous payload is stored safely at first and only becomes exploitable when read back and used unsafely in subsequent queries.

Exploit preconditions

  • Attack surface: Authenticated web interface (AJAX status endpoint calling getNearEvents()).
  • Required access: Valid ZoneMinder account with Events edit and view permissions.
  • Precondition (data priming): Attacker can create or modify events whose Name or Cause fields are stored in the database.
  • Trigger point: A subsequent request that calls getNearEvents(), causing the stored event fields to be read and concatenated into a SQL WHERE clause.
  • Why exploitation is possible: The application correctly uses parameterized queries when storing the data but later constructs SQL by string concatenation using retrieved field values without parameterization or proper escaping, enabling injection of attacker-controlled SQL fragments.

Why this happens

The core issue is a second-order SQL injection pattern aligned with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

ZoneMinder safely inserts event fields (Name, Cause) using parameterized queries, which prevents direct injection at write time.

However, the design fails to maintain the same safety guarantees when these values are read back and incorporated into the getNearEvents() query.

Instead of binding them as parameters, the code concatenates the values directly into a SQL WHERE clause.

This breaks the separation between data and query logic and allows attacker-controlled content, stored earlier, to be interpreted as part of the SQL syntax during later query execution.

Potential impact

  • Arbitrary SQL query execution within the ZoneMinder database context
  • Reading sensitive data that the authenticated user normally cannot access
  • Tampering with ZoneMinder configuration or event records
  • Deleting or corrupting event data, impacting video evidence integrity
  • Escalation of privileges within the application if role or user tables are modified
  • Laying groundwork for further compromise if database contents include secrets or integration credentials

General mitigation guidance

Effective mitigation centers on treating all database-driven strings as untrusted, even when they originate from previously stored values:

  • Use parameterized queries or prepared statements for all dynamic SQL, including queries that combine stored fields into WHERE clauses or other expressions.
  • Avoid constructing SQL by string concatenation; rely on query builders or ORM methods that enforce parameter binding.
  • Normalize data flow such that fields like Name and Cause are never inserted directly into SQL syntax (e.g., avoid using them as raw fragments in WHERE or ORDER BY clauses).
  • Introduce defensive input handling and canonicalization at write time, reducing the chance that control characters or SQL metacharacters persist in stored fields.
  • Apply least-privilege to the database account used by the application, limiting its ability to perform destructive or high-risk operations.
  • Adopt secure coding guidelines that explicitly call out second-order injection risks, not just immediate user-input injection.

How teams detect issues like this

Identifying and managing this vulnerability class typically involves a combination of automated and manual techniques:

  • Static analysis: Flag any database calls where SQL strings are constructed by concatenating variables, especially when those variables originate from database reads rather than direct request parameters.
  • Code review patterns: During review of data access layers and AJAX handlers, look for:
  • SQL fragments assembled with . or + operators
  • Conditional clause construction (e.g., $where .= " AND " . $name;) using variable content
  • Functions that read from the database and later build dynamic queries using those values
  • Data flow analysis: Trace how user-controllable fields (event Name, Cause) propagate through the application and whether they are ever re-used in query construction without re-parameterization.
  • Runtime monitoring: Enable database logging or application-level SQL logging with alerting for anomalous queries containing unexpected syntax or concatenated fragments.
  • Security testing: Include second-order injection tests in QA and penetration testing by:
  • Storing benign-looking payloads in database fields
  • Exercising application features that reuse those fields in subsequent queries.

Sources

SourceLink
github.comgithub.com/ZoneMinder/zoneminder/releases/tag/1.36.38
github.comgithub.com/ZoneMinder/zoneminder/releases/tag/1.38.1
github.comgithub.com/ZoneMinder/zoneminder/security/advisories/GHSA-r6gm-478g-f2c4
owasp.orgowasp.org/www-community/attacks/SQL_Injection

Frequently asked

questions

Yes, but it requires authentication. An attacker must access the ZoneMinder web interface and have the necessary permissions to edit and view events. From there, they can craft event metadata and trigger the vulnerable getNearEvents() logic to exploit the injection.

The attacker needs a valid ZoneMinder account with Events edit and view permissions. They do not need direct database access; exploitation occurs through normal web requests that cause the application to execute crafted SQL.

Refactor all affected queries to use parameterized statements or a query builder that enforces parameter binding. Ensure that stored fields like Name and Cause are always bound as data parameters and never integrated directly into SQL strings, regardless of when they were originally supplied.

Treat all data, including values retrieved from the database, as untrusted when it will be reintroduced into SQL. Establish coding standards that prohibit raw string concatenation for query building, perform targeted code reviews for second-order injection patterns, and integrate static analysis rules that detect dynamic SQL construction across the codebase.

Find out what's already
exploitable in your codebase.