Skip to content

CVE-2025-39964: Linux Kernel Crypto AF_ALG Concurrent Write Race Condition

HERMES

HERMES THREAT SCORE & OPERATIONAL EXPLOITABILITY

Target: Linux Kernel Crypto User API (crypto/af_alg.c / af_alg_sendmsg)
Confidence: 97%
88 / 100
HIGH

Measures real-world operational relevance, exploit weaponization, and active threat posture.

Dimension Breakdown
Exploitability 18 / 20
Threat Activity 18 / 20
Weaponization 17 / 20
Exposure 18 / 20
Prevalence 18 / 20
Impact 18 / 20
Exploit Maturity 17 / 20
Attack Chain Potential 17 / 20
โš–๏ธ Divergence & Operational Rationale

Classic CVSS v3.1 initially rated this flaw as low/moderate severity (3.3 to 5.5) under the theoretical assumption that it only triggered local denial of service. The Hermes Threat Score re-evaluates it at 88 HIGH following its weaponization by threat actors and formal addition to the CISA KEV Catalog on September 18, 2026.

๐Ÿ•ธ๏ธ Connected Knowledge Graph & Provenance

CVE-2025-39964: Linux Kernel Crypto AF_ALG Concurrent Write Race ConditionVULNERABILITY

Connected Nodes: 1
Active Relationships (Outgoing)
→ affectsPRODUCTLinux Kernel Core
98% VERY_HIGH

Software platform affected by security vulnerabilities and agentic attack patterns.

๐Ÿ” Why is this related? (Evidence & Provenance)

“Confirmed security vulnerability in Linux Kernel Core documented in Hermes dossier.”

Supporting Verified Evidence:

1. Technical Root Cause: The Lack of Exclusive Write Ownership

Section titled โ€œ1. Technical Root Cause: The Lack of Exclusive Write Ownershipโ€

The AF_ALG socket interface allows unprivileged userland processes to access in-kernel hardware-accelerated cryptographic ciphers (e.g. AES, SHA, ChaCha20).

When a process initiates data transmission via sendmsg(), the kernel routes the request to af_alg_sendmsg(). In vulnerable kernel versions, multiple threads could concurrently issue sendmsg() calls against the exact same socket context (struct af_alg_ctx):

sequenceDiagram
autonumber
actor ThreadA as Thread A (Attacker)
actor ThreadB as Thread B (Attacker)
participant Socket as AF_ALG Socket (af_alg_ctx)
participant SGL as Scatterlist Buffer Allocator
ThreadA->>Socket: sendmsg(size=4096)
ThreadB->>Socket: sendmsg(size=1024) [Concurrent race]
Note over Socket: ctx->used counter and sgl pointers modified simultaneously
Socket->>SGL: Asymmetric page allocation & partial release
ThreadA->>Socket: Thread A completes and prematurely frees shared page buffer
ThreadB->>Socket: Thread B writes into freed page (Use-After-Free / Slab Corruption)

Because af_alg_sendmsg() lacked an exclusive lock on write operations:

  1. ctx->used counters were modified non-atomically.
  2. The scatter-gather list (sgl) chained buffers became corrupted.
  3. Thread completion routines triggered premature deallocations while peer threads were still transmitting, resulting in Use-After-Free (UAF) and slab corruption.

The Linux kernel development team resolved the flaw by introducing an explicit write ownership lock ctx->write:

// crypto/af_alg.c fix snippet
if (ctx->write) {
err = -EBUSY;
goto unlock;
}
ctx->write = true;

This ensures that only a single userland thread can execute sendmsg() on any given AF_ALG socket instance at any point in time. Any concurrent write attempt receives an explicit -EBUSY error rather than corrupting memory state.


Look for reference count underflow or page table corruption originating in crypto/af_alg.c:

kernel BUG at crypto/af_alg.c:382!
refcount_t: underflow; use-after-free has been detected on af_alg socket.
Call Trace:
<TASK>
af_alg_free_resources+0x.../0x... [af_alg]
af_alg_release+0x.../0x... [af_alg]
sock_close+0x.../0x...
...

Detect suspicious creation of cryptographic sockets by non-root users:

Terminal window
-a always,exit -F arch=b64 -S socket -F a0=38 -k crypto_af_alg_creation

(On x86_64, socket family constant 38 corresponds to AF_ALG).

rule Linux_AF_ALG_Exploit_Artifact {
meta:
description = "Detects compiled binaries opening AF_ALG cryptographic sockets in multithreaded loops"
cve = "CVE-2025-39964"
author = "Hermes Codex Intelligence"
strings:
$af_alg_str1 = "skcipher" ascii
$af_alg_str2 = "cbc(aes)" ascii
$sock_call = { 48 C7 C7 26 00 00 00 } // mov rdi, 38 (AF_ALG)
condition:
uint32(0) == 0x464C457F and all of ($af_alg_str*) and $sock_call
}

A functional local privilege escalation exploit repository authored by researcher n1k0oowang is available on GitHub (n1k0oowang/CVE-2025-39964_EXP). The exploit orchestrates multithreaded concurrent invocations of af_alg_sendmsg() on shared AF_ALG cryptographic sockets, corrupting sgl scatterlist structures to trigger kernel heap use-after-free conditions and grooming the slab allocator to overwrite credential structures (commit_creds) for local root privilege escalation.


  1. Apply Updated Stable Kernels: Upgrade to Linux kernel versions 5.10.245, 5.15.194, 6.1.154, 6.6.108, 6.12.49, or 6.16.9 (and newer).
  2. Blacklist the Vulnerable Kernel Module (Immediate Workaround): If userland applications do not require direct kernel cryptographic acceleration:
    Terminal window
    echo "blacklist af_alg" > /etc/modprobe.d/disable-af-alg.conf
    echo "install af_alg /bin/true" >> /etc/modprobe.d/disable-af-alg.conf
  3. Container Hardening: Ensure containers drop unnecessary capabilities and block socket(AF_ALG) via seccomp filters.