# CVE-2022-31626: mysqlnd/pdo password buffer overflow

> A buffer overflow in PHP's mysqlnd driver allows remote code execution if an attacker controls the connection host and password length.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 16 Jun 2022
- **Updated:** 17 Sep 2024
- **Also known as:** ALSA-2022:5468, ALSA-2022:5904, BIT-libphp-2022-31626, BIT-php-2022-31626, BIT-php-min-2022-31626, DEBIAN-CVE-2022-31626, ECHO-615f-247f-a22b, GHSA-jfc6-9gw3-fhfg, RHSA-2022:5467, RHSA-2022:5468, RHSA-2022:5471, RHSA-2022:5904, RLSA-2022:5467, RLSA-2022:5468, RLSA-2022:5904, UBUNTU-CVE-2022-31626

## What is CVE-2022-31626?

CVE-2022-31626 is a high-severity memory corruption vulnerability in Debian Debian Linux, published on 16 Jun 2022. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

In PHP versions 7.4.x below 7.4.30, 8.0.x below 8.0.20, and 8.1.x below 8.1.7, when pdo_mysql extension with mysqlnd driver, if the third party is allowed to supply host to connect to and the password for the connection, password of excessive length can trigger a buffer overflow in PHP, which can lead to a remote code execution vulnerability.

Weakness: CWE-120 (Buffer Copy without Checking Size of Input)

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

3 open source packages ship an affected version, including libphp, php and php-min. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libphp` | Bitnami | From 7.4.0 | 7.4.30, 8.0.20, 8.1.7 |
| `php` | Bitnami | From 7.4.0 | 7.4.30, 8.0.20, 8.1.7 |
| `php-min` | Bitnami | From 7.4.0 | 7.4.30, 8.0.20, 8.1.7 |
| `apcu-panel` | AlmaLinux:8 | All versions | 5.1.20-1.module_el8.6.0+2739+efabdb8f |
| `libzip` | AlmaLinux:8 | All versions | 1.7.3-1.module_el8.6.0+2739+efabdb8f |
| `libzip-devel` | AlmaLinux:8 | All versions | 1.7.3-1.module_el8.6.0+2739+efabdb8f |
| `libzip-tools` | AlmaLinux:8 | All versions | 1.7.3-1.module_el8.6.0+2739+efabdb8f |
| `php-pear` | AlmaLinux:8 | All versions | 1:1.10.13-1.module_el8.6.0+3268+b150a051 |
| `php-pecl-apcu` | AlmaLinux:8 | All versions | 5.1.20-1.module_el8.6.0+2739+efabdb8f |
| `php-pecl-apcu-devel` | AlmaLinux:8 | All versions | 5.1.20-1.module_el8.6.0+2739+efabdb8f |
| `php-pecl-rrd` | AlmaLinux:8 | All versions | 2.0.3-1.module_el8.6.0+2739+efabdb8f |
| `php-pecl-xdebug3` | AlmaLinux:8 | All versions | 3.1.2-1.module_el8.6.0+2739+efabdb8f |
| `php-pecl-zip` | AlmaLinux:8 | All versions | 1.19.2-1.module_el8.6.0+2739+efabdb8f |
| `php` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-bcmath` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-cli` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-common` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-dba` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-dbg` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-devel` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-embedded` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-enchant` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-ffi` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-fpm` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-gd` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-gmp` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-intl` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-ldap` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-mbstring` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-mysqlnd` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-odbc` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-opcache` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-pdo` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-pgsql` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-process` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-snmp` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-soap` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `php-xml` | AlmaLinux:9 | All versions | 8.0.13-2.el9_0 |
| `apcu-panel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.1.18-1.module+el8.3.0+6678+b09f589e |
| `apcu-panel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.1.20-1.module+el8.6.0+13671+84712317 |

Products: Debian Debian Linux, Php Php.

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

Upgrade libphp to a fixed version for your release line: 7.4.30, 8.0.20 or 8.1.7.

## Is CVE-2022-31626 being exploited?

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

Public exploit code:

- https://github.com/amitlttwo/CVE-2022-31626 (github_poc): https://github.com/amitlttwo/CVE-2022-31626
- CVE-2022-31626, CVE-2024-2961, CVE-2019-6977, PHP security research (github_poc): https://github.com/HORKimhab/CVE-2022-31626-CVE-2024-2961-CVE-2019-6977

## 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-31626 and fix it if it is affected.

What it is: CVE-2022-31626 is a high-severity memory corruption vulnerability in Debian Debian Linux, published on 16 Jun 2022. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-31626 in the wild and no public exploit code.

Affected packages and fixed versions:
- libphp (Bitnami): affected from 7.4.0; fixed in 7.4.30, 8.0.20, 8.1.7
- php (Bitnami): affected from 7.4.0; fixed in 7.4.30, 8.0.20, 8.1.7
- php-min (Bitnami): affected from 7.4.0; fixed in 7.4.30, 8.0.20, 8.1.7

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

## Sources

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

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