# CVE-2025-39797: xfrm: Duplicate SPI Handling

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.25% (percentile 10, 2026-11-26)
- **Published:** 2025-09-12T15:59:33.639Z
- **Modified:** 2026-11-05T22:17:32.040Z

## Who should check

- Anyone running Linux \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< fb58962aa3b9359988c7b5b15a971fd9ad5b0ecd; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 3d8090bb53424432fa788fe9a49e8ceca74f0544; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< c67d4e7a8f90fb6361ca89d4d5c9a28f4e935e47; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 29e9158f91f99057dbd35db5e8674d93b38549fe; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 94f39804d891cffe4ce17737d295f3b195bc7299
- Anyone running Linux 2.6.12

## Description

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

xfrm: Duplicate SPI Handling

The issue originates when Strongswan initiates an XFRM\_MSG\_ALLOCSPI
Netlink message, which triggers the kernel function xfrm\_alloc\_spi().
This function is expected to ensure uniqueness of the Security Parameter
Index (SPI) for inbound Security Associations (SAs). However, it can
return success even when the requested SPI is already in use, leading
to duplicate SPIs assigned to multiple inbound SAs, differentiated
only by their destination addresses.

This behavior causes inconsistencies during SPI lookups for inbound packets.
Since the lookup may return an arbitrary SA among those with the same SPI,
packet processing can fail, resulting in packet drops.

According to RFC 4301 section 4.4.2 , for inbound processing a unicast SA
is uniquely identified by the SPI and optionally protocol.

Reproducing the Issue Reliably:
To consistently reproduce the problem, restrict the available SPI range in
charon.conf : spi\_min = 0x10000000 spi\_max = 0x10000002
This limits the system to only 2 usable SPI values.
Next, create more than 2 Child SA. each using unique pair of src/dst address.
As soon as the 3rd Child SA is initiated, it will be assigned a duplicate
SPI, since the SPI pool is already exhausted.
With a narrow SPI range, the issue is consistently reproducible.
With a broader/default range, it becomes rare and unpredictable.

Current implementation:
xfrm\_spi\_hash() lookup function computes hash using daddr, proto, and family.
So if two SAs have the same SPI but different destination addresses, then
they will:
a. Hash into different buckets
b. Be stored in different linked lists (byspi + h)
c. Not be seen in the same hlist\_for\_each\_entry\_rcu() iteration.
As a result, the lookup will result in NULL and kernel allows that Duplicate SPI

Proposed Change:
xfrm\_state\_lookup\_spi\_proto() does a truly global search - across all states,
regardless of hash bucket and matches SPI and proto.

## Affected and fixed versions

- Linux: \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< fb58962aa3b9359988c7b5b15a971fd9ad5b0ecd; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 3d8090bb53424432fa788fe9a49e8ceca74f0544; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< c67d4e7a8f90fb6361ca89d4d5c9a28f4e935e47; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 29e9158f91f99057dbd35db5e8674d93b38549fe; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 94f39804d891cffe4ce17737d295f3b195bc7299 (cvelist)
- Linux: 2.6.12 (cvelist)

## Mitigation

- Upgrade Linux to 94f39804d891cffe4ce17737d295f3b195bc7299 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2025-39797. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-39797.md
Affected: Linux >= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, < fb58962aa3b9359988c7b5b15a971fd9ad5b0ecd; >= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, < 3d8090bb53424432fa788fe9a49e8ceca74f0544; >= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, < 2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38; >= 1da177e4c3f41524e886b7f…
Fixed in: Linux 3d8090bb53424432fa788fe9a49e8ceca74f0544, Linux 2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38, Linux 29e9158f91f99057dbd35db5e8674d93b38549fe, Linux 94f39804d891cffe4ce17737d295f3b195bc7299

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2025-39797 being exploited?

There is no confirmed exploitation: CVE-2025-39797 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.25% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2025-39797?

High: CVSS 7.8 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

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

Linux \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< fb58962aa3b9359988c7b5b15a971fd9ad5b0ecd; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 3d8090bb53424432fa788fe9a49e8ceca74f0544; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< c67d4e7a8f90fb6361ca89d4d5c9a28f4e935e47; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 29e9158f91f99057dbd35db5e8674d93b38549fe; \>= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \< 94f39804d891cffe4ce17737d295f3b195bc7299; Linux 2.6.12.

### Is there a fix for CVE-2025-39797?

Yes. Fixed in Linux 3d8090bb53424432fa788fe9a49e8ceca74f0544, Linux 2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38, Linux 29e9158f91f99057dbd35db5e8674d93b38549fe, Linux 94f39804d891cffe4ce17737d295f3b195bc7299. Upgrade Linux to 94f39804d891cffe4ce17737d295f3b195bc7299 or later.

### How do I check if I'm affected by CVE-2025-39797?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/3d8090bb53424432fa788fe9a49e8ceca74f0544>
- patch: <https://git.kernel.org/stable/c/2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38>
- patch: <https://git.kernel.org/stable/c/c67d4e7a8f90fb6361ca89d4d5c9a28f4e935e47>
- patch: <https://git.kernel.org/stable/c/29e9158f91f99057dbd35db5e8674d93b38549fe>
- patch: <https://git.kernel.org/stable/c/94f39804d891cffe4ce17737d295f3b195bc7299>
- other: <https://git.kernel.org/stable/c/fb58962aa3b9359988c7b5b15a971fd9ad5b0ecd>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2025-39797>

HTML: <https://flawdb.com/CVE-2025-39797> · JSON: <https://flawdb.com/api/v1/entries/CVE-2025-39797>
