Summary
ChurchCRM versions prior to 7.1.0 contain a SQL injection vulnerability in SettingsIndividual.php where user-controlled array keys from the type POST parameter are used directly within SQL queries.
An authenticated user can manipulate these inputs to inject arbitrary SQL, potentially extracting sensitive information from the ChurchCRM database.
Affected context
This vulnerability affects ChurchCRM deployments running versions prior to 7.1.0 where the SettingsIndividual.php functionality is accessible to authenticated users.
The issue occurs in code paths that build SQL queries from POST data, specifically the type parameter, and treat array keys as trusted parts of the query structure.
Environments with default or permissive role configurations, where many users can reach this settings area, are more exposed, but any instance where authenticated users can trigger SettingsIndividual.php may be impacted.
Exploit preconditions
- Attack surface: Web application endpoint handling
SettingsIndividual.php. - Required access: Valid authenticated ChurchCRM account with permission to access the affected settings endpoint.
- Trigger point: Submission of crafted POST requests where the
typeparameter (including its array keys) is controlled by the attacker. - Why exploitation is possible: The server-side code interpolates user-controlled array keys directly into SQL statements without proper parameterization or validation, allowing hostile input to alter the query structure.
Why this happens
The root cause is the construction of SQL queries using dynamic string concatenation that incorporates user-controlled data from the type POST parameter, including its array keys, without sanitization or parameter binding.
This pattern aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where input that influences SQL syntax is not separated from data values using prepared statements or robust input handling.
Instead of treating user input strictly as data, the code allows it to participate in building column or condition fragments, enabling attackers to inject additional SQL clauses.
Potential impact
- Authenticated users could extract sensitive data from ChurchCRM databases, including member records or configuration data.
- Attackers may be able to enumerate or exfiltrate credential-related information stored in the database, depending on schema and protections.
- Exposure of personally identifiable information (PII) about congregants, staff, or donors.
- Potential pivot into additional SQL-based attacks, such as inference of table structure or limited data modification where the query context allows it.
General mitigation guidance
Effective mitigation focuses on separating SQL structure from user input and constraining what users can influence:
- Use parameterized queries or prepared statements for all data values, never interpolating POST parameters directly into SQL strings.
- Restrict dynamic elements such as column names or setting keys to fixed, server-side whitelists, mapping user input to predefined, safe identifiers.
- Apply strict validation and normalization for all incoming POST data, rejecting unexpected keys or structures rather than attempting to sanitize them.
- Enforce least-privilege database accounts so that the application can only access the minimal tables and operations needed for ChurchCRM functions.
- Adopt secure coding patterns for data access layers, centralizing query construction to reduce ad hoc string-building in individual scripts.
How teams detect issues like this
Organizations can identify similar issues through a combination of code-centric and runtime approaches:
- Static analysis: Configure SAST rules to detect SQL strings built via concatenation that include request parameters like
$_POST, especially when array keys are interpolated into query fragments. - Code review: Flag any use of dynamic keys from client input in SQL column names, WHERE clauses, or ORDER BY segments; ensure all queries go through a vetted data access layer.
- Security testing: Use automated or manual penetration testing to send crafted POST requests to settings endpoints and monitor for anomalous SQL behavior or verbose database errors.
- Policy enforcement: Establish development guidelines requiring prepared statements and whitelist-based handling for any dynamic query elements, and enforce them via pull request checks and CI tooling.

