|
| 1 | +From d1a916264c775d4bb42668de57be6645ca79c525 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Georg Gebauer <georg.gebauer@zeiss.com> |
| 3 | +Date: Fri, 26 Apr 2024 08:12:42 +0200 |
| 4 | +Subject: [PATCH] Fix CVE-2021-43612 heap overflow when reading SONMP packages |
| 5 | + |
| 6 | +By sending short SONMP packets, an attacker can make the decoder crash |
| 7 | +by reading too much data on the heap. SONMP packets are fixed in size, |
| 8 | +just ensure we get the enough bytes to contain a SONMP packet. |
| 9 | + |
| 10 | +References: |
| 11 | +* https://github.com/lldpd/lldpd/commit/73d42680fce8598324364dbb31b9bc3b8320adf7 |
| 12 | +* https://nvd.nist.gov/vuln/detail/CVE-2021-43612 |
| 13 | + |
| 14 | +Suggested-by: Vincent Bernat (vincent@bernat.ch) |
| 15 | +CVE: CVE-2021-43612 |
| 16 | +--- |
| 17 | + NEWS | 2 ++ |
| 18 | + src/daemon/protocols/sonmp.c | 2 +- |
| 19 | + src/daemon/protocols/sonmp.h | 2 +- |
| 20 | + tests/check_sonmp.c | 8 ++++---- |
| 21 | + 4 files changed, 8 insertions(+), 6 deletions(-) |
| 22 | + |
| 23 | +diff --git a/NEWS b/NEWS |
| 24 | +index 18b059f..d62b86b 100644 |
| 25 | +--- a/NEWS |
| 26 | ++++ b/NEWS |
| 27 | +@@ -4,6 +4,8 @@ lldpd (1.0.8) |
| 28 | + liblldpctl for malformed fields. |
| 29 | + + Fix memory leak when receiving LLDPU with duplicate fields. |
| 30 | + CVE-2020-27827. |
| 31 | ++ + Fix heap overflow when reading SONMP. CVE-2021-43612. |
| 32 | ++ Thanks to Jeremy Galindo for discovering this one. |
| 33 | + * Changes: |
| 34 | + + Enable "router" capability bit when IPv6 routing is enabled. |
| 35 | + |
| 36 | +diff --git a/src/daemon/protocols/sonmp.c b/src/daemon/protocols/sonmp.c |
| 37 | +index d2eed15..6c80cb0 100644 |
| 38 | +--- a/src/daemon/protocols/sonmp.c |
| 39 | ++++ b/src/daemon/protocols/sonmp.c |
| 40 | +@@ -311,7 +311,7 @@ sonmp_decode(struct lldpd *cfg, char *frame, int s, |
| 41 | + |
| 42 | + length = s; |
| 43 | + pos = (u_int8_t*)frame; |
| 44 | +- if (length < SONMP_SIZE) { |
| 45 | ++ if (length < SONMP_SIZE + 2*ETHER_ADDR_LEN + sizeof(u_int16_t)) { |
| 46 | + log_warnx("sonmp", "too short SONMP frame received on %s", hardware->h_ifname); |
| 47 | + goto malformed; |
| 48 | + } |
| 49 | +diff --git a/src/daemon/protocols/sonmp.h b/src/daemon/protocols/sonmp.h |
| 50 | +index 0e60106..ff7a720 100644 |
| 51 | +--- a/src/daemon/protocols/sonmp.h |
| 52 | ++++ b/src/daemon/protocols/sonmp.h |
| 53 | +@@ -24,7 +24,7 @@ |
| 54 | + #define LLC_ORG_NORTEL { 0x00, 0x00, 0x81 } |
| 55 | + #define LLC_PID_SONMP_HELLO 0x01a2 |
| 56 | + #define LLC_PID_SONMP_FLATNET 0x01a1 |
| 57 | +-#define SONMP_SIZE (2*ETHER_ADDR_LEN + sizeof(u_int16_t) + 8) |
| 58 | ++#define SONMP_SIZE 19 |
| 59 | + |
| 60 | + struct sonmp_chassis { |
| 61 | + int type; |
| 62 | +diff --git a/tests/check_sonmp.c b/tests/check_sonmp.c |
| 63 | +index 8c7a208..b1f18c8 100644 |
| 64 | +--- a/tests/check_sonmp.c |
| 65 | ++++ b/tests/check_sonmp.c |
| 66 | +@@ -33,7 +33,7 @@ START_TEST (test_send_sonmp) |
| 67 | + IEEE 802.3 Ethernet |
| 68 | + Destination: Bay-Networks-(Synoptics)-autodiscovery (01:00:81:00:01:00) |
| 69 | + Source: 5e:10:8e:e7:84:ad (5e:10:8e:e7:84:ad) |
| 70 | +- Length: 22 |
| 71 | ++ Length: 19 |
| 72 | + Logical-Link Control |
| 73 | + DSAP: SNAP (0xaa) |
| 74 | + IG Bit: Individual |
| 75 | +@@ -55,7 +55,7 @@ Nortel Networks / SynOptics Network Management Protocol |
| 76 | + IEEE 802.3 Ethernet |
| 77 | + Destination: Bay-Networks-(Synoptics)-autodiscovery (01:00:81:00:01:01) |
| 78 | + Source: 5e:10:8e:e7:84:ad (5e:10:8e:e7:84:ad) |
| 79 | +- Length: 22 |
| 80 | ++ Length: 19 |
| 81 | + Logical-Link Control |
| 82 | + DSAP: SNAP (0xaa) |
| 83 | + IG Bit: Individual |
| 84 | +@@ -76,13 +76,13 @@ Nortel Networks / SynOptics Network Management Protocol |
| 85 | + */ |
| 86 | + char pkt1[] = { |
| 87 | + 0x01, 0x00, 0x81, 0x00, 0x01, 0x00, 0x5e, 0x10, |
| 88 | +- 0x8e, 0xe7, 0x84, 0xad, 0x00, 0x16, 0xaa, 0xaa, |
| 89 | ++ 0x8e, 0xe7, 0x84, 0xad, 0x00, 0x13, 0xaa, 0xaa, |
| 90 | + 0x03, 0x00, 0x00, 0x81, 0x01, 0xa2, 0xac, 0x11, |
| 91 | + 0x8e, 0x25, 0x00, 0x00, 0x04, 0x01, 0x0c, 0x03, |
| 92 | + 0x01 }; |
| 93 | + char pkt2[] = { |
| 94 | + 0x01, 0x00, 0x81, 0x00, 0x01, 0x01, 0x5e, 0x10, |
| 95 | +- 0x8e, 0xe7, 0x84, 0xad, 0x00, 0x16, 0xaa, 0xaa, |
| 96 | ++ 0x8e, 0xe7, 0x84, 0xad, 0x00, 0x13, 0xaa, 0xaa, |
| 97 | + 0x03, 0x00, 0x00, 0x81, 0x01, 0xa1, 0xac, 0x11, |
| 98 | + 0x8e, 0x25, 0x00, 0x00, 0x04, 0x01, 0x0c, 0x03, |
| 99 | + 0x01 }; |
0 commit comments