Tenable has discovered multiple authenticated vulnerabilities in Mikrotik's RouterOS.
CVE-2018-1156: Stack buffer overflow in licupgr
The licupgr binary has a sprintf call that an authenticated user can use to trigger a remote stack buffer overflow. The sprintf is used on the following string:
GET /ssl_conn.php?usrname=%s&passwd=%s&softid=%s&level=%d&pay_type=%d&board=%d HTTP/1.0
Where the user has control of the username and password strings. Tenable's proof of concept results in the following crash dump:
2018.05.25-10:57:13.72@0: /nova/bin/licupgr
2018.05.25-10:57:13.72@0: --- signal=11 --------------------------------------------
2018.05.25-10:57:13.72@0:
2018.05.25-10:57:13.72@0: eip=0x41414141 eflags=0x00010202
2018.05.25-10:57:13.72@0: edi=0x41414141 esi=0x41414141 ebp=0x41414141 esp=0x7fb052d0
2018.05.25-10:57:13.72@0: eax=0x7fb0532c ebx=0x41414141 ecx=0x00000899 edx=0x00000001
2018.05.25-10:57:13.72@0:
2018.05.25-10:57:13.72@0: maps:
2018.05.25-10:57:13.72@0: 08048000-0804d000 r-xp 00000000 00:0b 1101 /nova/bin/licupgr
2018.05.25-10:57:13.72@0: 77547000-7757c000 r-xp 00000000 00:0b 997 /lib/libuClibc-0.9.33.2.so
2018.05.25-10:57:13.72@0: 77580000-7759a000 r-xp 00000000 00:0b 993 /lib/libgcc_s.so.1
2018.05.25-10:57:13.72@0: 7759b000-775aa000 r-xp 00000000 00:0b 977 /lib/libuc++.so
2018.05.25-10:57:13.72@0: 775ab000-775ad000 r-xp 00000000 00:0b 992 /lib/libdl-0.9.33.2.so
2018.05.25-10:57:13.72@0: 775af000-776f7000 r-xp 00000000 00:0b 987 /lib/libcrypto.so.1.0.0
2018.05.25-10:57:13.72@0: 77706000-7774a000 r-xp 00000000 00:0b 989 /lib/libssl.so.1.0.0
2018.05.25-10:57:13.72@0: 7774e000-77799000 r-xp 00000000 00:0b 979 /lib/libumsg.so
2018.05.25-10:57:13.72@0: 7779f000-777a6000 r-xp 00000000 00:0b 991 /lib/ld-uClibc-0.9.33.2.so
2018.05.25-10:57:13.72@0:
2018.05.25-10:57:13.72@0: stack: 0x7fb06000 - 0x7fb052d0
2018.05.25-10:57:13.72@0: 41 41 26 73 6f 66 74 69 64 3d 30 58 59 5a 2d 43 46 5a 52 26 6c 65 76 65 6c 3d 31 26 70 61 79 5f
2018.05.25-10:57:13.72@0: 74 79 70 65 3d 31 26 62 6f 61 72 64 3d 31 20 48 54 54 50 2f 31 2e 30 0d 0a 41 63 63 65 70 74 3a
2018.05.25-10:57:13.72@0:
2018.05.25-10:57:13.72@0: code: 0x41414141
CVE-2018-1157: Memory exhaustion in www
An authenticated user can cause the www binary to consume all memory via a crafted POST request to /jsproxy/upload. When testing our proof of concept on an x86 RouterOS VM, Tenable discovered that this vulnerability didn't just crash www but caused the whole system to reboot.
CVE-2018-1158: Stack exhaustion in www
An authenticated user communicating with the www binary can trigger a stack exhaustion vulnerability via recursive parsing of JSON.
CVE-2018-1159: Memory corruption in www
An authenticated user can cause memory corruption in the www binary by rapidly authenticating and disconnecting. Tenable's proof of concept generates the following crash dump. Note that due to the nature of memory corruption this exact stack trace will be very difficult to reproduce:
2018.05.25-11:11:54.39@0:
2018.05.25-11:11:54.39@0:
2018.05.25-11:11:54.39@0: /nova/bin/www
2018.05.25-11:11:54.39@0: --- signal=11 --------------------------------------------
2018.05.25-11:11:54.39@0:
2018.05.25-11:11:54.39@0: eip=0x7755a130 eflags=0x00010212
2018.05.25-11:11:54.39@0: edi=0x746e6f43 esi=0x0000007b ebp=0x77588078 esp=0x7758806b
2018.05.25-11:11:54.39@0: eax=0x08063564 ebx=0x7755bbe8 ecx=0x08062a30 edx=0x08062a34
2018.05.25-11:11:54.39@0:
2018.05.25-11:11:54.39@0: maps:
2018.05.25-11:11:54.39@0: 08048000-0805c000 r-xp 00000000 00:0b 1111 /nova/bin/www
2018.05.25-11:11:54.39@0: 77557000-7755b000 r-xp 00000000 00:0b 980 /lib/libucrypto.so
2018.05.25-11:11:54.39@0: 7755c000-77566000 r-xp 00000000 00:0b 1014 /nova/lib/www/jsproxy.p
2018.05.25-11:11:54.39@0: 77589000-775be000 r-xp 00000000 00:0b 997 /lib/libuClibc-0.9.33.2.so
2018.05.25-11:11:54.39@0: 775c2000-775dc000 r-xp 00000000 00:0b 993 /lib/libgcc_s.so.1
2018.05.25-11:11:54.39@0: 775dd000-775ec000 r-xp 00000000 00:0b 977 /lib/libuc++.so
2018.05.25-11:11:54.39@0: 775ed000-77735000 r-xp 00000000 00:0b 987 /lib/libcrypto.so.1.0.0
2018.05.25-11:11:54.39@0: 77744000-77788000 r-xp 00000000 00:0b 989 /lib/libssl.so.1.0.0
2018.05.25-11:11:54.39@0: 7778c000-7779b000 r-xp 00000000 00:0b 995 /lib/libpthread-0.9.33.2.so
2018.05.25-11:11:54.39@0: 7779f000-777a1000 r-xp 00000000 00:0b 992 /lib/libdl-0.9.33.2.so
2018.05.25-11:11:54.39@0: 777a3000-777a6000 r-xp 00000000 00:0b 981 /lib/libuxml++.so
2018.05.25-11:11:54.39@0: 777a7000-777f2000 r-xp 00000000 00:0b 979 /lib/libumsg.so
2018.05.25-11:11:54.39@0: 777f8000-777ff000 r-xp 00000000 00:0b 991 /lib/ld-uClibc-0.9.33.2.so
2018.05.25-11:11:54.39@0:
2018.05.25-11:11:54.39@0: stack: 0x7ff2d000 - 0x7758806b
2018.05.25-11:11:54.39@0: 77 43 6f 6e 74 7b 00 00 00 00 00 00 00 a8 80 58 77 3f a2 55 77 64 35 06 08 0c 36 06 08 26 00 00
2018.05.25-11:11:54.39@0: 00 20 a2 55 77 f0 80 58 77 ec c4 5e 77 b8 80 58 77 58 62 56 77 64 35 06 08 e8 80 58 77 c8 80 58
2018.05.25-11:11:54.39@0:
2018.05.25-11:11:54.39@0: code: 0x7755a130
2018.05.25-11:11:54.39@0: 8a 14 38 88 55 f3 0f b6 fa 8b b0 04 01 00 00 01
2018.05.25-11:11:54.39@0:
2018.05.25-11:11:54.39@0: backtrace: 0x7755a130 0x7755a23f 0x77562821 0x77564ef1 0x77565369 0x7756122b 0x080575ef 0x08055d14 0x08055ee9 0x08053df6 0x08053eed 0x77797435 0x777926d2