All vulnerabilities · WordPress
WordPress WP_Query SQL Injection (CVE-2022-21661): Check Your WordPress Version
CVE-2022-21661CVSS 7.5
A SQL injection in WP_Query affected WordPress 3.7 to 5.8.2. See which releases are fixed in every branch and how to check the version your site shows.
Affected and fixed versions
WP_Query, the class WordPress uses to fetch posts, didn’t fully sanitize some of its input.
Themes and plugins that passed user input into a query could be used for SQL injection, reading or
changing database contents. WordPress fixed it in 5.8.3 in January 2022 and backported the fix to
every branch back to 3.7.
Who is affected
WordPress 3.7 to 5.8.2, except the patched releases of each branch (for example 5.7.5 or 4.9.19).
Sites with automatic background updates usually received the fix within days.
What our check looks at
We read the WordPress version in the page’s generator tag (WordPress 5.8.2) and compare it with
the affected ranges for its branch. Many sites remove that tag; then we can’t tell.
How to fix it
- Update WordPress (Dashboard → Updates), ideally to the current release.
- Keep automatic minor updates on; they deliver security fixes like this one.
- Remove the version from the page. Most security plugins do this, or add
remove_action('wp_head', 'wp_generator'); to your theme.
FAQ
Our site runs WordPress 5.7.5. Is it affected?
No, 5.7.5 contains the backported fix. But the 5.7 branch is long out of support; plan the update.
Does a security plugin protect us?
It can block known attack patterns, but only updating removes the flaw.
Official advisory
Last updated October 27, 2026 · This product uses data from the NVD API but is not endorsed or certified by the NVD.