CVE-2023-4233: Ofono: sms decoder stack-based buffer overflow remote code execution vulnerability within the sms_decode_address_field() function
A flaw was found in ofono, an Open Source Telephony on Linux. A stack overflow bug is triggered within the smsdecodeaddressfield() function during the SMS PDU decoding. It is assumed that the attack scenario is accessible from a compromised modem, a malicious base station, or just SMS.
Other sources
ofono is a Open Source Telephony on Linux stack overflow bug is triggered within the smsdecodeaddressfield() function during SMS PDU decoding here assumed that the attack scenario is accessible from a compromised modem or possibily accessible from a malicious base station or just SMS
partial code path is here - atcmtnotify() - ofonosmsdelivernotify() - smsdecode() - decodedeliver() - smsdecodeaddressfield()
~~~C++ gboolean smsdecodeaddressfield(const unsigned char pdu, int len, int offset, gboolean sc, struct smsaddress out) { unsigned char addrlen; unsigned char addrtype; int bytelen;
if (!nextoctet(pdu, len, offset, &addrlen)) return FALSE;
if (sc && addrlen == 0) { out->address[0] = '\0'; return TRUE; }
if (!nextoctet(pdu, len, offset, &addrtype)) return FALSE;
if (sc) bytelen = addrlen - 1; else bytelen = (addrlen + 1) / 2;
if ((len - offset) < bytelen) return FALSE;
out->numbertype = bitfield(addrtype, 4, 3); out->numberingplan = bitfield(addrtype, 0, 4);
if (out->numbertype != SMSNUMBERTYPEALPHANUMERIC) { extractbcdnumber(pdu + offset, bytelen, out->address); // overflow within extractbcdnumber(), addrlen is from SMS PDU offset += bytelen; } else { ... }
void extractbcdnumber(const unsigned char buf, int len, char out) { static const char digitlut[] = "0123456789#abc\0"; unsigned char oct; int i;
for (i = 0; i < len; i++) { oct = buf[i];
out[i 2] = digitlut[oct & 0x0f]; out[i 2 + 1] = digitlut[(oct & 0xf0) >> 4]; }
out[i 2] = '\0'; } ~~~
ASAN report ================================================================= ==116978==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd18b788ac at pc 0x556e7631ff99 bp 0x7ffd18b78450 sp 0x7ffd18b78440 WRITE of size 1 at 0x7ffd18b788ac thread T0 #0 0x556e7631ff98 in extractbcdnumber src/smsutil.c:86 #1 0x556e76322c72 in smsdecodeaddressfield src/smsutil.c:650 #2 0x556e763237c3 in decodedeliver src/smsutil.c:761 #3 0x556e76329456 in smsdecode src/smsutil.c:1567 #4 0x556e762c508d in main src/main.c:225 #5 0x7f635c42350f in libcstartcallmain ../sysdeps/nptl/libcstartcallmain.h:58 #6 0x7f635c4235c8 in libcstartmainimpl ../csu/libc-start.c:381 #7 0x556e76064274 in start (/root/ofono/src/ofonod+0x12b274)
Address 0x7ffd18b788ac is located in stack of thread T0 at offset 316 in frame #0 0x556e762c4edd in main src/main.c:205
This frame has 1 object(s): [48, 316) 'sms1' (line 212) <== Memory access at offset 316 overflows this variable HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions are supported) SUMMARY: AddressSanitizer: stack-buffer-overflow src/smsutil.c:86 in extractbcdnumber Shadow bytes around the buggy address: 0x1000231670c0: 01 f2 04 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 0x1000231670d0: 00 00 00 00 00 00 f1 f1 f1 f1 04 f3 f3 f3 00 00 0x1000231670e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 0x1000231670f0: f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 00 00 0x100023167100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x100023167110: 00 00 00 00 00[04]f3 f3 f3 f3 f3 f3 f3 f3 00 00 0x100023167120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100023167130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100023167140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100023167150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100023167160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==116978==ABORTING
— Red Hat
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2023-4233?
CVE-2023-4233 has been classified as a critical vulnerability due to the potential for remote code execution stemming from a stack overflow condition.
How do I fix CVE-2023-4233?
To remediate CVE-2023-4233, update to ofono version 2.1 or later for Red Hat systems, or version 2.12-1 or later for Debian systems.
What systems are affected by CVE-2023-4233?
CVE-2023-4233 affects users running ofono versions prior to 2.1 on Red Hat and versions up to 1.31-3 on Debian.
What types of attacks can exploit CVE-2023-4233?
CVE-2023-4233 can be exploited via a compromised modem or a malicious base station targeting the SMS PDU decoding process.
Is CVE-2023-4233 something to be concerned about?
Yes, CVE-2023-4233 poses significant risks as it allows remote code execution, making it imperative to address immediately.