Summary
ChurchCRM versions prior to 7.1.0 contain an SQL injection vulnerability in the src/MemberRoleChange.php endpoint, where the NewRole POST parameter is incorporated into a query without proper integer validation.
An authenticated user with the ManageGroups role who knows a valid GroupID and PersonID can inject arbitrary SQL, potentially leading to data exposure, modification, or further compromise of the ChurchCRM database.
Affected context
The vulnerability occurs in ChurchCRM's group membership management functionality, specifically when changing a member's role via MemberRoleChange.php.
It is relevant in deployments where:
- Users are granted the ManageGroups role,
- The application talks directly to a relational database (e.g., MySQL) using dynamically constructed SQL, and
- Input parameters such as
NewRoleare not strictly validated or bound as parameters.
The issue is limited to contexts where authenticated users can access the role-change action and interact with the relevant group/member records.
Exploit preconditions
- Attack surface: HTTP POST requests to the
src/MemberRoleChange.phpendpoint. - Required access: Authenticated ChurchCRM account with ManageGroups privileges.
- Knowledge prerequisites: Valid
GroupIDandPersonIDvalues (obtainable via GroupView or PersonView pages). - Trigger point: Submission of a crafted
NewRolePOST parameter that is concatenated into an SQL query. - Why exploitation is possible: The server-side code incorporates
NewRoledirectly into SQL without enforcing integer-only semantics or using parameterized queries, enabling alteration of the intended query structure.
Why this happens
This vulnerability stems from building SQL statements by concatenating user-supplied input (NewRole) into the query string without proper type enforcement or parameter binding.
Instead of treating NewRole as a strictly validated integer, the application allows arbitrary content to propagate into the SQL layer.
This maps directly to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where untrusted input is not safely parameterized, allowing attackers to modify query logic.
Potential impact
- Disclosure of sensitive data from ChurchCRM tables, including member or group information.
- Unauthorized modification or deletion of records (e.g., membership data, roles, group assignments).
- Creation or alteration of application accounts or permissions if related tables are reachable.
- Potential pivot to broader database compromise, including schema changes or persistence of malicious data.
- Operational disruption due to corrupted or inconsistent database state.
General mitigation guidance
Effective mitigation focuses on eliminating dynamic SQL construction from user-controllable values:
- Use parameterized queries or prepared statements for all database access, ensuring user inputs cannot alter query structure.
- Enforce strict type validation on fields like
NewRole, treating them as integers and rejecting non-numeric data early. - Apply centralized input validation routines for role IDs, group IDs, and person IDs to reduce the chance of inconsistent checks.
- Implement least-privilege database accounts so that the application can only perform necessary operations, limiting damage if an injection occurs.
- Consider implementing a server-side allowlist for acceptable role identifiers instead of trusting client-provided values.
How teams detect issues like this
Organizations can detect similar issues using a combination of review and automated checks:
- Static analysis rules that flag string concatenation or interpolation used with SQL execution APIs, especially with request parameters like
$_POST. - Code review checklists that require developers to justify any non-parameterized SQL and verify strict type enforcement for IDs and role values.
- Application security tests (including dynamic scanning) that attempt to inject SQL meta-characters into numeric parameters such as
NewRole. - Centralized logging and monitoring for anomalous SQL patterns, such as unexpected errors or queries containing injected fragments.

