Severity:

HIGH RISK

(7.1)

SQL Injection in Mautic API Contact Filtering

CVE-2026-4776

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Data Exposure and Manipulation via Authenticated SQL Injection

Severity:

HIGH RISK

(7.1)

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

An SQL injection vulnerability in Mautic's API contact filtering mechanism allows crafted nested query parameters to bypass input sanitization.

An authenticated API user who can invoke contact filtering endpoints may inject arbitrary SQL fragments into backend queries, potentially exposing or manipulating contact data.

Affected context

This vulnerability arises in Mautic deployments that expose and use the API for contact filtering and segmentation.

It manifests when the backend constructs SQL queries from nested filter parameters supplied via the API without fully sanitizing or parameterizing all nested elements.

The issue is more likely in deployments where:

  • Applications or integrations rely heavily on dynamic, user-controlled filters
  • API authentication is widely granted to internal services or external partners
  • Database accounts backing Mautic have broad read/write privileges on contact tables.

Exploit preconditions

  • Attack surface: Mautic HTTP API, specifically endpoints that perform contact filtering based on user-supplied criteria.
  • Required access: Valid authenticated API access (e.g., API key, OAuth token, or equivalent credentials) with permission to call contact-related endpoints.
  • Trigger point: Submission of crafted nested filter parameters in API requests, causing the backend to build SQL queries including attacker-controlled fragments.
  • Why exploitation is possible: The recursive processing of nested query parameters does not consistently enforce parameterization or escaping at every depth, allowing malicious input to bypass filtering and be concatenated into SQL statements.

Why this happens

The core issue is the construction of SQL queries using user-controlled filter parameters without ensuring that all components are safely bound as parameters.

While Mautic attempts to sanitize input, the recursive handling of nested filter structures leaves gaps where certain values are incorporated into the query string directly.

This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, where user input is treated as part of the SQL command syntax rather than data.

Conceptually, the bug reflects a mismatch between complex, expressive filtering APIs and an incomplete defensive strategy that does not guarantee parameterization at every level of the query-building logic.

Potential impact

  • Disclosure of contact data and related metadata beyond the attacker's normal authorization scope
  • Unauthorized filtering to infer sensitive attributes about contacts (e.g., segmentation, campaign participation)
  • Manipulation of contact records, including insertion, modification, or deletion, depending on database permissions
  • Potential impact on reporting accuracy and campaign analytics due to tampered datasets
  • In extreme cases, broader database compromise if the underlying account has elevated privileges and the DBMS allows stacked or extended queries

General mitigation guidance

Effective mitigation centers on eliminating string-built SQL from user-controlled filter parameters and enforcing strict data/command separation:

  • Prefer parameterized queries or ORM query builders exclusively, ensuring every filter value (including nested fields, operators, and sort expressions) is bound as data, not concatenated.
  • Normalize and validate filter schemas before query construction, restricting allowed fields, operators, and value types to a fixed, documented set.
  • Flatten or canonicalize nested filter structures server-side, applying the same validation and binding rules uniformly at every depth.
  • Apply least-privilege to the database user used by Mautic so that even if a query is abused, it cannot access or modify unrelated schemas or system tables.
  • Consider centralizing query construction in a dedicated abstraction layer instead of scattering SQL-building logic across controllers or handler functions.

How teams detect issues like this

Detection can focus on both code-level and runtime indicators:

  • Static analysis: Configure rules that flag string concatenation or interpolation in SQL construction, especially in API handlers that process filter or query parameters; look for dynamic injection of operators, column names, or clauses derived from user input.
  • Code review: During manual reviews, pay particular attention to complex filter parsing, recursive parameter handling, and any bypass paths around central validation or parameterization utilities.
  • Runtime monitoring: Analyze database logs for anomalous queries originating from Mautic, such as unexpected SQL keywords in parameter positions, unusually complex WHERE clauses, or patterns containing comment markers and control characters.
  • Automated testing: Extend API test suites with negative tests that submit malformed or syntactically suspicious filter parameters to confirm that they are rejected or safely handled.

Sources

SourceLink
github.comgithub.com/mautic/mautic/security/advisories/GHSA-fcmw-wx57-9p75

Frequently asked

questions

Yes, but it requires authenticated access to Mautic's API. An attacker must be able to send crafted requests to contact filtering endpoints over the network.

The attacker needs valid API credentials with permission to invoke contact-related filtering operations. Unauthenticated users cannot exploit this specific flaw, but weak credential management could widen exposure.

Refactor the contact filtering query builder to rely solely on parameterized queries or ORM constructs, enforcing a strict whitelist of allowed fields and operators, and applying the same binding logic to all nested filter elements.

Adopt a defensive design for query-building APIs: centralize query construction, prohibit direct string concatenation with user input, enforce schema-based validation for complex filter structures, and integrate static analysis plus security-focused code review into the development workflow.

Find out what's already
exploitable in your codebase.