{
  "id": "CVE-2025-39797",
  "url": "https://poc.griffinguard.io/cve/CVE-2025-39797",
  "published_at": "2025-09-12T15:59:33.639Z",
  "title": "xfrm: Duplicate SPI Handling",
  "vendor": "Linux",
  "product": "Linux",
  "cvss": {
    "score": 7.8,
    "source": "nvd",
    "vector": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  },
  "kev": {
    "in_kev": false,
    "added_at": null,
    "days_after_publication": null
  },
  "first_poc": null,
  "poc_repo_count": 0,
  "exploit_count": 0,
  "suspicious_repo_count": 0,
  "edge_device": null,
  "description": "In the Linux kernel, the following vulnerability has been resolved:\n\nxfrm: Duplicate SPI Handling\n\nThe issue originates when Strongswan initiates an XFRM_MSG_ALLOCSPI\nNetlink message, which triggers the kernel function xfrm_alloc_spi().\nThis function is expected to ensure uniqueness of the Security Parameter\nIndex (SPI) for inbound Security Associations (SAs). However, it can\nreturn success even when the requested SPI is already in use, leading\nto duplicate SPIs assigned to multiple inbound SAs, differentiated\nonly by their destination addresses.\n\nThis behavior causes inconsistencies during SPI lookups for inbound packets.\nSince the lookup may return an arbitrary SA among those with the same SPI,\npacket processing can fail, resulting in packet drops.\n\nAccording to RFC 4301 section 4.4.2 , for inbound processing a unicast SA\nis uniquely identified by the SPI and optionally protocol.\n\nReproducing the Issue Reliably:\nTo consistently reproduce the problem, restrict the available SPI range in\ncharon.conf : spi_min = 0x10000000 spi_max = 0x10000002\nThis limits the system to only 2 usable SPI values.\nNext, create more than 2 Child SA. each using unique pair of src/dst address.\nAs soon as the 3rd Child SA is initiated, it will be assigned a duplicate\nSPI, since the SPI pool is already exhausted.\nWith a narrow SPI range, the issue is consistently reproducible.\nWith a broader/default range, it becomes rare and unpredictable.\n\nCurrent implementation:\nxfrm_spi_hash() lookup function computes hash using daddr, proto, and family.\nSo if two SAs have the same SPI but different destination addresses, then\nthey will:\na. Hash into different buckets\nb. Be stored in different linked lists (byspi + h)\nc. Not be seen in the same hlist_for_each_entry_rcu() iteration.\nAs a result, the lookup will result in NULL and kernel allows that Duplicate SPI\n\nProposed Change:\nxfrm_state_lookup_spi_proto() does a truly global search - across all states,\nregardless of hash bucket and matches SPI and proto.",
  "cpes": [
    "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*"
  ],
  "cvss_by_source": {
    "nvd": 7.8
  },
  "repos": [],
  "remediation": {
    "affected": [
      {
        "vendor": "Linux",
        "product": "Linux",
        "ranges": [
          "\u003e= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \u003c fb58962aa3b9359988c7b5b15a971fd9ad5b0ecd",
          "\u003e= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \u003c 3d8090bb53424432fa788fe9a49e8ceca74f0544",
          "\u003e= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \u003c 2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38",
          "\u003e= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \u003c c67d4e7a8f90fb6361ca89d4d5c9a28f4e935e47",
          "\u003e= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \u003c 29e9158f91f99057dbd35db5e8674d93b38549fe",
          "\u003e= 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2, \u003c 94f39804d891cffe4ce17737d295f3b195bc7299"
        ],
        "fixed_in": [
          "fb58962aa3b9359988c7b5b15a971fd9ad5b0ecd",
          "3d8090bb53424432fa788fe9a49e8ceca74f0544",
          "2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38",
          "c67d4e7a8f90fb6361ca89d4d5c9a28f4e935e47",
          "29e9158f91f99057dbd35db5e8674d93b38549fe",
          "94f39804d891cffe4ce17737d295f3b195bc7299"
        ]
      },
      {
        "vendor": "Linux",
        "product": "Linux",
        "ranges": [
          "2.6.12"
        ],
        "fixed_in": [
          "0",
          "6.1.191",
          "6.6.103",
          "6.12.43",
          "6.15.11",
          "6.16.2",
          "6.17"
        ]
      }
    ],
    "upgrade": [
      "Upgrade Linux to fb58962aa3b9359988c7b5b15a971fd9ad5b0ecd or 3d8090bb53424432fa788fe9a49e8ceca74f0544 or 2fc5b54368a1bf1d2d74b4d3b8eea5309a653e38 or c67d4e7a8f90fb6361ca89d4d5c9a28f4e935e47 or 29e9158f91f99057dbd35db5e8674d93b38549fe or 94f39804d891cffe4ce17737d295f3b195bc7299 or later.",
      "Upgrade Linux to 0 or 6.1.191 or 6.6.103 or 6.12.43 or 6.15.11 or 6.16.2 or 6.17 or later."
    ]
  },
  "exploit_refs": [],
  "hunt_profile": [],
  "rules": []
}
