{"id":"CVE-2025-40331","state":"PUBLISHED","title":"sctp: Prevent TOCTOU out-of-bounds write","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nsctp: Prevent TOCTOU out-of-bounds write\n\nFor the following path not holding the sock lock,\n\n  sctp_diag_dump() -> sctp_for_each_endpoint() -> sctp_ep_dump()\n\nmake sure not to exceed bounds in case the address list has grown\nbetween buffer allocation (time-of-check) and write (time-of-use).","publishedAt":"2025-12-09T04:09:48.196Z","updatedAt":"2026-08-05T12:09:40.498Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"b106a68df0650b694b254427cd9250c04500edd3","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"3006959371007fc2eae4a078f823c680fa52de1a","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"72e3fea68eac8d088e44c3dd954e843478e9240e","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"584307275b2048991b2e8984962189b6cc0a9b85","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"c9119f243d9c0da3c3b5f577a328de3e7ffd1b42","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"2fe08fcaacb7eb019fa9c81db39b2214de216677","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"89eac1e150dbd42963e13d23828cb8c4e0763196","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"95aef86ab231f047bb8085c70666059b58f53c09","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["net/sctp/diag.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"4.7","status":"affected"},{"version":"0","status":"unaffected","lessThan":"4.7","versionType":"semver"},{"version":"5.4.302","status":"unaffected","lessThanOrEqual":"5.4.*","versionType":"semver"},{"version":"5.10.247","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.197","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.1.159","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.117","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.58","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.17.8","status":"unaffected","lessThanOrEqual":"6.17.*","versionType":"semver"},{"version":"6.18","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["net/sctp/diag.c"]}],"references":["https://git.kernel.org/stable/c/b106a68df0650b694b254427cd9250c04500edd3","https://git.kernel.org/stable/c/3006959371007fc2eae4a078f823c680fa52de1a","https://git.kernel.org/stable/c/72e3fea68eac8d088e44c3dd954e843478e9240e","https://git.kernel.org/stable/c/584307275b2048991b2e8984962189b6cc0a9b85","https://git.kernel.org/stable/c/c9119f243d9c0da3c3b5f577a328de3e7ffd1b42","https://git.kernel.org/stable/c/2fe08fcaacb7eb019fa9c81db39b2214de216677","https://git.kernel.org/stable/c/89eac1e150dbd42963e13d23828cb8c4e0763196","https://git.kernel.org/stable/c/95aef86ab231f047bb8085c70666059b58f53c09"],"weaknesses":[],"ingestedAt":"2026-10-29T20:09:09.358Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2025/40xxx/CVE-2025-40331.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2025-40331","state":"PUBLISHED","datePublished":"2025-12-09T04:09:48.196Z","dateUpdated":"2026-08-05T12:09:40.498Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2025-04-16T07:20:57.186Z"},"containers":{"cna":{"title":"sctp: Prevent TOCTOU out-of-bounds write","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nsctp: Prevent TOCTOU out-of-bounds write\n\nFor the following path not holding the sock lock,\n\n  sctp_diag_dump() -> sctp_for_each_endpoint() -> sctp_ep_dump()\n\nmake sure not to exceed bounds in case the address list has grown\nbetween buffer allocation (time-of-check) and write (time-of-use)."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"b106a68df0650b694b254427cd9250c04500edd3","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"3006959371007fc2eae4a078f823c680fa52de1a","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"72e3fea68eac8d088e44c3dd954e843478e9240e","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"584307275b2048991b2e8984962189b6cc0a9b85","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"c9119f243d9c0da3c3b5f577a328de3e7ffd1b42","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"2fe08fcaacb7eb019fa9c81db39b2214de216677","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"89eac1e150dbd42963e13d23828cb8c4e0763196","versionType":"git"},{"version":"8f840e47f190cbe61a96945c13e9551048d42cef","status":"affected","lessThan":"95aef86ab231f047bb8085c70666059b58f53c09","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["net/sctp/diag.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"4.7","status":"affected"},{"version":"0","status":"unaffected","lessThan":"4.7","versionType":"semver"},{"version":"5.4.302","status":"unaffected","lessThanOrEqual":"5.4.*","versionType":"semver"},{"version":"5.10.247","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.197","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.1.159","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.117","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.58","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.17.8","status":"unaffected","lessThanOrEqual":"6.17.*","versionType":"semver"},{"version":"6.18","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["net/sctp/diag.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/b106a68df0650b694b254427cd9250c04500edd3"},{"url":"https://git.kernel.org/stable/c/3006959371007fc2eae4a078f823c680fa52de1a"},{"url":"https://git.kernel.org/stable/c/72e3fea68eac8d088e44c3dd954e843478e9240e"},{"url":"https://git.kernel.org/stable/c/584307275b2048991b2e8984962189b6cc0a9b85"},{"url":"https://git.kernel.org/stable/c/c9119f243d9c0da3c3b5f577a328de3e7ffd1b42"},{"url":"https://git.kernel.org/stable/c/2fe08fcaacb7eb019fa9c81db39b2214de216677"},{"url":"https://git.kernel.org/stable/c/89eac1e150dbd42963e13d23828cb8c4e0763196"},{"url":"https://git.kernel.org/stable/c/95aef86ab231f047bb8085c70666059b58f53c09"}],"metrics":[{"cvssV3_1":{"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"},"scenarios":[{"lang":"en","value":"AV:L - Triggering requires local syscalls — a `NETLINK_SOCK_DIAG` dump request plus a concurrent `setsockopt(SCTP_SOCKOPT_BINDX_ADD)` on the attacker's own socket. A remote SCTP peer cannot drive the diag dump, so despite being in net/sctp this is the local netlink/diag surface.\nAC:L - The attacker owns both sides of the race — one thread hammers the diag dump, another calls sctp_bindx on its own endpoint — and the vulnerable window spans the entire unbounded write loop, which the attacker lengthens by pre-binding many addresses. Failed attempts are harmless and can be retried indefinitely.\nPR:L - No capability check exists anywhere on the sock_diag/inet_diag dump path (the `net_admin` flag only selects optional attributes), and sctp_do_bind only needs CAP_NET_BIND_SERVICE for ports below 1024, which the attacker avoids. Any unprivileged local user with an SCTP socket can do this, without namespaces.\nUI:N - The attacker creates the SCTP endpoint, issues the diag dump, and grows the address list entirely on its own. No victim action of any kind is involved.\nS:U - The corruption is confined to kernel heap memory managed by the same kernel security authority. No VM, IOMMU, or sandbox boundary is crossed.\nC:H - The same TOCTOU in the shrink direction leaves the tail of the reserved INET_DIAG_LOCALS attribute uninitialized and copies that kernel heap data straight to userspace, and the heap overflow itself corrupts skb_shared_info (frag_list/destructor_arg), which is readily leveraged into arbitrary kernel memory disclosure.\nI:H - This is a heap out-of-bounds write with attacker-chosen length — a single bindx call can append ~8000 addresses, yielding up to ~1 MB written past the reserved region — and partially attacker-controlled content, smashing skb_shared_info and adjacent slab objects, which is a strong path to control-flow hijack and privilege escalation.\nA:H - Overwriting skb_shared_info and neighbouring allocations with sockaddr data reliably produces oopses and kernel panics on subsequent skb handling. Any unprivileged user can repeat the attack at will."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T12:09:40.498Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.7","versionEndExcluding":"5.4.302"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.7","versionEndExcluding":"5.10.247"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.7","versionEndExcluding":"5.15.197"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.7","versionEndExcluding":"6.1.159"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.7","versionEndExcluding":"6.6.117"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.7","versionEndExcluding":"6.12.58"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.7","versionEndExcluding":"6.17.8"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.7","versionEndExcluding":"6.18"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"timestamp":"2026-06-16T19:58:03.978750Z","id":"CVE-2025-40331","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"partial"}],"role":"CISA Coordinator","version":"2.0.3"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2026-06-16T19:58:14.829Z"}}]}}}