Skip to contentSkip to conversation

package/ipmitool: fix CVE-2020-5208

PATCH New Heiko Thiery 3 participants 3 messages Sep 14, 2020 – Sep 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/ipmitool: fix CVE-2020-5208

Add several upstream patches that are made to fix this CVE. Since there is still no dated plan to release a new version add this bunch of patches.

Cc Peter Korsgaard <[email protected]>
---
 ...-Fix-buffer-overflow-vulnerabilities.patch | 132 ++++++++++++++++
 ...uffer-overflow-in-ipmi_spd_print_fru.patch |  52 +++++++
 ...er-overflow-in-ipmi_get_session_info.patch |  52 +++++++
 .../0011-channel-Fix-buffer-overflow.patch    |  41 +++++
 ...er-overflows-in-get_lan_param_select.patch |  92 ++++++++++++
 ...u-sdr-Fix-id_string-buffer-overflows.patch | 141 ++++++++++++++++++
 package/ipmitool/ipmitool.mk                  |   8 +
 7 files changed, 518 insertions(+)
 create mode 100644 package/ipmitool/0008-fru-Fix-buffer-overflow-vulnerabilities.patch
 create mode 100644 package/ipmitool/0009-fru-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch
 create mode 100644 package/ipmitool/0010-session-Fix-buffer-overflow-in-ipmi_get_session_info.patch
 create mode 100644 package/ipmitool/0011-channel-Fix-buffer-overflow.patch
 create mode 100644 package/ipmitool/0012-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch
 create mode 100644 package/ipmitool/0013-fru-sdr-Fix-id_string-buffer-overflows.patch
