# CVE-2022-21661: SQL injection in WordPress

> Attackers can exploit improper sanitization in WP_Query to perform SQL injection, potentially reading or modifying database contents.

- **Severity:** High 8.0 (`CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Jan 2022
- **Updated:** 9 Sep 2024
- **Also known as:** BIT-wordpress-2022-21661, BIT-wordpress-multisite-2022-21661, DEBIAN-CVE-2022-21661, GHSA-6676-cqfm-gw84, UBUNTU-CVE-2022-21661

## What is CVE-2022-21661?

CVE-2022-21661 is a high-severity SQL injection vulnerability in Debian Debian Linux, published on 6 Jan 2022. An attacker needs administrator access to exploit it, with no action from the victim.

### Official 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.

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command)

## Which versions are affected by CVE-2022-21661?

2 open source packages ship an affected version, including wordpress and wordpress-multisite. It affects 3 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `wordpress` | Bitnami | From 3.7.0 | 3.7.37, 3.8.37, 3.9.35, 4.0.34, 4.1.34, 4.2.31, 4.3.27, 4.4.26, 4.5.25, 4.6.22, 4.7.22, 4.8.18, 4.9.19, 5.0.15, 5.1.12, 5.2.14, 5.3.11, 5.4.9, 5.5.8, 5.6.7, 5.7.5, 5.8.3 |
| `wordpress-multisite` | Bitnami | From 3.7.0 | 3.7.37, 3.8.37, 3.9.35, 4.0.34, 4.1.34, 4.2.31, 4.3.27, 4.4.26, 4.5.25, 4.6.22, 4.7.22, 4.8.18, 4.9.19, 5.0.15, 5.1.12, 5.2.14, 5.3.11, 5.4.9, 5.5.8, 5.6.7, 5.7.5, 5.8.3 |

Products: Debian Debian Linux, Fedoraproject Fedora, Wordpress Wordpress.

## How do I fix CVE-2022-21661?

Upgrade wordpress to a fixed version for your release line: 3.7.37, 3.8.37, 3.9.35 or 4.0.34.

## Is CVE-2022-21661 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-21661 exists.

Public exploit code:

- WordPress WP_Query SQL Injection POC (github_poc): https://github.com/z92g/CVE-2022-21661
- https://github.com/purple-WL/wordpress-CVE-2022-21661 (github_poc): https://github.com/purple-WL/wordpress-CVE-2022-21661
- Wordpress 5.8.2  CVE-2022-21661 Vuln enviroment POC exploit (github_poc): https://github.com/0x4E0x650x6F/Wordpress-cve-CVE-2022-21661
- CVE-2022-21661 exp for Elementor custom skin. (github_poc): https://github.com/guestzz/CVE-2022-21661
- Study and exploit the vulnerability CVE-2022-21661 that allows SQL Injections through plugins POST requests to WordPress versions below 5.8.3. (github_poc): https://github.com/WellingtonEspindula/SSI-CVE-2022-21661
- A Python PoC of CVE-2022-21661, inspired from z92g's Go PoC (github_poc): https://github.com/sealldeveloper/CVE-2022-21661-PoC

## Other vulnerabilities in Debian Debian Linux

- [CVE-2015-3306](https://insights.sbomify.com/CVE-2015-3306/): ProFTPD Improper Access Control (critical 10.0, exploited in the wild)
- [CVE-2025-49113](https://insights.sbomify.com/CVE-2025-49113/): RoundCube Webmail Deserialization of Untrusted Data (critical 9.9, exploited in the wild)
- [CVE-2026-24061](https://insights.sbomify.com/CVE-2026-24061/): GNU InetUtils Argument Injection (critical 9.8, exploited in the wild)
- [CVE-2025-39682](https://insights.sbomify.com/CVE-2025-39682/): Linux Kernel Improper Check for Unusual or Exceptional Conditions (critical 9.8, exploited in the wild)
- [CVE-2024-9680](https://insights.sbomify.com/CVE-2024-9680/): Mozilla Firefox Use-After-Free (critical 9.8, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-21661 and fix it if it is affected.

What it is: CVE-2022-21661 is a high-severity SQL injection vulnerability in Debian Debian Linux, published on 6 Jan 2022. An attacker needs administrator access to exploit it, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-21661 exists.

Affected packages and fixed versions:
- wordpress (Bitnami): affected from 3.7.0; fixed in 3.7.37, 3.8.37, 3.9.35, 4.0.34, 4.1.34, 4.2.31, 4.3.27, 4.4.26, 4.5.25, 4.6.22, 4.7.22, 4.8.18, 4.9.19, 5.0.15, 5.1.12, 5.2.14, 5.3.11, 5.4.9, 5.5.8, 5.6.7, 5.7.5, 5.8.3
- wordpress-multisite (Bitnami): affected from 3.7.0; fixed in 3.7.37, 3.8.37, 3.9.35, 4.0.34, 4.1.34, 4.2.31, 4.3.27, 4.4.26, 4.5.25, 4.6.22, 4.7.22, 4.8.18, 4.9.19, 5.0.15, 5.1.12, 5.2.14, 5.3.11, 5.4.9, 5.5.8, 5.6.7, 5.7.5, 5.8.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-21661/ (Markdown: https://insights.sbomify.com/CVE-2022-21661/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-21661
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-21661
- OSV: https://osv.dev/vulnerability/CVE-2022-21661

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-21661/
Summaries are generated and may contain mistakes; the official description above is the record.
