Skip to contentSkip to conversation

frr: Fix CVE-2023-41358 and CVE-2023-38802

PATCH New nmali 1 participant 1 message Sep 5, 2023

lore
Share & tools
lore

nmali

author
#0 lore raw

PATCH 1/1 frr: Fix CVE-2023-41358 and CVE-2023-38802

From: Narpat Mali <[email protected]>

CVE-2023-41358:
An issue was discovered in FRRouting FRR through 9.0. bgpd/bgp_packet.c processes NLRIs if the attribute length is zero.

CVE-2023-38802:
FRRouting FRR 7.5.1 through 9.0 and Pica8 PICOS 4.3.3.2 allow a remote attacker to cause a denial of service via a crafted BGP update with a corrupted attribute 23 (Tunnel Encapsulation).

References:
https://nvd.nist.gov/vuln/detail/CVE-2023-41358
https://nvd.nist.gov/vuln/detail/CVE-2023-38802

---
 .../frr/frr/CVE-2023-38802.patch              | 136 ++++++++++++++++++
 .../frr/frr/CVE-2023-41358.patch              | 105 ++++++++++++++
 .../recipes-protocols/frr/frr_8.2.2.bb        |   2 +
 3 files changed, 243 insertions(+)
 create mode 100644 meta-networking/recipes-protocols/frr/frr/CVE-2023-38802.patch
 create mode 100644 meta-networking/recipes-protocols/frr/frr/CVE-2023-41358.patch
