Description | After updating my system and SOPE and SOGo to 5.8.2, there's a buffer overflow thrown with each HTTP request.
The following is logged (with debug enabled):
Apr 10 16:44:11 sogod [25728]: <0x0x55a43e9bf1b0[WOHttpAdaptor]> notified the watchdog that we are ready
Apr 10 16:44:16 sogod [25728]: |SOGo| starting method 'GET' on uri '/SOGo/'
Apr 10 16:44:16 sogod [25728]: <0x0x55a43e70c9e0[SOGoCache]> Cache cleanup interval set every 300.000000 seconds
Apr 10 16:44:16 sogod [25728]: <0x0x55a43e70c9e0[SOGoCache]> Using host(s) 'localhost' as server(s)
2023-04-10 16:44:16.402 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> SQL: BEGIN;
2023-04-10 16:44:16.402 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> query has no results.
2023-04-10 16:44:16.402 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> SQL: SELECT t1.c_creationdate, t1.c_id, t1.c_lastseen, t1.c_value FROM sogo_sessions_folder t1 WHERE t1.c_id='G0PcoWmXgZfgTqWY';
2023-04-10 16:44:16.402 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> query has results, entering fetch-mode.
2023-04-10 16:44:16.402 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> SQL: ROLLBACK;
2023-04-10 16:44:16.402 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> query has no results.
2023-04-10 16:44:16.403 sogod[25728:25728] MySQL4 connection established 0x0x55a43e9e4740
2023-04-10 16:44:16.403 sogod[25728:25728] ---------- -[MySQL4Channel openChannel]: <MySQL4Channel[0x0x55a43ea48770] connection=0x0x55a43e9e4740> opens channel count[1]
2023-04-10 16:44:16.403 sogod[25728:25728] MySQL4 channel 0x0x55a43ea48770 opened (connection=0x0x55a43e9e4740,sogo)
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43ea48770] connection=0x0x55a43e9e4740> SQL: BEGIN;
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43ea48770] connection=0x0x55a43e9e4740> query has no results.
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43ea48770] connection=0x0x55a43e9e4740> SQL: SELECT t1.c_creationdate, t1.c_id, t1.c_lastseen, t1.c_value FROM sogo_sessions_folder t1 WHERE t1.c_id='G0PcoWmXgZfgTqWY';
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43ea48770] connection=0x0x55a43e9e4740> query has results, entering fetch-mode.
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43ea48770] connection=0x0x55a43e9e4740> SQL: ROLLBACK;
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43ea48770] connection=0x0x55a43e9e4740> query has no results.
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> SQL: BEGIN;
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> query has no results.
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> SQL: UPDATE sogo_sessions_folder SET c_lastseen = 1681137856, c_creationdate = 1676146453, c_value = '<REDACTED>', c_id = 'G0PcoWmXgZfgTqWY' WHERE c_id='G0PcoWmXgZfgTqWY';
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> query has no results.
2023-04-10 16:44:16.403 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> SQL: COMMIT;
2023-04-10 16:44:16.404 sogod[25728:25728] <MySQL4Channel[0x0x55a43e988980] connection=0x0x55a43e6f6cf0> query has no results.
Apr 10 16:44:16 sogod [25728]: [WARN] <0x0x7fba66c916a0[WOxElemBuilder]> could not locate builders: WOxExtElemBuilder,WOxExtElemBuilder
Apr 10 16:44:16 sogod [25728]: |SOGo| constructed root-url: /SOGo/
Apr 10 16:44:16 sogod [25728]: |SOGo| setting root-url in context: /SOGo/
Apr 10 16:44:16 sogod [25728]: |SOGo| ROOT baseURL(no container, name=(null)):
own: /SOGo/
Apr 10 16:44:16 sogod [25728]: |SOGo| request took 0.010906 seconds to execute
buffer overflow detected : terminated
Apr 10 16:44:16 sogod [25472]: <0x0x55a43e996ce0[WOWatchDogChild]> child 25728 exited
Apr 10 16:44:16 sogod [25472]: <0x0x55a43e996ce0[WOWatchDogChild]> (terminated due to signal 6)
Apr 10 16:44:16 sogod [25472]: <0x0x55a43e996ce0[WOWatchDogChild]> avoiding to respawn child before 2023-04-10 16:44:16 +0200
Apr 10 16:44:17 sogod [25472]: <0x0x55a43e8cefd0[WOWatchDog]> child spawned with pid 25729
The stack trace from the debugger looks as follows:
Program received signal SIGABRT, Aborted.
0x00007fba660acd0c in ?? () from /lib64/libc.so.6
(gdb) bt
#0 0x00007fba660acd0c in ?? () from /lib64/libc.so.6
0000001 0x00007fba6605ad96 in raise () from /lib64/libc.so.6
0000002 0x00007fba660447fc in abort () from /lib64/libc.so.6
0000003 0x00007fba660a0666 in ?? () from /lib64/libc.so.6
0000004 0x00007fba6613e0d2 in fortify_fail () from /lib64/libc.so.6
0000005 0x00007fba6613c9b6 in __chk_fail () from /lib64/libc.so.6
0000006 0x00007fba6613c5d5 in snprintf_chk () from /lib64/libc.so.6
0000007 0x00007fba66ba530b in snprintf (fmt=0x7fba66bed7ba " %i %s\r\n", n=1024, __s=0x7ffc44b4a2b8 "")
at /usr/include/bits/stdio2.h:54
0000008 -[WOHttpTransaction deliverResponse:toRequest:onStream:] (self=0x55a43ea08830, _cmd=<optimized out>,
_response=0x55a43e8fcdc0, _request=0x55a43e7575f0, _out=0x55a43e855200) at WOHttpTransaction.m:752
0000009 0x00007fba66ba2da5 in -[WOHttpTransaction _sendResponse] (self=0x55a43ea08830, _cmd=<optimized out>)
at WOHttpTransaction.m:431
0000010 0x00007fba66ba38ab in -[WOHttpTransaction _run] (self=0x55a43ea08830, _cmd=<optimized out>)
at WOHttpTransaction.m:584
0000011 0x00007fba66ba4c5a in -[WOHttpTransaction run] (self=0x55a43ea08830, _cmd=<optimized out>)
at WOHttpTransaction.m:619
0000012 0x00007fba66b9feb2 in -[WOHttpAdaptor runConnection:] (self=0x55a43eb15fe0, _cmd=<optimized out>,
_socket=<optimized out>) at WOHttpAdaptor.m:373
0000013 0x00007fba66ba0e8c in -[WOHttpAdaptor _handleAcceptedConnection:] (self=self@entry=0x55a43eb15fe0,
_cmd=_cmd@entry=0x7fba66cc9d20 <_OBJC_SELECTOR_TABLE+1344>, _connection=<optimized out>) at WOHttpAdaptor.m:407
0000014 0x00007fba66ba11c0 in -[WOHttpAdaptor _handleConnection:] (self=0x55a43eb15fe0, _cmd=<optimized out>,
connection=0x55a43e8fcfb0) at WOHttpAdaptor.m:466
0000015 0x00007fba66ba0222 in -[WOHttpAdaptor acceptControlMessage:] (self=0x55a43eb15fe0, _cmd=<optimized out>,
aNotification=<optimized out>) at WOHttpAdaptor.m:505
0000016 0x00007fba664bac24 in ?? () from /usr/lib64/libgnustep-base.so.1.27
0000017 0x00007fba665d197e in ?? () from /usr/lib64/libgnustep-base.so.1.27
0000018 0x00007fba66506e02 in ?? () from /usr/lib64/libgnustep-base.so.1.27
0000019 0x00007fba66506a20 in ?? () from /usr/lib64/libgnustep-base.so.1.27
0000020 0x00007fba66b17376 in -[WOCoreApplication run] (self=0x55a43ead1710, _cmd=<optimized out>)
at WOCoreApplication.m:584
0000021 0x000055a43d907ee4 in -[SOGo run] (self=0x55a43ead1710, _cmd=<optimized out>) at SOGo.m:337
0000022 0x00007fba66b55bbb in -[WOWatchDog _spawnChild:] (self=0x55a43e8cefd0, _cmd=<optimized out>, child=0x55a43e996ce0)
at WOWatchDogApplicationMain.m:600
0000023 0x00007fba66b54bad in -[WOWatchDog _ensureChildren] (self=0x55a43e8cefd0, _cmd=<optimized out>)
at WOWatchDogApplicationMain.m:690
0000024 0x00007fba66b56635 in -[WOWatchDog run:argc:argv:] (self=0x55a43e8cefd0, _cmd=<optimized out>,
newAppName=<optimized out>, newArgC=<optimized out>, newArgV=<optimized out>) at WOWatchDogApplicationMain.m:942
0000025 0x00007fba66b56b82 in WOWatchDogApplicationMain (appName=appName@entry=0x55a43d90f200 <_OBJC_INSTANCE_3.1>,
argc=argc@entry=8, argv=argv@entry=0x7ffc44b4f5e8) at WOWatchDogApplicationMain.m:1051
0000026 0x000055a43d9062f7 in main (argc=8, argv=0x7ffc44b4f5e8, env=<optimized out>) at sogod.m:51
The source code in WOHttpTransaction.m:752 shows a buggy call to snprintf:
snprintf((char *)&(buf[slen]), sizeof(buf), " %i %s\r\n", s, r);
The size of "sizeof(buf)" is the full buffer size, but the address given to snprintf isn't the start of the buffer.
As a consequence, that call might actually write behind the end of the buffer.
(gdb) f 8
0000008 -[WOHttpTransaction deliverResponse:toRequest:onStream:] (self=0x55a43ea08830, _cmd=<optimized out>,
_response=0x55a43e8fcdc0, _request=0x55a43e7575f0, _out=0x55a43e855200) at WOHttpTransaction.m:752
752 in WOHttpTransaction.m
(gdb) p slen
$1 = 8 |
---|