# CVE-2019-18874: Double Free in psutil

> A double free vulnerability in psutil allows attackers to cause denial of service or potentially execute arbitrary code via refcount mishandling.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/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:** 12 Nov 2019
- **Updated:** 5 Aug 2024
- **Also known as:** ALPINE-CVE-2019-18874, ALSA-2021:4324, AZL-6810, DEBIAN-CVE-2019-18874, DLA-1998-1, GHSA-qfc5-mcwq-26q8, MGASA-2019-0370, OESA-2021-1412, PYSEC-2019-41, RHSA-2020:2583, RHSA-2020:2593, RHSA-2020:2635, RHSA-2021:4324, RLSA-2021:4324, UBUNTU-CVE-2019-18874, USN-4204-1

## What is CVE-2019-18874?

CVE-2019-18874 is a high-severity use after free vulnerability in n/a, published on 12 Nov 2019. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

psutil (aka python-psutil) through 5.6.5 can have a double free. This occurs because of refcount mishandling within a while or for loop that converts system data into a Python object.

Weakness: CWE-415 (Double Free)

## Which versions are affected by CVE-2019-18874?

3 open source packages ship an affected version, including psutil. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `psutil` | PyPI | All versions | 5.6.6 |
| `psutil` | PyPI | All versions | 5.6.6 |
| `psutil` | PyPI | All versions | 5.6.6 |
| `python3-psutil` | AlmaLinux:8 | All versions | 5.4.3-11.el8 |
| `python-psutil` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.4.3-11.el8 |
| `python-psutil-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.4.3-11.el8 |
| `python3-psutil` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.4.3-11.el8 |
| `python3-psutil-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.4.3-11.el8 |
| `python-psutil` | Red Hat:openshift:4.2::el7 | All versions | 0:5.6.6-1.el7ar |
| `python-psutil-debuginfo` | Red Hat:openshift:4.2::el7 | All versions | 0:5.6.6-1.el7ar |
| `python2-psutil` | Red Hat:openshift:4.2::el7 | All versions | 0:5.6.6-1.el7ar |
| `python-psutil` | Red Hat:openshift:4.3::el7 | All versions | 0:5.6.6-1.el7ar |
| `python-psutil-debuginfo` | Red Hat:openshift:4.3::el7 | All versions | 0:5.6.6-1.el7ar |
| `python2-psutil` | Red Hat:openshift:4.3::el7 | All versions | 0:5.6.6-1.el7ar |
| `python-psutil` | Red Hat:openshift:4.4::el7 | All versions | 0:5.6.6-1.el7ar |
| `python-psutil-debuginfo` | Red Hat:openshift:4.4::el7 | All versions | 0:5.6.6-1.el7ar |
| `python2-psutil` | Red Hat:openshift:4.4::el7 | All versions | 0:5.6.6-1.el7ar |
| `python-psutil` | Rocky Linux:8 | All versions | 0:5.4.3-11.el8 |

Products: Psutil Project Psutil.

## How do I fix CVE-2019-18874?

Upgrade psutil to 5.6.6 or later.

## Is CVE-2019-18874 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2019-18874 and fix it if it is affected.

What it is: CVE-2019-18874 is a high-severity use after free vulnerability in n/a, published on 12 Nov 2019. 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-2019-18874 in the wild and no public exploit code.

Affected packages and fixed versions:
- psutil (PyPI): affected all versions; fixed in 5.6.6
- psutil (PyPI): affected all versions; fixed in 5.6.6
- psutil (PyPI): affected all versions; fixed in 5.6.6

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

## Sources

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

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