1*4882a593SmuzhiyunFrom 1d479fc61feacc64adea64da9601f3dfcf6f74b3 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Chrostoper Ertl <chertl@microsoft.com> 3*4882a593SmuzhiyunDate: Thu, 28 Nov 2019 16:56:38 +0000 4*4882a593SmuzhiyunSubject: [PATCH] channel: Fix buffer overflow 5*4882a593SmuzhiyunMIME-Version: 1.0 6*4882a593SmuzhiyunContent-Type: text/plain; charset=UTF-8 7*4882a593SmuzhiyunContent-Transfer-Encoding: 8bit 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunPartial fix for CVE-2020-5208, see 10*4882a593Smuzhiyunhttps://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunThe `ipmi_get_channel_cipher_suites` function does not properly check 13*4882a593Smuzhiyunthe final response’s `data_len`, which can lead to stack buffer overflow 14*4882a593Smuzhiyunon the final copy. 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun[Retrieve from: 17*4882a593Smuzhiyunhttps://github.com/ipmitool/ipmitool/commit/9452be87181a6e83cfcc768b3ed8321763db50e4 18*4882a593Smuzhiyun 19*4882a593SmuzhiyunThe patch is slightly modified manually. The define 20*4882a593Smuzhiyun(MAX_CIPHER_SUITE_DATA_LEN) was introduced upstream in another patch. 21*4882a593SmuzhiyunReplace the define by the value 0x10.] 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunSigned-off-by: Heiko Thiery <heiko.thiery@gmail.com> 24*4882a593Smuzhiyun--- 25*4882a593Smuzhiyun lib/ipmi_channel.c | 5 ++++- 26*4882a593Smuzhiyun 1 file changed, 4 insertions(+), 1 deletion(-) 27*4882a593Smuzhiyun 28*4882a593Smuzhiyundiff --git a/lib/ipmi_channel.c b/lib/ipmi_channel.c 29*4882a593Smuzhiyunindex fab2e54..59ac227 100644 30*4882a593Smuzhiyun--- a/lib/ipmi_channel.c 31*4882a593Smuzhiyun+++ b/lib/ipmi_channel.c 32*4882a593Smuzhiyun@@ -413,7 +413,10 @@ ipmi_get_channel_cipher_suites(struct ipmi_intf *intf, const char *payload_type, 33*4882a593Smuzhiyun lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites"); 34*4882a593Smuzhiyun return -1; 35*4882a593Smuzhiyun } 36*4882a593Smuzhiyun- if (rsp->ccode > 0) { 37*4882a593Smuzhiyun+ if (rsp->ccode 38*4882a593Smuzhiyun+ || rsp->data_len < 1 39*4882a593Smuzhiyun+ || rsp->data_len > sizeof(uint8_t) + 0x10) 40*4882a593Smuzhiyun+ { 41*4882a593Smuzhiyun lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s", 42*4882a593Smuzhiyun val2str(rsp->ccode, completion_code_vals)); 43*4882a593Smuzhiyun return -1; 44*4882a593Smuzhiyun-- 45*4882a593Smuzhiyun2.20.1 46*4882a593Smuzhiyun 47