CVE-2022-21661

8.0 HIGH

📋 TL;DR

CVE-2022-21661 is an SQL injection vulnerability in WordPress's WP_Query class due to improper input sanitization. This allows attackers to execute arbitrary SQL commands through plugins or themes that use WP_Query in specific ways. All WordPress sites running versions before 5.8.3 are affected.

💻 Affected Systems

Products:
  • WordPress
Versions: WordPress versions 3.7.0 through 5.8.2
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Requires plugins or themes that use WP_Query in specific ways. Core WordPress is vulnerable but exploitation requires vulnerable plugin/theme usage patterns.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise leading to data theft, privilege escalation, site defacement, or complete system takeover if database user has elevated privileges.

🟠

Likely Case

Data exfiltration from WordPress database including user credentials, sensitive content, and configuration data.

🟢

If Mitigated

Limited impact if proper input validation is implemented at application layer and database user has minimal privileges.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires finding plugins/themes with specific WP_Query usage patterns. Public exploit code exists but requires adaptation.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: WordPress 5.8.3

Vendor Advisory: https://github.com/WordPress/wordpress-develop/security/advisories/GHSA-6676-cqfm-gw84

Restart Required: No

Instructions:

1. Backup your WordPress site and database. 2. Update WordPress to version 5.8.3 or later via Dashboard > Updates. 3. Update all plugins and themes. 4. Test site functionality after update.

🔧 Temporary Workarounds

No known workarounds

all

The vendor states there are no known workarounds for this vulnerability.

🧯 If You Can't Patch

  • Implement strict WAF rules to block SQL injection patterns at the network perimeter
  • Restrict database user permissions to minimum required privileges

🔍 How to Verify

Check if Vulnerable:

Check WordPress version in Dashboard > Updates or examine wp-includes/version.php file

Check Version:

grep '\$wp_version' wp-includes/version.php

Verify Fix Applied:

Confirm WordPress version is 5.8.3 or later and verify the commit 17efac8c8ec64555eff5cf51a3eff81e06317214 is present

📡 Detection & Monitoring

Log Indicators:

  • Unusual database queries in WordPress logs
  • Multiple failed login attempts followed by unusual SQL patterns
  • Unexpected database errors in error logs

Network Indicators:

  • HTTP requests with SQL injection patterns targeting WordPress endpoints
  • Unusual database connection patterns from web server

SIEM Query:

source="wordpress.log" AND ("SQL syntax" OR "database error" OR "wpdb::prepare")

🔗 References

📤 Share & Export