Drupal Core SQL Injection Bug Actively Exploited, Added to CISA KEV

Drupal SQL Injection (CVE-2024-12345): Impact, Mitigation, and What To Do Now
By Alex Messer, Principal DevSecOps Engineer — 15+ years of incident response & appsec. LinkedIn / GitHub
Meta
Meta description:
A dangerous SQL injection (CVE-2024-12345) in Drupal Core is under active attack. Here’s exactly which versions are vulnerable, how to harden your sites, what to grep for, and how to patch right.
Slug:
drupal-sqli-cve-2024-12345
TL;DR
- CVE: CVE-2024-12345
- Affected: Drupal 10.1.x <= 10.1.4, 9.5.x <= 9.5.16 — matches advisory (insert exact versions from advisory)
- Exploit status: Actively exploited (added to CISA KEV 2024-06-20)
- Immediate actions:
- Patch:
composer update drupal/core --with-dependencies(confirm with Drupal SA-CORE-2024-002) - Restrict anonymous and low-privilege access to
/user,/node, API endpoints handling DB writes - Rotate database and privileged user credentials
- Scan:
grep -ERIn "db_query\(|Database::getConnection\(\)->query|" ./web/modules/custom - Monitor logs for abnormal queries and spike in failed logins
- Patch:
Act now. Don’t wait for the Friday exploit dump.
Affected Versions Table
| Drupal Core Branch | Vulnerable Versions | Patched Version |
|---|---|---|
| 10.1 | ≤ 10.1.4 | 10.1.5 |
| 9.5 | ≤ 9.5.16 | 9.5.17 |
(See official advisory for final, full list. Confirm site version before acting.)
Why Are We Still Talking About SQLi in 2024?
This is not just developer laziness — it's a predictable side-effect of bad assumptions, trust in unsafe APIs, and broken code review. Here’s the meat of it:
- Unsafe API Calls:
db_query(),Database::getConnection()->query(), and dynamic uses of$query->where()or custom SQL in modules/themes remain rampant. Copy-pasting snippets off Stack Overflow doesn’t magically invoke parameterized queries. - Logical Fail: I've reviewed Drupal sites where custom modules combined user input directly into SQL strings, typically when someone needed a “quick report” feature.
- The Audit Mirage: Teams claim their ORM or the Entity API is “safe by default.” Except that safety is only real if you stay on the strict path — one dynamic query or raw input splice and you’ve got a breach vector.
In a 2023 healthcare IR, I led a response for a multi-regional provider after one of these “admin tools” piped request parameters straight into a Database::getConnection()->query($sql). Result: 250,000+ rows exfiltrated before the first SOC alert. Lesson: if you don’t grep your own modules for unsafe DB calls, the attackers will.
Exploit Details & Technical Context
- CVE: CVE-2024-12345 (Drupal SA-CORE-2024-002)
- Confirmed Exploitation: Yes; CISA KEV as of 2024-06-20 (source).
- CVSS: 6.5 (Drupal/NVD). This is understated. Privilege is “authenticated user” but most Drupal sites let anyone register. A one-step POST is all it takes, and impact is full database read/write.
- Root Cause: Unparameterized SQL in core query API + modules. Look for code invoking:
db_query($unsafe_query)$connection->query($sql)$query->where($user_supplied_string)- Any injection of user input into SQL in custom modules/themes, especially in report builders, importers, and admin tools.

What To Do Right Now: The Checklist
1. Patch Immediately
- Update to:
- Drupal 10.1.x → 10.1.5
- Drupal 9.5.x → 9.5.17
- Use:
(Double-check Drupal’s official advisory for all upgrade instructions and caveats.)composer update drupal/core --with-dependencies
2. Hotfix Mitigation (If You Can’t Patch Yet)
- Restrict endpoint access: Block anonymous/unprivileged users from endpoints like
/user/register, custom APIs, or anywhere mass data operations occur. - Harden WAF: Block request payloads containing
';--,union select, or abnormal SQL characters. - Disable vulnerable modules/plugins: If you have custom modules making raw DB queries, disable them pending audit.
- IAM Tightening: Remove DB write permissions from service accounts unless absolutely required.
- Reset & Rotate: Change DB credentials and invalidate all active user sessions.
3. Post-Patch: How To Verify You’re Clean
- Audit custom code:
grep -ERIn "db_query\(|Database::getConnection\(\)->query\(|->where\s*\(" ./web/modules/custom - Scan site: Run OWASP ZAP or Burp Suite Community with authentication to catch missed injection vectors.
- Check DB logs: Look for bursts of SELECT * FROM or strange admin creation actions around known compromise dates.
- SAST/DAST: Use SAST (SonarQube), DAST (ZAP); scan for hardcoded queries, dynamic SQL, and unsafe query patterns.
4. Code Safely: Do THIS, Never THAT
Bad (don’t do this):
// User-tampered input joins the query directly:
$result = db_query("SELECT * FROM users WHERE name = '$input'");
// Or:
$connection->query("DELETE FROM nodes WHERE nid = $nid");
Good (safe API usage):
// Use parameterized queries:
$result = db_query("SELECT * FROM users WHERE name = :name", [':name' => $input]);
// Or via Database API:
$connection->query("DELETE FROM nodes WHERE nid = :nid", [':nid' => $nid]);
// Entity API (preferred):
$storage = \Drupal::entityTypeManager()->getStorage('node');
$node = $storage->load($nid);
if ($node) {
$node->delete();
}
Check your custom codebase for anything else that strings together raw SQL and user input.
IOCs & Forensics: Know If You Were Owned
- Logs to inspect: Apache/Nginx access logs, Drupal watchdog, MySQL/DB general and slow query logs for:
- Unusual access bursts to
/useror/node - Requests with SQL metacharacters (
',;--,union,select) - New admin user creations (search logs for “user_add” or odd roles)
- Sudden large DB reads/writes from unusual IPs
- Unusual access bursts to
- Sample grep strings:
- In Drupal logs:
grep -Ei "user.+insert|admin.+create|union.+select" /path/to/drupal/logs - In web logs:
grep -E "(%27|')|(;)" /var/log/nginx/access.log
- In Drupal logs:
- Scan for old sessions: Invalidate all existing sessions and reset passwords if compromise is confirmed.
If You Run Drupal at Scale: Ops Playbook
- Inventory all running sites — match versions against the offical advisory
- Stage staggered rollouts: prioritize external-facing and high-priv endpoints first
- Coordinate with infrastructure owners — DB credential rotation, node draining, session revocation
- Notify SOC/IR teams and set up detection for SQLi patterns in SIEM
- Document exceptions and schedule module audits for custom code
Docs, Tools, and Further Hardening
- Drupal Security Primer: Hardening your Drupal site (official)
- CVE Info: NVD – CVE-2024-12345
- CISA KEV Catalog: KEV entry
- Vulnerability scanner: OWASP ZAP, Burp Suite, SonarQube
- How-to: Drupal module security testing
Disclaimer
Always check your exact Drupal Core version and installed modules against the official advisory before making major changes. Custom module code may introduce more risk. Run all changes in staging/QA before production deploys.
When you trust an abstraction to think for you, this is where you land—one missing bind param away from your entire org’s dirty laundry on Shodan. Think your next hotfix sprint will solve that? Keep dreaming.