# CVE-2021-23214: SQL injection in postgresql

> Man-in-the-middle attackers can inject arbitrary SQL queries during connection establishment in PostgreSQL when using specific trust or cert authentication modes.

- **Severity:** High 8.1 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 4 Mar 2022
- **Updated:** 3 Aug 2024
- **Also known as:** ALPINE-CVE-2021-23214, ALSA-2022:1830, AZL-8973, BIT-postgresql-2021-23214, CLEANSTART-2026-WT68849, CLSA-2022-1657814447, CLSA-2024-1712837808, DEBIAN-CVE-2021-23214, ECHO-75ea-a96e-c256, GHSA-467w-rrqc-395f, JLSEC-2026-29, RHSA-2022:1830, RLSA-2022:1830, UBUNTU-CVE-2021-23214

## What is CVE-2021-23214?

CVE-2021-23214 is a high-severity SQL injection vulnerability in Fedoraproject Fedora, published on 4 Mar 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

When the server is configured to use trust authentication with a clientcert requirement or to use cert authentication, a man-in-the-middle attacker can inject arbitrary SQL queries when a connection is first established, despite the use of SSL certificate verification and encryption.

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

## Which versions are affected by CVE-2021-23214?

1 open source package ship an affected version, including postgresql. It affects 6 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `postgresql` | Bitnami | All versions | 9.6.24, 10.19.0, 11.14.0, 12.9.0, 13.5.0, 14.0.1 |
| `postgresql` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-contrib` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-docs` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-plperl` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-plpython3` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-pltcl` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-server` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-server-devel` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-static` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-test` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-test-rpm-macros` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-upgrade` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql-upgrade-devel` | AlmaLinux:8 | All versions | 10.19-1.module_el8.6.0+2744+ce3fc19a |
| `postgresql` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-contrib` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-contrib-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-docs` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-docs-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-plperl` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-plperl-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-plpython3` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-plpython3-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-pltcl` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-pltcl-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-server` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-server-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-server-devel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-server-devel-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-static` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-test` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-test-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-test-rpm-macros` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-upgrade` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-upgrade-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-upgrade-devel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql-upgrade-devel-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:10.19-1.module+el8.6.0+13642+78853f5a |
| `postgresql` | Rocky Linux:8 | All versions | 0:10.19-1.module+el8.6.0+802+f92d3c38 |

Products: Fedoraproject Fedora, Postgresql Postgresql, Redhat Enterprise Linux, Redhat Enterprise Linux for Ibm Z Systems, Redhat Enterprise Linux for Power Little Endian, Redhat Software Collections.

## How do I fix CVE-2021-23214?

Upgrade postgresql to a fixed version for your release line: 9.6.24, 10.19.0, 11.14.0 or 12.9.0.

## Is CVE-2021-23214 being exploited?

There is no known exploitation of CVE-2021-23214 in the wild and no public exploit code.

## Other vulnerabilities in Fedoraproject Fedora

- [CVE-2024-4577](https://insights.sbomify.com/CVE-2024-4577/): PHP-CGI OS Command Injection (critical 9.8, exploited in the wild)
- [CVE-2021-39226](https://insights.sbomify.com/CVE-2021-39226/): Grafana Authentication Bypass (critical 9.8, exploited in the wild)
- [CVE-2019-5544](https://insights.sbomify.com/CVE-2019-5544/): VMware ESXi and Horizon DaaS OpenSLP Heap-Based Buffer Overflow (critical 9.8, exploited in the wild)
- [CVE-2024-4947](https://insights.sbomify.com/CVE-2024-4947/): Google Chromium V8 Type Confusion (critical 9.6, exploited in the wild)
- [CVE-2024-4671](https://insights.sbomify.com/CVE-2024-4671/): Google Chromium Visuals Use-After-Free (critical 9.6, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-23214 and fix it if it is affected.

What it is: CVE-2021-23214 is a high-severity SQL injection vulnerability in Fedoraproject Fedora, published on 4 Mar 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-23214 in the wild and no public exploit code.

Affected packages and fixed versions:
- postgresql (Bitnami): affected all versions; fixed in 9.6.24, 10.19.0, 11.14.0, 12.9.0, 13.5.0, 14.0.1

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-2021-23214/ (Markdown: https://insights.sbomify.com/CVE-2021-23214/index.md)
```

## Sources

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

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