Skip to contentSkip to conversation

CVE-2023-4233 and CVE-2023-4234

PATCH Applied Denis Grigorev 2 participants 5 messages Dec 21, 2023 – Dec 22, 2023

lore
Share & tools
lore
#0 lore raw

cover CVE-2023-4233 and CVE-2023-4234

Hello,

The following patches prevent possible buffer overflow during SMS decoding.

There are corresponding bug reports on Red Hat Bugzilla:

* https://bugzilla.redhat.com/show_bug.cgi?id=2255396
* https://bugzilla.redhat.com/show_bug.cgi?id=2255399

Denis Grigorev (2):
smsutil: Check that address fits in memory
smsutil: Check that submit report fits in memory

 src/smsutil.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 smsutil: Check that address fits in memory

This addresses CVE-2023-4233.

---
 src/smsutil.c | 4 ++++
 1 file changed, 4 insertions(+)
src/smsutil.c +4 -0
index 8e57a065..e9551b0d 100644
@@ -647,6 +647,10 @@ gboolean sms_decode_address_field(const unsigned char *pdu, int len,
 	out->numbering_plan = bit_field(addr_type, 0, 4);
 
 	if (out->number_type != SMS_NUMBER_TYPE_ALPHANUMERIC) {
+		/* BCD number consumes half as much memory */
+		if (byte_len * 2 >= (int) sizeof(out->address))
+			return FALSE;
+
 		extract_bcd_number(pdu + *offset, byte_len, out->address);
 		*offset += byte_len;
 	} else {
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/2] smsutil: Check that address fits in memory

Hi Denis,

Quoted 10 lines · Denis Grigorev

This addresses CVE-2023-4233.

---
  src/smsutil.c | 4 ++++
  1 file changed, 4 insertions(+)
src/smsutil.c +0 -0
index 8e57a065..e9551b0d 100644

src/smsutil.c gboolean sms_decode_address_field(const unsigned char *pdu, int len, · line 651

Quoted 5 lines
src/smsutil.c +2 -0
@@ -647,6 +647,10 @@ gboolean sms_decode_address_field(const unsigned char *pdu, int len,
  	out->numbering_plan = bit_field(addr_type, 0, 4);
 
  	if (out->number_type != SMS_NUMBER_TYPE_ALPHANUMERIC) {
+		/* BCD number consumes half as much memory */
+		if (byte_len * 2 >= (int) sizeof(out->address))

Unfortunately this is not precise enough. The AddressValue field is limited to 10 bytes, or 20 bcd characters. sizeof(out->address) is 23 due to UTF8 representation of certain GSM characters. It might be better to check addr_len above instead.

src/smsutil.c gboolean sms_decode_address_field(const unsigned char *pdu, int len, · line 656

Quoted 5 lines
src/smsutil.c +2 -0
+			return FALSE;
+
  		extract_bcd_number(pdu + *offset, byte_len, out->address);
  		*offset += byte_len;
  	} else {

Regards,
-Denis

#3 lore raw

PATCH 2/2 smsutil: Check that submit report fits in memory

In reply to Denis Grigorev

This addresses CVE-2023-4234.

---
 src/smsutil.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/smsutil.c +6 -0
index e9551b0d..6edf9ee6 100644
@@ -942,10 +942,16 @@ static gboolean decode_submit_report(const unsigned char *pdu, int len,
 			return FALSE;
 
 		if (out->type == SMS_TYPE_SUBMIT_REPORT_ERROR) {
+			if (expected > (int) sizeof(out->submit_err_report.ud))
+				return FALSE;
+
 			out->submit_err_report.udl = udl;
 			memcpy(out->submit_err_report.ud,
 					pdu + offset, expected);
 		} else {
+			if (expected > (int) sizeof(out->submit_ack_report.ud))
+				return FALSE;
+
 			out->submit_ack_report.udl = udl;
 			memcpy(out->submit_ack_report.ud,
 					pdu + offset, expected);
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH 2/2] smsutil: Check that submit report fits in memory

Hi Denis,

Quoted 5 lines · Denis Grigorev

This addresses CVE-2023-4234.

---
  src/smsutil.c | 6 ++++++
  1 file changed, 6 insertions(+)

Applied, thanks.

Regards,
-Denis