package/ipmitool/0008-fru-Fix-buffer-overflow-vulnerabilities.patch new file +132 -0
new file mode 100644
index 0000000000..a39713fdb1
@@ -0,0 +1,132 @@
+From d615cb6c39d401a569941be2a615176191afa7ac Mon Sep 17 00:00:00 2001
+From: Chrostoper Ertl <[email protected]>
+Date: Thu, 28 Nov 2019 16:33:59 +0000
+Subject: [PATCH] fru: Fix buffer overflow vulnerabilities
+
+Partial fix for CVE-2020-5208, see
+https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
+
+The `read_fru_area_section` function only performs size validation of
+requested read size, and falsely assumes that the IPMI message will not
+respond with more than the requested amount of data; it uses the
+unvalidated response size to copy into `frubuf`. If the response is
+larger than the request, this can result in overflowing the buffer.
+
+The same issue affects the `read_fru_area` function.
+
+[Retrieve from
+https://github.com/ipmitool/ipmitool/commit/e824c23316ae50beb7f7488f2055ac65e8b341f2]
+Signed-off-by: Heiko Thiery <[email protected]>
+---
+ lib/ipmi_fru.c | 33 +++++++++++++++++++++++++++++++--
+ 1 file changed, 31 insertions(+), 2 deletions(-)
+
+diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c
+index cf00eff..af99aa9 100644
+--- a/lib/ipmi_fru.c
++++ b/lib/ipmi_fru.c
+@@ -615,7 +615,10 @@ int
+ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
+ 			uint32_t offset, uint32_t length, uint8_t *frubuf)
+ {
+-	uint32_t off = offset, tmp, finish;
++	uint32_t off = offset;
++	uint32_t tmp;
++	uint32_t finish;
++	uint32_t size_left_in_buffer;
+ 	struct ipmi_rs * rsp;
+ 	struct ipmi_rq req;
+ 	uint8_t msg_data[4];
+@@ -628,10 +631,12 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
+ 
+ 	finish = offset + length;
+ 	if (finish > fru->size) {
++		memset(frubuf + fru->size, 0, length - fru->size);
+ 		finish = fru->size;
+ 		lprintf(LOG_NOTICE, "Read FRU Area length %d too large, "
+ 			"Adjusting to %d",
+ 			offset + length, finish - offset);
++		length = finish - offset;
+ 	}
+ 
+ 	memset(&req, 0, sizeof(req));
+@@ -667,6 +672,7 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
+ 		}
+ 	}
+ 
++	size_left_in_buffer = length;
+ 	do {
+ 		tmp = fru->access ? off >> 1 : off;
+ 		msg_data[0] = id;
+@@ -707,9 +713,18 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
+ 		}
+ 
+ 		tmp = fru->access ? rsp->data[0] << 1 : rsp->data[0];
++		if(rsp->data_len < 1
++		   || tmp > rsp->data_len - 1
++		   || tmp > size_left_in_buffer)
++		{
++			printf(" Not enough buffer size");
++			return -1;
++		}
++
+ 		memcpy(frubuf, rsp->data + 1, tmp);
+ 		off += tmp;
+ 		frubuf += tmp;
++		size_left_in_buffer -= tmp;
+ 		/* sometimes the size returned in the Info command
+ 		* is too large.  return 0 so higher level function
+ 		* still attempts to parse what was returned */
+@@ -742,7 +757,9 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
+ 			uint32_t offset, uint32_t length, uint8_t *frubuf)
+ {
+ 	static uint32_t fru_data_rqst_size = 20;
+-	uint32_t off = offset, tmp, finish;
++	uint32_t off = offset;
++	uint32_t tmp, finish;
++	uint32_t size_left_in_buffer;
+ 	struct ipmi_rs * rsp;
+ 	struct ipmi_rq req;
+ 	uint8_t msg_data[4];
+@@ -755,10 +772,12 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
+ 
+ 	finish = offset + length;
+ 	if (finish > fru->size) {
++		memset(frubuf + fru->size, 0, length - fru->size);
+ 		finish = fru->size;
+ 		lprintf(LOG_NOTICE, "Read FRU Area length %d too large, "
+ 			"Adjusting to %d",
+ 			offset + length, finish - offset);
++		length = finish - offset;
+ 	}
+ 
+ 	memset(&req, 0, sizeof(req));
+@@ -773,6 +792,8 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
+ 	if (fru->access && fru_data_rqst_size > 16)
+ #endif
+ 		fru_data_rqst_size = 16;
++
++	size_left_in_buffer = length;
+ 	do {
+ 		tmp = fru->access ? off >> 1 : off;
+ 		msg_data[0] = id;
+@@ -804,8 +825,16 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
+ 		}
+ 
+ 		tmp = fru->access ? rsp->data[0] << 1 : rsp->data[0];
++		if(rsp->data_len < 1
++		   || tmp > rsp->data_len - 1
++		   || tmp > size_left_in_buffer)
++		{
++			printf(" Not enough buffer size");
++			return -1;
++		}
+ 		memcpy((frubuf + off)-offset, rsp->data + 1, tmp);
+ 		off += tmp;
++		size_left_in_buffer -= tmp;
+ 
+ 		/* sometimes the size returned in the Info command
+ 		* is too large.  return 0 so higher level function
+-- 
+2.20.1
+
package/ipmitool/0009-fru-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch new file +52 -0

52 lines not on this page · raw message

package/ipmitool/0010-session-Fix-buffer-overflow-in-ipmi_get_session_info.patch new file +52 -0

52 lines not on this page · raw message

package/ipmitool/0011-channel-Fix-buffer-overflow.patch new file +41 -0

41 lines not on this page · raw message

package/ipmitool/0012-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch new file +92 -0

92 lines not on this page · raw message

package/ipmitool/0013-fru-sdr-Fix-id_string-buffer-overflows.patch new file +141 -0

141 lines not on this page · raw message

package/ipmitool/ipmitool.mk +8 -0
index 5254668877..123dd274f4 100644
@@ -10,6 +10,14 @@ IPMITOOL_SITE = http://downloads.sourceforge.net/project/ipmitool/ipmitool/$(IPM
 IPMITOOL_LICENSE = BSD-3-Clause
 IPMITOOL_LICENSE_FILES = COPYING
 
+# 0008-fru-Fix-buffer-overflow-vulnerabilities.patch
+# 0009-fru-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch
+# 0010-session-Fix-buffer-overflow-in-ipmi_get_session_info.patch
+# 0011-channel-Fix-buffer-overflow.patch
+# 0012-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch
+# 0013-fru-sdr-Fix-id_string-buffer-overflows.patch
+IPMITOOL_IGNORE_CVES += CVE-2020-5208
+
 ifeq ($(BR2_PACKAGE_IPMITOOL_LANPLUS),y)
 IPMITOOL_DEPENDENCIES += openssl
 IPMITOOL_CONF_OPTS += --enable-intf-lanplus
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 package/ipmitool: fix CVE-2020-5208

Quoted 6 lines · On Mon, 14 Sep 2020 15:20:55 +0200 Heiko Thiery <[email protected]> wrote:

Add several upstream patches that are made to fix this CVE. Since there is still no dated plan to release a new version add this bunch of patches.

Cc Peter Korsgaard <[email protected]>
Quoted 15 lines
---
 ...-Fix-buffer-overflow-vulnerabilities.patch | 132 ++++++++++++++++
 ...uffer-overflow-in-ipmi_spd_print_fru.patch |  52 +++++++
 ...er-overflow-in-ipmi_get_session_info.patch |  52 +++++++
 .../0011-channel-Fix-buffer-overflow.patch    |  41 +++++
 ...er-overflows-in-get_lan_param_select.patch |  92 ++++++++++++
 ...u-sdr-Fix-id_string-buffer-overflows.patch | 141 ++++++++++++++++++
 package/ipmitool/ipmitool.mk                  |   8 +
 7 files changed, 518 insertions(+)
 create mode 100644 package/ipmitool/0008-fru-Fix-buffer-overflow-vulnerabilities.patch
 create mode 100644 package/ipmitool/0009-fru-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch
 create mode 100644 package/ipmitool/0010-session-Fix-buffer-overflow-in-ipmi_get_session_info.patch
 create mode 100644 package/ipmitool/0011-channel-Fix-buffer-overflow.patch
 create mode 100644 package/ipmitool/0012-lanp-Fix-buffer-overflows-in-get_lan_param_select.patch
 create mode 100644 package/ipmitool/0013-fru-sdr-Fix-id_string-buffer-overflows.patch

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 package/ipmitool: fix CVE-2020-5208

In reply to Heiko Thiery
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Heiko" == Heiko Thiery <[email protected]> writes:

Add several upstream patches that are made to fix this CVE. Since there is still no dated plan to release a new version add this bunch of patches.

Cc Peter Korsgaard <[email protected]>

Committed to 2020.02.x, 2020.05.x and 2020.08.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard