Skip to content

Commit 30b009d

Browse files
committed
netfilter: nft_ct: sanitize layer 3 and 4 protocol number in custom expectations
CVE: CVE-2024-26673 JIRA: https://issues.redhat.com/browse/RHEL-31345 Upstream Status: commit 8059918 commit 8059918 Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Mon Jan 29 13:12:33 2024 +0100 netfilter: nft_ct: sanitize layer 3 and 4 protocol number in custom expectations - Disallow families other than NFPROTO_{IPV4,IPV6,INET}. - Disallow layer 4 protocol with no ports, since destination port is a mandatory attribute for this object. Fixes: 857b460 ("netfilter: nft_ct: add ct expectations support") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Phil Sutter <psutter@redhat.com>
1 parent b24d261 commit 30b009d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

net/netfilter/nft_ct.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,31 @@ static int nft_ct_expect_obj_init(const struct nft_ctx *ctx,
11901190
if (tb[NFTA_CT_EXPECT_L3PROTO])
11911191
priv->l3num = ntohs(nla_get_be16(tb[NFTA_CT_EXPECT_L3PROTO]));
11921192

1193+
switch (priv->l3num) {
1194+
case NFPROTO_IPV4:
1195+
case NFPROTO_IPV6:
1196+
if (priv->l3num != ctx->family)
1197+
return -EINVAL;
1198+
1199+
fallthrough;
1200+
case NFPROTO_INET:
1201+
break;
1202+
default:
1203+
return -EOPNOTSUPP;
1204+
}
1205+
11931206
priv->l4proto = nla_get_u8(tb[NFTA_CT_EXPECT_L4PROTO]);
1207+
switch (priv->l4proto) {
1208+
case IPPROTO_TCP:
1209+
case IPPROTO_UDP:
1210+
case IPPROTO_UDPLITE:
1211+
case IPPROTO_DCCP:
1212+
case IPPROTO_SCTP:
1213+
break;
1214+
default:
1215+
return -EOPNOTSUPP;
1216+
}
1217+
11941218
priv->dport = nla_get_be16(tb[NFTA_CT_EXPECT_DPORT]);
11951219
priv->timeout = nla_get_u32(tb[NFTA_CT_EXPECT_TIMEOUT]);
11961220
priv->size = nla_get_u8(tb[NFTA_CT_EXPECT_SIZE]);

0 commit comments

Comments
 (0)