# CVE-2025-31115: XZ has a heap-use-after-free bug in threaded .xz decoder

> A heap use-after-free bug in the XZ Utils multithreaded decoder allows attackers to cause a crash via invalid input.

- **Severity:** High 8.7 (`CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 3 Apr 2025
- **Updated:** 15 Oct 2026
- **Also known as:** ALPINE-CVE-2025-31115, ALSA-2025:7524, AZL-59497, BELL-CVE-2025-31115, DEBIAN-CVE-2025-31115, DSA-5895-1, ECHO-06a1-9520-94df, GHSA-6cc8-p5mm-29w2, HSEC-2025-0003, MGASA-2025-0131, OESA-2025-1430, OESA-2025-1431, RHSA-2025:7524, RLSA-2025:7524, SUSE-SU-2025:1137-1, SUSE-SU-2025:20553-1, SUSE-SU-2025:20590-1, UBUNTU-CVE-2025-31115, USN-7414-1, openSUSE-SU-2025:14984-1

## What is CVE-2025-31115?

CVE-2025-31115 is a high-severity use after free vulnerability in tukaani-project xz, published on 3 Apr 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

XZ Utils provide a general-purpose data-compression library plus command-line tools. In XZ Utils 5.3.3alpha to 5.8.0, the multithreaded .xz decoder in liblzma has a bug where invalid input can at least result in a crash. The effects include heap use after free and writing to an address based on the null pointer plus an offset. Applications and libraries that use the lzma_stream_decoder_mt function are affected. The bug has been fixed in XZ Utils 5.8.1, and the fix has been committed to the v5.4, v5.6, v5.8, and master branches in the xz Git repository. No new release packages will be made from the old stable branches, but a standalone patch is available that applies to all affected releases.

Weakness: CWE-826 (Premature Release of Resource During Expected Lifetime), CWE-476 (NULL Pointer Dereference), CWE-416 (Use After Free), CWE-366 (Race Condition within a Thread)

## Which versions are affected by CVE-2025-31115?

1 open source package ship an affected version, including xz-clib.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `xz-clib` | Hackage | From 5.6.3 | 5.8.1 |
| `xz` | AlmaLinux:10 | All versions | 1:5.6.2-4.el10_0 |
| `xz-devel` | AlmaLinux:10 | All versions | 1:5.6.2-4.el10_0 |
| `xz-libs` | AlmaLinux:10 | All versions | 1:5.6.2-4.el10_0 |
| `xz-lzma-compat` | AlmaLinux:10 | All versions | 1:5.6.2-4.el10_0 |
| `xz` | Red Hat:enterprise_linux:10.0 | All versions | 1:5.6.2-4.el10_0 |
| `xz-debuginfo` | Red Hat:enterprise_linux:10.0 | All versions | 1:5.6.2-4.el10_0 |
| `xz-debugsource` | Red Hat:enterprise_linux:10.0 | All versions | 1:5.6.2-4.el10_0 |
| `xz-devel` | Red Hat:enterprise_linux:10.0 | All versions | 1:5.6.2-4.el10_0 |
| `xz-libs` | Red Hat:enterprise_linux:10.0 | All versions | 1:5.6.2-4.el10_0 |
| `xz-libs-debuginfo` | Red Hat:enterprise_linux:10.0 | All versions | 1:5.6.2-4.el10_0 |
| `xz-lzma-compat` | Red Hat:enterprise_linux:10.0 | All versions | 1:5.6.2-4.el10_0 |
| `xz-lzma-compat-debuginfo` | Red Hat:enterprise_linux:10.0 | All versions | 1:5.6.2-4.el10_0 |
| `xz` | Rocky Linux:10 | All versions | 1:5.6.2-4.el10_0 |
| `xz` | SUSE:Linux Enterprise Module for Basesystem 15 SP6 | All versions | 5.4.1-150600.3.3.1 |
| `xz` | SUSE:Linux Micro 6.0 | All versions | 5.4.3-5.1 |
| `xz` | SUSE:Linux Micro 6.1 | All versions | 5.4.3-slfo.1.1_2.1 |
| `xz` | openSUSE:Leap 15.6 | All versions | 5.4.1-150600.3.3.1 |
| `xz` | openSUSE:Tumbleweed | All versions | 5.8.1-1.1 |

## How do I fix CVE-2025-31115?

Upgrade xz-clib to 5.8.1 or later.

## Is CVE-2025-31115 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-31115 and fix it if it is affected.

What it is: CVE-2025-31115 is a high-severity use after free vulnerability in tukaani-project xz, published on 3 Apr 2025. 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-2025-31115 in the wild and no public exploit code.

Affected packages and fixed versions:
- xz-clib (Hackage): affected from 5.6.3; fixed in 5.8.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-2025-31115/ (Markdown: https://insights.sbomify.com/CVE-2025-31115/index.md)
```

## Sources

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

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