CVE-2025-39965 xfrm: xfrm_alloc_spi shouldn't use 0 as SPI

High 7.8 Published Updated

A use-after-free vulnerability in the Linux kernel's xfrm subsystem allows attackers to potentially execute code or escalate privileges.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2025-39965?

CVE-2025-39965 is a high-severity use after free vulnerability in Linux kernel, published on 13 Oct 2025. It can only be exploited from the same machine or local network, with no action from the victim.

Official description

In the Linux kernel, the following vulnerability has been resolved:

xfrm: xfrm_alloc_spi shouldn't use 0 as SPI

x->id.spi == 0 means "no SPI assigned", but since commit 94f39804d891 ("xfrm: Duplicate SPI Handling"), we now create states and add them to the byspi list with this value.

__xfrm_state_delete doesn't remove those states from the byspi list, since they shouldn't be there, and this shows up as a UAF the next time we go through the byspi list.

Which versions are affected by CVE-2025-39965?

It affects 1 product.

Products include Linux kernel.

How do I fix CVE-2025-39965?

Apply the vendor's patch.

Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.

Is CVE-2025-39965 being exploited?

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

Public exploit code: 1 proofs of concept on GitHub.

All Linux kernel vulnerabilities

Sources

Also known as AZL-68457, BELL-CVE-2025-39965, DEBIAN-CVE-2025-39965, GHSA-jc8g-4mch-vjcv, ROOT-OS-DEBIAN-13-CVE-2025-39965, UBUNTU-CVE-2025-39965.

Is CVE-2025-39965 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free