Summary
ChurchCRM versions prior to 7.1.0 contain a SQL injection vulnerability in GroupPropsFormRowOps.php, where user-controlled data in the Field parameter is concatenated directly into SQL statements.
Because backtick characters are not escaped by mysqli_real_escape_string(), attackers can break out of SQL identifier context and inject arbitrary SQL, potentially leading to data exfiltration, modification, or full application compromise.
Affected context
This vulnerability affects ChurchCRM deployments using versions prior to 7.1.0 where dynamic SQL is built in GroupPropsFormRowOps.php.
The problematic code path is triggered when the application accepts the Field parameter from user input and interpolates it into SQL queries as an identifier (e.g., column or field name).
The risk is present when users, plugins, or external integrations can influence this parameter in a way that is not tightly constrained to a safe, predefined set of values.
Exploit preconditions
- Attack surface: Web interface or HTTP API endpoints that route to
GroupPropsFormRowOps.phpand accept theFieldparameter. - Required access: Ability to send crafted HTTP requests to the ChurchCRM instance (typically unauthenticated or low-privilege authenticated, depending on deployment configuration).
- Trigger point: Code paths that construct SQL using the
Fieldparameter directly in an identifier position (e.g., within backticks) without robust validation or whitelisting. - Why exploitation is possible:
mysqli_real_escape_string()is designed to escape string literals, not SQL identifiers; it does not escape backticks, so attacker-supplied backticks allow breaking out of identifier context and injecting arbitrary SQL fragments.
Why this happens
The core issue is unsafe construction of SQL statements using untrusted input, mapping directly to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Instead of using parameterized queries or strict whitelisting for identifier names, the application concatenates the Field parameter directly into the SQL query.
The developer relied on mysqli_real_escape_string() to sanitize the input, but this function only escapes characters relevant to string literals, not identifier delimiters such as backticks.
As a result, an attacker can introduce backticks to terminate the identifier and inject arbitrary SQL, causing the database engine to interpret attacker-controlled input as part of the SQL syntax rather than as data.
Potential impact
- Access to, and exfiltration of, sensitive data stored in ChurchCRM tables (e.g., member information, contact details, internal notes).
- Modification or deletion of data, including tampering with records, corrupting group configurations, or removing entire tables.
- Creation of new administrative accounts or elevation of privileges by manipulating authentication or authorization tables.
- Disruption of application availability via destructive queries (e.g., dropping tables, locking operations).
- Potential pivoting to underlying infrastructure if database access can be leveraged to compromise the host or other services.
General mitigation guidance
Effective mitigation focuses on eliminating direct string concatenation of untrusted input into SQL statements, especially in identifier positions.
Recommended design patterns include:
- Using parameterized queries (prepared statements) for all user-controlled values that can be expressed as parameters (particularly values in WHERE clauses and data inserts/updates).
- Avoiding dynamic identifiers where possible; instead, mapping user choices to a predefined, server-side whitelist of allowed column or field names.
- When dynamic identifiers are unavoidable, enforcing strict validation using allowlists and rejecting any value that does not match known-safe identifiers.
- Treating
mysqli_real_escape_string()and similar APIs as supplementary defenses for string literals, not as a primary protection for SQL syntax or identifiers. - Applying the principle of least privilege at the database level so that the application account has only the minimal permissions required, limiting the blast radius of any injection.
- Centralizing query-building logic and validation rules to reduce the chance of ad hoc, unsafe SQL construction scattered across the codebase.
How teams detect issues like this
Detection typically combines code-centric review with runtime analysis:
- Static analysis: Configure SAST tools or custom rules to flag direct concatenation of
$_GET,$_POST, or other user input into SQL strings, especially when used near backticks or other identifier delimiters. - Code review signals: Look for:
- SQL queries constructed via string concatenation or interpolation.
- Use of
mysqli_real_escape_string()or similar functions as the primary defense. - Dynamic use of user input for column names, table names, or ORDER BY clauses without explicit allowlists.
- Policy enforcement: Adopt coding standards that require parameterized queries, centralized database access layers, and explicit whitelisting for any dynamic identifiers.
- Runtime monitoring: Use database or application logs and WAF rules to detect anomalous query patterns, such as unexpected backticks, comment markers, or stacked queries originating from web requests.