meta-networking/recipes-protocols/frr/frr/CVE-2023-38802.patch new file +136 -0
new file mode 100644
index 0000000000..b86407b3d7
@@ -0,0 +1,136 @@
+From f8a663076fc354914c57c861d4333779a296ea79 Mon Sep 17 00:00:00 2001
+From: Narpat Mali <[email protected]>
+Date: Mon, 4 Sep 2023 15:23:52 +0000
+Subject: [PATCH 2/2] bgpd: Use treat-as-withdraw for tunnel encapsulation
+ attribute
+
+Before this path we used session reset method, which is discouraged by rfc7606.
+
+Handle this as rfc requires.
+
+Signed-off-by: Donatas Abraitis <[email protected]>
+
+CVE: CVE-2023-38802
+
+Upstream-Status: Backport [https://github.com/FRRouting/frr/commit/bcb6b58d9530173df41d3a3cbc4c600ee0b4b186]
+
+Signed-off-by: Narpat Mali <[email protected]>
+---
+ bgpd/bgp_attr.c | 61 ++++++++++++++++++++-----------------------------
+ 1 file changed, 25 insertions(+), 36 deletions(-)
+
+diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
+index 5d06991e2..b10a60351 100644
+--- a/bgpd/bgp_attr.c
++++ b/bgpd/bgp_attr.c
+@@ -1310,6 +1310,7 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, uint8_t subcode,
+	case BGP_ATTR_LARGE_COMMUNITIES:
+	case BGP_ATTR_ORIGINATOR_ID:
+	case BGP_ATTR_CLUSTER_LIST:
++	case BGP_ATTR_ENCAP:
+		return BGP_ATTR_PARSE_WITHDRAW;
+	case BGP_ATTR_MP_REACH_NLRI:
+	case BGP_ATTR_MP_UNREACH_NLRI:
+@@ -2411,26 +2412,21 @@ bgp_attr_ipv6_ext_communities(struct bgp_attr_parser_args *args)
+ }
+
+ /* Parse Tunnel Encap attribute in an UPDATE */
+-static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
+-			  bgp_size_t length, /* IN: attr's length field */
+-			  struct attr *attr, /* IN: caller already allocated */
+-			  uint8_t flag,      /* IN: attr's flags field */
+-			  uint8_t *startp)
++static int bgp_attr_encap(struct bgp_attr_parser_args *args)
+ {
+-	bgp_size_t total;
+	uint16_t tunneltype = 0;
+-
+-	total = length + (CHECK_FLAG(flag, BGP_ATTR_FLAG_EXTLEN) ? 4 : 3);
++	struct peer *const peer = args->peer;
++	struct attr *const attr = args->attr;
++	bgp_size_t length = args->length;
++	uint8_t type = args->type;
++	uint8_t flag = args->flags;
+
+	if (!CHECK_FLAG(flag, BGP_ATTR_FLAG_TRANS)
+	    || !CHECK_FLAG(flag, BGP_ATTR_FLAG_OPTIONAL)) {
+-		zlog_info(
+-			"Tunnel Encap attribute flag isn't optional and transitive %d",
+-			flag);
+-		bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR,
+-					  BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR,
+-					  startp, total);
+-		return -1;
++		zlog_err("Tunnel Encap attribute flag isn't optional and transitive %d",
++			 flag);
++		return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
++					  args->total);
+	}
+
+	if (BGP_ATTR_ENCAP == type) {
+@@ -2438,12 +2434,11 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
+		uint16_t tlv_length;
+
+		if (length < 4) {
+-			zlog_info(
++			zlog_err(
+				"Tunnel Encap attribute not long enough to contain outer T,L");
+-			bgp_notify_send_with_data(
+-				peer, BGP_NOTIFY_UPDATE_ERR,
+-				BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, startp, total);
+-			return -1;
++			return bgp_attr_malformed(args,
++						  BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
++						  args->total);
+		}
+		tunneltype = stream_getw(BGP_INPUT(peer));
+		tlv_length = stream_getw(BGP_INPUT(peer));
+@@ -2473,13 +2468,11 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
+		}
+
+		if (sublength > length) {
+-			zlog_info(
+-				"Tunnel Encap attribute sub-tlv length %d exceeds remaining length %d",
+-				sublength, length);
+-			bgp_notify_send_with_data(
+-				peer, BGP_NOTIFY_UPDATE_ERR,
+-				BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, startp, total);
+-			return -1;
++			zlog_err("Tunnel Encap attribute sub-tlv length %d exceeds remaining length %d",
++				 sublength, length);
++			return bgp_attr_malformed(args,
++						  BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
++						  args->total);
+		}
+
+		/* alloc and copy sub-tlv */
+@@ -2527,13 +2520,10 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
+
+	if (length) {
+		/* spurious leftover data */
+-		zlog_info(
+-			"Tunnel Encap attribute length is bad: %d leftover octets",
+-			length);
+-		bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR,
+-					  BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
+-					  startp, total);
+-		return -1;
++		zlog_err("Tunnel Encap attribute length is bad: %d leftover octets",
++			 length);
++		return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
++					  args->total);
+	}
+
+	return 0;
+@@ -3332,8 +3322,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
+		case BGP_ATTR_VNC:
+ #endif
+		case BGP_ATTR_ENCAP:
+-			ret = bgp_attr_encap(type, peer, length, attr, flag,
+-					     startp);
++			ret = bgp_attr_encap(&attr_args);
+			break;
+		case BGP_ATTR_PREFIX_SID:
+			ret = bgp_attr_prefix_sid(&attr_args);
+--
+2.40.0
meta-networking/recipes-protocols/frr/frr/CVE-2023-41358.patch new file +105 -0

105 lines not on this page · raw message

meta-networking/recipes-protocols/frr/frr_8.2.2.bb +2 -0
index 1897eb2abd..703eedf9fe 100644
@@ -18,6 +18,8 @@ SRC_URI = "git://github.com/FRRouting/frr.git;protocol=https;branch=stable/8.2 \
            file://CVE-2022-43681.patch \
            file://CVE-2023-31489.patch \
            file://CVE-2023-31490.patch \
+           file://CVE-2023-41358.patch \
+           file://CVE-2023-38802.patch \
            file://frr.pam \
 	      "
 
Signature · 1 line
2.40.0