Summary
ChurchCRM versions prior to 7.1.0 contain a SQL injection vulnerability in the searchwhat parameter of QueryView.php when using QueryID=15 (the "Advanced Search" query).
An authenticated user with access to Data/Reports → Query Menu → Advanced Search can manipulate this parameter to inject arbitrary SQL, potentially leading to data exposure, modification, or other high-impact database actions.
Affected context
The vulnerability occurs in ChurchCRM's reporting functionality, specifically within the Advanced Search query (QueryID=15) handled by QueryView.php.
It affects deployments where:
- Users have authenticated access to ChurchCRM, and
- At least some users are granted permissions to Data/Reports → Query Menu → "Advanced Search."
In this context, the searchwhat parameter is incorporated into a backend SQL query without adequate sanitization or parameterization, making it susceptible to injection when user-controlled values are passed to the database.
Exploit preconditions
- Attack surface: Web application interface (ChurchCRM UI) via HTTP(S) requests to
QueryView.php. - Required access: Authenticated ChurchCRM account with permission to access Data/Reports → Query Menu and the "Advanced Search" query (QueryID=15).
- Trigger point: Submission of the Advanced Search form with a crafted
searchwhatparameter value; the parameter is processed server-side and embedded into a database query. - Why exploitation is possible: The application constructs SQL statements by concatenating or interpolating the
searchwhatvalue directly into the query without enforcing strict parameterization or robust input handling, allowing attacker-controlled input to alter the intended query structure.
Why this happens
This issue is a classic example of CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
In the affected ChurchCRM code path, the searchwhat parameter from the Advanced Search feature is treated as trusted input and incorporated into an SQL statement in a way that allows control over SQL syntax.
The underlying bug is the use of dynamic SQL construction (e.g., string concatenation or interpolation) with user-controlled values instead of binding values via prepared statements or using a query abstraction layer that enforces separation of code and data.
As a result, attackers can inject additional SQL clauses or expressions through searchwhat, influencing which records are returned or how the database operation executes.
Potential impact
- Unauthorized reading of sensitive church member records or other data the database query can access.
- Unauthorized modification of data, such as updating or deleting records, if the injected SQL is executed in a context that permits it.
- Escalation of access to additional data by bypassing application-level filters and restrictions enforced in other layers.
- Potential pivot to other application features that rely on the same database, depending on database privileges and configuration.
- Interference with reporting accuracy and data integrity, potentially impacting operational decisions based on those reports.
General mitigation guidance
Effective mitigation centers on eliminating unsafe dynamic SQL construction and reducing trust in user-controlled inputs:
- Use parameterized queries or prepared statements for all database interactions, ensuring that user input is always bound as data, not as executable SQL syntax.
- Apply strict input validation and canonicalization on search and filter parameters, restricting them to expected patterns (e.g., alphanumeric, specific operators) and rejecting or normalizing anything outside of defined rules.
- Refactor reporting and query-building features to rely on vetted query builders or ORM abstractions that enforce separation between query structure and user input.
- Implement least-privilege database accounts so that the application's database user can perform only the minimum necessary operations, limiting impact if an injection path is missed.
- Prefer pre-defined, parameterized report templates over arbitrary user-defined SQL, especially in administrative or reporting modules.
How teams detect issues like this
Detection generally combines code-level analysis with runtime monitoring:
- Static analysis: Configure SAST tools or linters to flag direct concatenation of request parameters (such as
$_GET,$_POST, or framework equivalents) into SQL strings, particularly in files likeQueryView.phpand other reporting components. - Code review cues: During manual review, look for any custom query-building logic in reporting and search features where input fields like
searchwhatare directly used to construct WHERE clauses or other SQL fragments. - Database monitoring: Enable database logs and alerts for anomalous queries, such as those containing unexpected operators, stacked statements (if supported), or unusual patterns that may indicate injection attempts.
- Security testing: Incorporate automated DAST or focused penetration tests targeting search and reporting forms to identify residual injection points by fuzzing parameters and analyzing server responses.

