Skip to contentSkip to conversation

sctp: validate cookie AUTH state before use

PATCH New Artem Dinaburg 1 participant 1 message Nov 25

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp: validate cookie AUTH state before use

From: Jérémy Jean <[email protected]>
Date: Tue, 4 Aug 2026 20:00:42 +0000

[ Upstream commit 3dbb44d88b1e94dd31fe43588af7437b34b44d56 ]

When cookie authentication is disabled, COOKIE_ECHO restores fixed-size AUTH fields directly from peer-controlled cookie bytes. A forged RANDOM length, HMAC list, or CHUNKS list can then reach association consumers with lengths or identifiers that were never validated against the local backing arrays.

A forged RANDOM length can cause out-of-bounds reads during key-vector construction. A forged HMAC identifier also caused a 32-byte write past a zero-length AUTH chunk, providing a primitive for a local privilege escalation chain.

Validate the cookie's RANDOM, HMACS, and CHUNKS parameters at the cookie trust boundary before copying them into the association. Reject invalid types, malformed lengths, unsupported HMAC identifiers, HMAC lists without SHA1, and forbidden chunk ids.

Fixes bbd0d59809f9 ("[SCTP]: Implement the receive and verification of AUTH chunk")
Fixes 1f485649f529 ("[SCTP]: Implement SCTP-AUTH internals")

[ Backport to 6.18.y: context adjusted in include/net/sctp/auth.h, where
6.18.y still declares sctp_auth_init_hmacs(), and in sctp_unpack_cookie(), where 6.18.y still sets retval->c.peer_addr after copying the cookie. No code changes. ]

---
Hi,

Please apply this backport to 6.18.y. It fixes CVE-2026-74752.

The fix is in 6.6.160, 6.12.114 and 7.1.10, and in mainline since 7.2. It carries no stable tag; it reached those series through the Fixes-based selection but was not queued for 6.18.y. A three-way cherry-pick conflicts in include/net/sctp/auth.h, and the plain upstream diff also fails on context in sctp_unpack_cookie(). The code change is identical to upstream.

Compiled net/sctp/auth.o and net/sctp/sm_make_chunk.o for x86_64 with CONFIG_WERROR=y, both on 6.18.65 and on 6.18.65 with the current queue-6.18 patches (stable-queue 0fdc4475764). No kernel boot or runtime test was performed.

An LLM was used to prepare this backport and to check applicability and stable-queue history; I reviewed the result.

Thanks,
Artem Dinaburg

 include/net/sctp/auth.h  |  3 ++
 net/sctp/auth.c          | 75 ++++++++++++++++++++++++++++++++++++++++
 net/sctp/sm_make_chunk.c |  3 ++
 3 files changed, 81 insertions(+)
include/net/sctp/auth.h +3 -0
index 3d5879e08e78..fe45c8df210f 100644
@@ -22,6 +22,7 @@ struct sctp_endpoint;
 struct sctp_association;
 struct sctp_authkey;
 struct sctp_hmacalgo;
+struct sctp_cookie;
 
 /* Defines an HMAC algorithm supported by SCTP chunk authentication */
 struct sctp_hmac {
@@ -72,6 +73,8 @@ struct sctp_shared_key *sctp_auth_get_shkey(
 int sctp_auth_asoc_copy_shkeys(const struct sctp_endpoint *ep,
 				struct sctp_association *asoc,
 				gfp_t gfp);
+bool sctp_auth_verify_cookie_params(const struct sctp_endpoint *ep,
+				    const struct sctp_cookie *cookie);
 int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp);
 const struct sctp_hmac *sctp_auth_get_hmac(__u16 hmac_id);
 const struct sctp_hmac *
net/sctp/auth.c +75 -0

81 lines not on this page · raw message

net/sctp/sm_make_chunk.c +3 -0
index 3518f997a7b8..5d894b18ec39 100644
@@ -1867,6 +1867,9 @@ struct sctp_association *sctp_unpack_cookie(
 	/* Set up our peer's port number.  */
 	retval->peer.port = ntohs(chunk->sctp_hdr->source);
 
+	if (!sctp_auth_verify_cookie_params(ep, bear_cookie))
+		goto malformed;
+
 	/* Populate the association from the cookie.  */
 	memcpy(&retval->c, bear_cookie, sizeof(*bear_cookie));
 	retval->c.peer_addr = paddr;