Skip to main content
Vulnerability Database/CVE-2024-57982

CVE-2024-57982: Linux Kernel Use-After-Free Vulnerability

CVE-2024-57982 is a use-after-free vulnerability in the Linux Kernel xfrm state lookup mechanism that can cause out-of-bounds reads during parallel operations. This article covers technical details, affected versions, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-57982 Overview

CVE-2024-57982 is an out-of-bounds read vulnerability in the Linux kernel's xfrm (IPsec transform) state management subsystem. The flaw occurs because state lookup and hash table resize operations can run in parallel. The xfrm_state_hash_generation seqlock ensures retries, but the hash helper functions can observe an hmask value that is too large for the newly assigned hlist array. This mismatch produces an out-of-bounds read in xfrm_dst_hash() during RCU-side lookups. The issue affects IPsec-enabled Linux systems and is categorized under [CWE-125] Out-of-Bounds Read.

Critical Impact

A local user can trigger an out-of-bounds read in the kernel xfrm state hash table, leading to kernel memory disclosure or system crash on IPsec-enabled hosts.

Affected Products

  • Linux Kernel (upstream mainline branches prior to the fix commits)
  • Linux Kernel stable branches containing the pre-patch xfrm state hashing code
  • Distributions shipping vulnerable kernels with IPsec/xfrm enabled

Discovery Timeline

  • 2025-02-27 - CVE-2024-57982 published to NVD
  • 2026-08-04 - Last updated in NVD database

Technical Details for CVE-2024-57982

Vulnerability Analysis

The vulnerability resides in the Linux kernel xfrm state subsystem, which maintains IPsec security associations in a hash table indexed by destination address, source address, request ID, and address family. During a rehash operation, the kernel publishes a new state_bydst hlist pointer via rcu_assign_pointer() and then updates net->xfrm.state_hmask to the new mask value. These two writes are not atomic with respect to concurrent readers.

A concurrent lookup calls xfrm_dst_hash() to compute an index using the current state_hmask, then dereferences net->xfrm.state_bydst + h. If the reader observes the new (larger) hmask before the new state_bydst pointer, or the old pointer with the new mask, the computed hash index can exceed the actual array bounds. The result is a read past the end of the hlist array, exposing adjacent kernel memory or triggering a fault.

Root Cause

The root cause is inconsistent ordering between the publication of the resized hash table pointer and its associated hmask value. Readers under RCU can observe a mismatched pair, producing an out-of-bounds index. The fix prefetches state_hmask together with the associated pointers so that the xfrm_state_hash_generation seqlock retry guarantees a consistent snapshot. Lockdep assertions are added to existing helpers such as xfrm_dst_hash() to document that they are safe only on the insert side, not the RCU reader side.

Attack Vector

Exploitation requires local access with low privileges on a host that uses IPsec. An attacker races state lookups against hash table resize events to coerce readers into observing an inconsistent hmask/pointer pair. Successful races produce out-of-bounds kernel reads, which may leak sensitive kernel memory or crash the system. No user interaction is required.

// No verified public exploit code is available for CVE-2024-57982.
// Refer to the upstream commits listed under Patch Information for the
// authoritative fix and affected code paths in net/xfrm/xfrm_state.c.

Detection Methods for CVE-2024-57982

Indicators of Compromise

  • Unexpected kernel oops or KASAN: slab-out-of-bounds reports referencing xfrm_dst_hash, xfrm_src_hash, or __xfrm_state_lookup in dmesg.
  • Sporadic kernel panics on IPsec gateways coinciding with security association churn or rekey storms.
  • Anomalous local processes repeatedly invoking xfrm netlink operations that trigger state insertions and lookups.

Detection Strategies

  • Enable CONFIG_KASAN on test kernels to surface out-of-bounds reads in xfrm lookup paths during fuzzing or load testing.
  • Audit kernel version strings across the fleet and flag hosts running kernels predating the fix commits a16871c7832e, dd4c2a174994, and e952837f3ddb.
  • Correlate IPsec control-plane activity with kernel log entries referencing xfrm_state functions to identify abuse patterns.

Monitoring Recommendations

  • Forward kernel ring buffer (/dev/kmsg) and journalctl -k output to a central log platform and alert on xfrm function names in oops traces.
  • Monitor the rate of XFRMA_* netlink messages per process to detect abnormal state-table manipulation from unprivileged users.
  • Track kernel package versions on IPsec endpoints and VPN concentrators to confirm patch deployment status.

How to Mitigate CVE-2024-57982

Immediate Actions Required

  • Upgrade the Linux kernel to a version that includes the upstream fix commits a16871c7832e, dd4c2a174994, or e952837f3ddb from the stable tree.
  • Apply distribution security updates on all IPsec gateways, VPN concentrators, and hosts where xfrm is loaded.
  • Restrict local shell access on IPsec-enabled systems to trusted administrators to reduce exposure to the local attack vector.

Patch Information

The fix is published in the upstream Linux kernel stable tree. See the vendor commits: Kernel commit a16871c7832e, Kernel commit dd4c2a174994, Kernel commit e952837f3ddb, and the related Kernel commit b86dc510308d. Validate kernel ABI compatibility before deploying to production IPsec hosts.

Workarounds

  • Where patching is delayed, disable or unload the xfrm subsystem on hosts that do not require IPsec by blocklisting related modules.
  • Limit CAP_NET_ADMIN and administrative netlink access so that unprivileged users cannot drive xfrm state table churn.
  • Reduce the rate of security association rekeys and reloads to lower the probability of racing a hash table resize.
bash
# Verify running kernel version against patched commits
uname -r

# List loaded xfrm-related modules
lsmod | grep -E 'xfrm|esp|ah'

# Optional: prevent xfrm_user loading on hosts that do not use IPsec
echo 'blacklist xfrm_user' | sudo tee /etc/modprobe.d/disable-xfrm.conf

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.