Vulnerability record · CVE-2022-21661 · published 6 January 2022
CVE-2022-21661: WordPress WP_Query improper sanitization enables SQL injection
Wordpress · Wordpress
WordPress core fails to properly sanitize input in WP_Query, allowing SQL injection when plugins or themes pass attacker-controlled data into that class. The flaw is patched in WordPress 5.8.3, with backports to 3.7.37 and later branches. Because WP_Query is widely used by plugins and themes, exposure depends on how each site's extensions call it.
Description
WordPress is a free and open-source content management system written in PHP and paired with a MariaDB database. Due to improper sanitization in WP_Query, there can be cases where SQL injection is possible through plugins or themes that use it in a certain way. This has been patched in WordPress version 5.8.3. Older affected versions are also fixed via security release, that go back till 3.7.37. We strongly recommend that you keep auto-updates enabled. There are no known workarounds for this vulnerability.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Automated analysis
high priorityHigh CVSS (7.5), very high EPSS, and public exploit code make this a realistic target despite no KEV listing.
What it is
WordPress core fails to properly sanitize input in WP_Query, allowing SQL injection when plugins or themes pass attacker-controlled data into that class. The flaw is patched in WordPress 5.8.3, with backports to 3.7.37 and later branches. Because WP_Query is widely used by plugins and themes, exposure depends on how each site's extensions call it.
Impact
An unauthenticated attacker can inject SQL through a vulnerable WP_Query call, potentially reading sensitive database contents such as user credentials and configuration data. The CVSS vector rates confidentiality impact as high with no integrity or availability impact.
Attack surface
Reached over the network via HTTP requests to a site whose plugin or theme passes unsanitized input into WP_Query; the CVSS vector indicates no authentication and no user interaction are required. The description does not name specific vulnerable plugins or themes.
Exploitation
CISA KEV does not list this CVE, but EPSS is very high at roughly 0.978 (99.9th percentile) and public exploit references exist on Exploit-DB and Packet Storm, indicating mature, widely available exploit code.
What to do
- Update WordPress core to 5.8.3 or later, or to the relevant security release (3.7.37 and later branches).
- Keep automatic core updates enabled as the vendor recommends.
- Inventory installed plugins and themes and update or remove any that pass user input into WP_Query without sanitization.
- Apply the Debian or Fedora package updates if running WordPress from those distributions.
- Note that the vendor states there are no known workarounds, so patching is the only reliable fix.
Detection
- Review web server and WAF logs for SQL metacharacters (quotes, UNION, SLEEP, comments) in query parameters hitting WordPress endpoints.
- Enable and monitor database query logging for anomalous or malformed SQL originating from the web application.
- Check installed plugin and theme versions against vendor advisories for WP_Query usage.
- Alert on unexpected outbound or database access patterns consistent with data exfiltration.
This assessment is produced automatically and is not human-reviewed. Verify against the vendor advisory before acting on it.
Affected products
3 vulnerable configurations from NVD's CPE data, grouped by vendor and product.
References
Track CVE-2022-21661 inside VULONE
Watch it alongside the ransomware crews, C2 infrastructure and forum chatter that reference it, query it through the API and pull it into your SIEM over TAXII.
Related vulnerabilities
Same products first, then exploited flaws of the same weakness class.
Source: NIST National Vulnerability Database (record CVE-2022-21661), CISA KEV, FIRST EPSS (scores of 2026-09-24). This page is refreshed as NVD updates the record.