Bug 1218293 (CVE-2023-4232) - VUL-0: CVE-2023-4232: ofono: SMS Decoder Stack-based Buffer Overflow Remote Code Execution Vulnerability within the decode_status_report() function
Summary: VUL-0: CVE-2023-4232: ofono: SMS Decoder Stack-based Buffer Overflow Remote C...
Status: NEW
Alias: CVE-2023-4232
Product: openSUSE Distribution
Classification: openSUSE
Component: Security (show other bugs)
Version: Leap 15.6
Hardware: Other Other
: P3 - Medium : Major (vote)
Target Milestone: ---
Assignee: Martin Pluskal
QA Contact: Security Team bot
URL: https://smash.suse.de/issue/388808/
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-21 08:35 UTC by SMASH SMASH
Modified: 2023-12-21 09:15 UTC (History)
1 user (show)

See Also:
Found By: Security Response Team
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description SMASH SMASH 2023-12-21 08:35:03 UTC
ofono is a Open Source Telephony on Linux stack overflow bug is triggered within the decode_status_report() 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 decode_submit(), but they forgot it in decode_status_report() this is a variant from ZDI-CAN-20971 partial code path is here
    - at_cmt_notify()
    - ofono_sms_deliver_notify()
    - sms_decode()
    - decode_status_report()
```

~~~C++
static gboolean decode_status_report(const unsigned char *pdu, int len,
                                        struct sms *out) { ...
        if (out->status_report.pi & 0x04) {
                int expected;

                if (!next_octet(pdu, len, &offset, &out->status_report.udl))
                        return FALSE;

                expected = sms_udl_in_bytes(out->status_report.udl,
                                                out->status_report.dcs);

                if ((len - offset) < expected)
                        return FALSE;

                memcpy(out->status_report.ud, pdu + offset, expected);          // overflow here, expected is from SMS PDU
        }

        return TRUE;
}
~~~

ASAN report
```
=================================================================
==118708==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffffffe26c at pc 0x7ffff7849846 bp 0x7fffffffdf50 sp 0x7fffffffd6f8 WRITE of size 224 at 0x7fffffffe26c thread T0
    #0 0x7ffff7849845 in __interceptor_memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
    #1 0x555555940bb5 in decode_status_report src/smsutil.c:1077
    #2 0x55555594449c in sms_decode src/smsutil.c:1571
    #3 0x5555558e008d in main src/main.c:225
    #4 0x7ffff742350f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #5 0x7ffff74235c8 in __libc_start_main_impl ../csu/libc-start.c:381
    #6 0x55555567f274 in _start (/root/ofono/src/ofonod+0x12b274)

Address 0x7fffffffe26c 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/sanitizer_common/sanitizer_common_interceptors.inc:827 in __interceptor_memcpy Shadow bytes around the buggy address:
  0x10007fff7bf0: 00 00 f1 f1 f1 f1 f1 f1 01 f2 04 f3 f3 f3 00 00
  0x10007fff7c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1
  0x10007fff7c10: f1 f1 04 f3 f3 f3 00 00 00 00 00 00 00 00 00 00
  0x10007fff7c20: 00 00 00 00 00 00 f1 f1 f1 f1 f1 f1 00 00 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[04]f3 f3
  0x10007fff7c50: f3 f3 f3 f3 f3 f3 00 00 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
==118708==ABORTING
```

References:
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2023-4232
https://bugzilla.redhat.com/show_bug.cgi?id=2255394
https://www.zerodayinitiative.com/advisories/ZDI-23-1860/