Summary
An SQL injection vulnerability in ChurchCRM's /MemberRoleChange.php endpoint allows authenticated users with the Manage Groups & Roles (ManageGroups) permission to inject arbitrary SQL via the NewRole parameter.
Under these conditions, an attacker can read and modify database records, potentially altering member roles, group assignments, and other sensitive application data.
Affected context
The vulnerability occurs in ChurchCRM deployments using versions prior to 7.1.0, specifically identified in 7.0.5, where the /MemberRoleChange.php endpoint processes role changes for members.
It is exposed when authenticated users with the ManageGroups capability can submit requests containing unvalidated NewRole parameter values that are interpolated into SQL statements without proper sanitization or binding.
The issue is limited to contexts where the application backend directly builds SQL queries from request parameters instead of using parameterized queries or robust input handling.
Exploit preconditions
- Attack surface: HTTP(S) requests to the /MemberRoleChange.php endpoint.
- Required access: Valid, authenticated ChurchCRM account with the Manage Groups & Roles (ManageGroups) permission.
- Trigger point: Submission of the NewRole parameter containing crafted SQL fragments in a request that invokes member role changes.
- Why exploitation is possible: The server-side code concatenates the NewRole parameter into SQL queries without parameterization or sufficient validation, allowing attacker-controlled input to alter the query structure and logic.
Why this happens
This vulnerability stems from dynamically constructing SQL statements using untrusted input from the NewRole parameter and embedding it directly into the query string.
Instead of using prepared statements or parameterized queries, the implementation appears to concatenate raw request data into SQL, which matches CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
The core bug class is trusting user-supplied data as part of query syntax rather than treating it strictly as data, enabling attackers to change the intent of the database operation.
Potential impact
- Reading sensitive information from ChurchCRM tables that the application database user can access.
- Modifying or corrupting member roles, group memberships, and related access-control data.
- Inserting, updating, or deleting records in the CRM database, potentially impacting integrity of church member and operational data.
- Escalating privileges within the application by assigning more powerful roles to attacker-controlled accounts, depending on database permissions and schema.
- Disrupting application behavior through data tampering that affects authorization logic or configuration stored in the database.
General mitigation guidance
Effective mitigation focuses on eliminating direct string concatenation of user input into SQL and tightening trust boundaries around role-management functions.
Common defensive patterns include:
- Using parameterized queries or prepared statements for all database interactions, ensuring that variables such as NewRole are always bound as data parameters.
- Applying strict server-side validation and whitelisting for role identifiers (e.g., numeric IDs or a finite set of allowed role names), rejecting any values outside the expected domain.
- Centralizing data access in a well-reviewed data access layer or ORM that consistently enforces safe query construction.
- Minimizing the privileges of the database account used by the application so that even if an injection vector exists, the scope of possible operations is limited.
- Restricting the ManageGroups permission to a minimal number of trusted administrative accounts and regularly reviewing assignment of powerful roles.
How teams detect issues like this
Organizations can detect and monitor for this class of vulnerability through several complementary approaches:
- Static analysis: Configure rules to flag dynamic SQL concatenation, especially where request parameters (e.g., $_GET, $_POST, or framework request objects) flow into query-building functions without binding.
- Code review: During manual review, look for endpoints performing administrative actions (like role changes) that build queries using string interpolation; verify that all variables are passed through parameter binding APIs.
- Security testing: Use automated DAST or interactive application security testing to probe parameters such as NewRole for injection behavior, monitoring for anomalous responses or database errors.
- Runtime monitoring: Enable database and application logging to detect unusual or malformed SQL patterns, as well as unexpected role changes or permission escalations associated with specific user accounts.

