CVE-2023-4235: Ofono: sms decoder stack-based buffer overflow remote code execution vulnerability within the decode_deliver_report() function
A flaw was found in ofono, an Open Source Telephony on Linux. A stack overflow bug is triggered within the decodedeliverreport() function during the SMS decoding. It is assumed that the attack scenario is accessible from a compromised modem, a malicious base station, or just SMS. There is a bound check for this memcpy length in decodesubmit(), but it was forgotten in decodedeliverreport().
Other sources
ofono is a Open Source Telephony on Linux stack overflow bug is triggered within the decodedeliverreport() function during SMS decoding here assumed that the attack scenario is accessible from a compromised modem or possibily accessible from a malicious base station or just SMS
there is a bound check for this memcpy length in decodesubmit(), but they forgot it in decodedeliverreport() this is a variant from ZDI-CAN-20971 partial code path is here - atcmtnotify() - ofonosmsdelivernotify() - smsdecode() - decodedeliverreport()
~~~C++ static gboolean decodedeliverreport(const unsigned char pdu, int len, struct sms out) { ... if (pi & 0x04) { int expected;
if (!nextoctet(pdu, len, &offset, &udl)) return FALSE;
expected = smsudlinbytes(udl, dcs);
if ((len - offset) < expected) return FALSE;
if (out->type == SMSTYPEDELIVERREPORTERROR) { out->delivererrreport.udl = udl; memcpy(out->delivererrreport.ud, pdu + offset, expected); // overflow here, expected is from SMS PDU } else { out->deliverackreport.udl = udl; memcpy(out->deliverackreport.ud, pdu + offset, expected); } }
return TRUE; } ~~~
ASAN report ================================================================= ==119365==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffffffe27c at pc 0x7ffff7849846 bp 0x7fffffffdf40 sp 0x7fffffffd6e8 WRITE of size 224 at 0x7fffffffe27c thread T0 #0 0x7ffff7849845 in interceptormemcpy ../../../../src/libsanitizer/sanitizercommon/sanitizercommoninterceptors.inc:827 #1 0x555555941dc6 in decodedeliverreport src/smsutil.c:1227 #2 0x5555559444df in smsdecode src/smsutil.c:1576 #3 0x5555558e008d in main src/main.c:225 #4 0x7ffff742350f in libcstartcallmain ../sysdeps/nptl/libcstartcallmain.h:58 #5 0x7ffff74235c8 in libcstartmainimpl ../csu/libc-start.c:381 #6 0x55555567f274 in start (/root/ofono/src/ofonod+0x12b274)
Address 0x7fffffffe27c is located in stack of thread T0 at offset 316 in frame #0 0x5555558dfedd 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/libsanitizer/sanitizercommon/sanitizercommoninterceptors.inc:827 in interceptormemcpy Shadow bytes around the buggy address: 0x10007fff7bf0: f1 f1 f1 f1 01 f2 01 f2 01 f2 01 f2 04 f3 f3 f3 0x10007fff7c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007fff7c10: f1 f1 f1 f1 04 f3 f3 f3 00 00 00 00 00 00 00 00 0x10007fff7c20: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 f1 f1 00 00 0x10007fff7c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x10007fff7c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00[04] 0x10007fff7c50: f3 f3 f3 f3 f3 f3 f3 f3 00 00 00 00 00 00 00 00 0x10007fff7c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007fff7c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007fff7c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007fff7c90: 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 ==119365==ABORTING
— Red Hat
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2023-4235?
CVE-2023-4235 is classified as a high severity vulnerability due to the potential for remote code execution via SMS.
How do I fix CVE-2023-4235?
To mitigate CVE-2023-4235, update the ofono package to version 2.1 on Red Hat or ensure it is updated in Debian systems to a version greater than 2.12-1.
What software is affected by CVE-2023-4235?
CVE-2023-4235 affects ofono versions up to 2.1 on Red Hat and versions up to 2.12-1 and 1.31-3 on Debian.
What causes the vulnerability in CVE-2023-4235?
CVE-2023-4235 is caused by a stack overflow in the decode_deliver_report() function during SMS decoding.
Can CVE-2023-4235 be exploited remotely?
Yes, CVE-2023-4235 can be exploited remotely through a compromised modem, a malicious base station, or an SMS message.