Summary
A high-severity SQL injection vulnerability in CiviCRM's contact search functionality allows authenticated staff to influence an RLIKE clause through unsanitized input.
An attacker with staff-level access may be able to read database contents, including donor, member, and other sensitive records, when the vulnerable search path is available.
Affected context
The vulnerability occurs in CiviCRM deployments where authenticated staff can use the affected contact search functionality and a user-supplied value is incorporated into an RLIKE SQL clause without adequate parameterization or escaping. The risk depends on the attacker's permissions, the application's database access, and the data exposed through the affected query.
Exploit preconditions
- Attack surface: The CiviCRM contact search feature and its RLIKE-based query path
- Required access: Authenticated staff-level access capable of submitting search criteria
- Trigger point: Processing a contact search value supplied by the authenticated user
- Why exploitation is possible: The search value is concatenated into a SQL statement without sufficient sanitization or parameter binding
Why this happens
The underlying issue is an SQL query construction pattern that combines user-controlled search input with query text. When the value is inserted into an RLIKE clause without safe parameterization, SQL syntax may be interpreted as part of the statement rather than treated solely as data.
This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'). The insecure boundary occurs when application input is trusted during dynamic query construction.
Potential impact
- An attacker may read records beyond their intended business scope
- Sensitive donor, member, contact, or administrative data could be disclosed
- Database contents may be exfiltrated through repeated search requests
- The confidentiality of information managed by the CiviCRM instance could be compromised
General mitigation guidance
Mitigation generally focuses on separating query structure from user-controlled values and reducing the trust placed in search input.
Common defensive patterns include:
- Use parameterized queries or prepared statements for RLIKE and other dynamic predicates
- Apply context-appropriate handling for regular-expression and pattern-matching input
- Validate search values against narrowly defined schemas and length limits
- Avoid constructing SQL through string concatenation
- Enforce least-privilege database credentials and restrict access to sensitive tables
- Apply authorization checks so search results remain within the user's permitted data scope
- Use secure-by-default query abstractions that do not expose raw SQL composition
How teams detect issues like this
Organizations can identify similar risks through:
- Static analysis rules for SQL string concatenation involving request or form values
- Code review checks for dynamic RLIKE, LIKE, ORDER BY, and filtering clauses
- Repository searches for raw database APIs used with unsanitized input
- Runtime monitoring for unusual search patterns, excessive result enumeration, or unexpected database errors
- Database audit policies that record access to sensitive tables and anomalous query volumes
Automated application-security and code-review tools may help identify unsafe query construction, but findings should be validated against authorization and data-access behavior.

