# CVE-2022-31625: Freeing unallocated memory in php_pgsql_free_params()

> Attackers can trigger remote code execution or denial of service in PHP applications using the PostgreSQL extension by supplying invalid query parameters.

- **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:** 16 Jun 2022
- **Updated:** 16 Sep 2024
- **Also known as:** ALSA-2022:6158, BIT-libphp-2022-31625, BIT-php-2022-31625, BIT-php-min-2022-31625, CLSA-2022-1658171149, CLSA-2022-1658171795, DEBIAN-CVE-2022-31625, ECHO-3ffd-e167-50cd, GHSA-wg63-8xjw-5wvx, RHSA-2022:6158, RLSA-2022:6158, UBUNTU-CVE-2022-31625, USN-5479-3

## What is CVE-2022-31625?

CVE-2022-31625 is a high-severity memory corruption vulnerability in Debian Debian Linux, published on 16 Jun 2022. An attacker can exploit it over the internet without logging in, 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 using Postgres database extension, supplying invalid parameters to the parametrized query may lead to PHP attempting to free memory using uninitialized data as pointers. This could lead to RCE vulnerability or denial of service.

Weakness: CWE-763 (Release of Invalid Pointer or Reference), CWE-824 (Access of Uninitialized Pointer), CWE-590 (Free of Memory not on the Heap)

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

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.18-1.module_el8.6.0+2750+78feabcb |
| `libzip` | AlmaLinux:8 | All versions | 1.6.1-1.module_el8.6.0+2750+78feabcb |
| `libzip-devel` | AlmaLinux:8 | All versions | 1.6.1-1.module_el8.6.0+2750+78feabcb |
| `libzip-tools` | AlmaLinux:8 | All versions | 1.6.1-1.module_el8.6.0+2750+78feabcb |
| `php` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-bcmath` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-cli` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-common` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-dba` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-dbg` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-devel` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-embedded` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-enchant` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-ffi` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-fpm` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-gd` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-gmp` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-intl` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-json` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-ldap` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-mbstring` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-mysqlnd` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-odbc` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-opcache` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-pdo` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-pear` | AlmaLinux:8 | All versions | 1:1.10.12-1.module_el8.6.0+2750+78feabcb |
| `php-pecl-apcu` | AlmaLinux:8 | All versions | 5.1.18-1.module_el8.6.0+2750+78feabcb |
| `php-pecl-apcu-devel` | AlmaLinux:8 | All versions | 5.1.18-1.module_el8.6.0+2750+78feabcb |
| `php-pecl-rrd` | AlmaLinux:8 | All versions | 2.0.1-1.module_el8.6.0+2750+78feabcb |
| `php-pecl-xdebug` | AlmaLinux:8 | All versions | 2.9.5-1.module_el8.6.0+2750+78feabcb |
| `php-pecl-zip` | AlmaLinux:8 | All versions | 1.18.2-1.module_el8.6.0+2750+78feabcb |
| `php-pgsql` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-process` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-snmp` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-soap` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-xml` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |
| `php-xmlrpc` | AlmaLinux:8 | All versions | 7.4.19-4.module_el8.6.0+3238+624bf8b8 |

Products: Debian Debian Linux, Php Php.

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

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

## Is CVE-2022-31625 being exploited?

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

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

What it is: CVE-2022-31625 is a high-severity memory corruption vulnerability in Debian Debian Linux, published on 16 Jun 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-2022-31625 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-31625/ (Markdown: https://insights.sbomify.com/CVE-2022-31625/index.md)
```

## Sources

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

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