/

CVE-2026-39318

Severity:

HIGH RISK

(8.8)

SQL Injection in ChurchCRM GroupPropsFormRowOps

CVE-2026-39318

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Execution / Data Compromise

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

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.php and accept the Field parameter.
  • 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 Field parameter 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.

Sources

SourceLink
github.comgithub.com/ChurchCRM/CRM/security/advisories/GHSA-8r53-w4r6-w62c
github.comgithub.com/ChurchCRM/CRM/security/advisories/GHSA-j3vj-59vv-h4rc

Frequently asked

questions

Exploitability is generally high: an attacker who can control the Field parameter and send crafted HTTP requests can often inject SQL without needing deep knowledge of the application, especially if error messages or observable behavior reveal query structure.

It depends on how the affected functionality is exposed in a given deployment. If the route using GroupPropsFormRowOps.php is reachable by unauthenticated users, no login is required; otherwise, low-privileged authenticated access may be sufficient as long as the user can influence the Field parameter.

Refactor the code to remove direct concatenation of user input into SQL, use prepared statements for values, and handle the Field parameter via a strict server-side whitelist of allowed identifiers rather than trusting arbitrary strings from the client.

Adopt a defensive development strategy where all database access goes through a well-reviewed abstraction layer that enforces parameterization and validation, establish coding guidelines that prohibit raw SQL concatenation, and integrate static analysis plus code review checks to catch any new instances early in the development lifecycle.

Find out what's already
exploitable in your codebase.