
4 new exploits Linux Kernel 2.4 / 2.6 x86-64 - System Call Emulation Exploit Linux Kernel 2.4 / 2.6 (x86_64) - System Call Emulation Exploit Linux Kernel 2.6.x (<= 2.6.20 / <= 2.6.24 / <= 2.6.27_7-10) (Ubuntu 7.04/8.04/8.10 / Fedora Core 10 / OpenSuse 11.1) - SCTP FWD Memory Corruption Remote Exploit Linux Kernel 2.6.x (<= 2.6.20 / <= 2.6.24 / <= 2.6.27_7-10) (Ubuntu 7.04/8.04/8.10 / Fedora Core 10 / OpenSuse 11.1) - SCTP FWD Memory Corruption Remote Exploit Linux Kernel <= 2.6.24_16-23 / <= 2.6.28.3 (Ubuntu 8.04/8.10 & Fedora Core 10) (x86-64) - set_selection() UTF-8 Off By One Local Exploit Linux Kernel <= 2.6.24_16-23 / <= 2.6.28.3 (Ubuntu 8.04/8.10 & Fedora Core 10 x86_64) - set_selection() UTF-8 Off By One Local Exploit Linux Kernel 2.6 < 2.6.19 (White Box 4 / CentOS 4.4/4.5 / Fedora Core 4/5/6) - (32-bit) ip_append_data() ring0 Root Exploit Linux Kernel 2.6 < 2.6.19 (White Box 4 / CentOS 4.4/4.5 / Fedora Core 4/5/6 x86) - ip_append_data() ring0 Root Exploit Linux Kernel < 2.6.36-rc4-git2 - x86_64 ia32syscall Emulation Privilege Escalation Linux Kernel 2.6.27 < 2.6.36 (x86_64) (Redhat) - compat Local Root Exploit Linux Kernel < 2.6.36-rc4-git2 (x86_64) - ia32syscall Emulation Privilege Escalation Linux Kernel 2.6.27 < 2.6.36 (Redhat x86_64) - compat Local Root Exploit Linux Kernel < 2.6.34 CAP_SYS_ADMIN x86 & x64 (Ubuntu 11.10) - Local Privilege Escalation Exploit (2) Linux Kernel < 2.6.34 (Ubuntu 11.10 x86 & x64) - CAP_SYS_ADMIN Local Privilege Escalation Exploit (2) Linux Kernel 2.6.39 <= 3.2.2 (32-bit & 64-bit) (Gentoo / Ubuntu) - Mempodipper Local Root (1) Linux Kernel 2.6.39 <= 3.2.2 (Gentoo / Ubuntu x86/x64) - Mempodipper Local Root (1) Linux Kernel < 3.3.x - 3.7.x (Arch Linux x86-64) - sock_diag_handlers[] Local Root Linux Kernel < 3.3.x - 3.7.x (Arch Linux x86_64) - sock_diag_handlers[] Local Root Linux Kernel <= 3.7.10 (Ubuntu 12.10) (64-Bit) - sock_diag_handlers Local Root Exploit Linux Kernel <= 3.7.10 (Ubuntu 12.10 x64) - sock_diag_handlers Local Root Exploit Linux Kernel < 3.8.9 - x86_64 perf_swevent_init Local Root Exploit Linux Kernel < 3.8.9 (x86_64) - perf_swevent_init Local Root Exploit Linux Kernel <= 3.7.6 (Redhat) (32bit/64bit) - 'MSR' Driver Local Privilege Escalation Linux Kernel <= 3.7.6 (Redhat x86/x64) - 'MSR' Driver Local Privilege Escalation Systrace 1.x (64-Bit) - Aware Linux Kernel Privilege Escalation Vulnerability Systrace 1.x (x64) - Aware Linux Kernel Privilege Escalation Vulnerability Linux Kernel 2.6.x - (64 bit) Personality Handling Local Denial of Service Vulnerability Linux Kernel 2.6.x (x64) - Personality Handling Local Denial of Service Vulnerability Linux Kernel < 3.2.0-23 (Ubuntu 12.04) - ptrace/sysret Local Privilege Escalation Linux Kernel < 3.2.0-23 (Ubuntu 12.04 x64) - ptrace/sysret Local Privilege Escalation Linux Kernel 2.6.39 <= 3.2.2 (32-bit & 64-bit) - Mempodipper Local Root (2) Linux Kernel 2.6.39 <= 3.2.2 (x86/x64) - Mempodipper Local Root (2) Joomla SecurityCheck Extension 2.8.9 - Multiple Vulnerabilities Liferay CE < 6.2 CE GA6 - Stored XSS Relay Ajax Directory Manager relayb01-071706_ 1.5.1_ 1.5.3 - Unauthenticated File Upload Websockify (C Implementation) 0.8.0 - Buffer Overflow
149 lines
No EOL
4.7 KiB
Text
Executable file
149 lines
No EOL
4.7 KiB
Text
Executable file
Advisory: Websockify: Remote Code Execution via Buffer Overflow
|
|
|
|
RedTeam Pentesting discovered a buffer overflow vulnerability in the C
|
|
implementation of Websockify, which allows attackers to execute
|
|
arbitrary code.
|
|
|
|
|
|
Details
|
|
=======
|
|
|
|
Product: Websockify C implementation
|
|
Affected Versions: all versions <= 0.8.0
|
|
Fixed Versions: versions since commit 192ec6f (2016-04-22) [0]
|
|
Vulnerability Type: Buffer Overflow
|
|
Security Risk: high
|
|
Vendor URL: https://github.com/kanaka/websockify
|
|
Vendor Status: fixed
|
|
Advisory URL: https://www.redteam-pentesting.de/advisories/rt-sa-2016-004
|
|
Advisory Status: published
|
|
CVE: GENERIC-MAP-NOMATCH
|
|
CVE URL: https://cve.mitre.org/cgi-bin/cvename.cgi?name=GENERIC-MAP-NOMATCH
|
|
|
|
|
|
Introduction
|
|
============
|
|
|
|
"websockify was formerly named wsproxy and was part of the noVNC
|
|
project.
|
|
|
|
At the most basic level, websockify just translates WebSockets traffic
|
|
to normal TCP socket traffic. Websockify accepts the WebSockets
|
|
handshake, parses it, and then begins forwarding traffic between the
|
|
client and the target in both directions."
|
|
|
|
(from the project's readme)
|
|
|
|
|
|
More Details
|
|
============
|
|
|
|
For each new connection, websockify forks and calls the function
|
|
do_handshake() to receive a client's WebSocket handshake. The
|
|
following excerpt shows some of the source code responsible for
|
|
receiving the client's data from the socket file descriptor:
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
ws_ctx_t *do_handshake(int sock) {
|
|
char handshake[4096], response[4096], sha1[29], trailer[17];
|
|
[...]
|
|
offset = 0;
|
|
for (i = 0; i < 10; i++) {
|
|
len = ws_recv(ws_ctx, handshake+offset, 4096);
|
|
if (len == 0) {
|
|
handler_emsg("Client closed during handshake\n");
|
|
return NULL;
|
|
}
|
|
offset += len;
|
|
handshake[offset] = 0;
|
|
if (strstr(handshake, "\r\n\r\n")) {
|
|
break;
|
|
}
|
|
usleep(10);
|
|
}
|
|
[...]
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
As can be seen in the listing, the function ws_recv() is called in a
|
|
loop to read data from the client's socket into the stack-allocated
|
|
buffer 'handshake'. Each time ws_recv() is called, a maximum of 4096
|
|
bytes are read from the socket and stored in the handshake buffer.
|
|
The variable 'offset' determines the position in the buffer at which
|
|
the received data is written. In each iteration, the value of 'offset'
|
|
is increased by the amount of bytes received. If the received data
|
|
contains the string "\r\n\r\n", which marks the end of the WebSocket
|
|
handshake data, the loop is terminated. Otherwise, the loop is
|
|
terminated after a maximum of 10 iterations. The do_handshake()
|
|
function returns early if no more data can be received from the
|
|
socket.
|
|
|
|
By forcing websockify to iterate multiple times, attackers can
|
|
exploit this behaviour to write data past the space allocated for the
|
|
handshake buffer, thereby corrupting adjacent memory.
|
|
|
|
|
|
Proof of Concept
|
|
================
|
|
|
|
The following curl command can be used to trigger the buffer overflow:
|
|
|
|
$ curl http://example.com/$(python -c 'print "A"*5000')
|
|
|
|
Providing a generic exploit for this vulnerability is not feasible, as
|
|
it depends on the server side environment websockify is used in as well
|
|
as the used compiler and its flags. However, during a penetration test
|
|
it was possible to successfully exploit this buffer overflow
|
|
vulnerability and to execute arbitrary commands on the server.
|
|
|
|
Workaround
|
|
==========
|
|
|
|
Use the Python implementation of websockify.
|
|
|
|
|
|
Fix
|
|
===
|
|
|
|
The vulnerability has been fixed in commit 192ec6f [0].
|
|
|
|
|
|
Security Risk
|
|
=============
|
|
|
|
Successful exploitation of the vulnerability allows attackers to execute
|
|
arbitrary code on the affected system. It is therefore rated as a high
|
|
risk.
|
|
|
|
|
|
Timeline
|
|
========
|
|
|
|
2016-04-14 Vulnerability identified
|
|
2016-05-03 Advisory provided to customer
|
|
2016-05-06 Customer provided updated firmware, notified users
|
|
2016-05-23 Customer notified users again
|
|
2016-05-31 Advisory published
|
|
|
|
|
|
References
|
|
==========
|
|
|
|
[0] https://github.com/kanaka/websockify/commit/192ec6f5f9bf9c80a089ca020d05ad4bd9e7bcd9
|
|
|
|
|
|
RedTeam Pentesting GmbH
|
|
=======================
|
|
|
|
RedTeam Pentesting offers individual penetration tests performed by a
|
|
team of specialised IT-security experts. Hereby, security weaknesses in
|
|
company networks or products are uncovered and can be fixed immediately.
|
|
|
|
As there are only few experts in this field, RedTeam Pentesting wants to
|
|
share its knowledge and enhance the public knowledge with research in
|
|
security-related areas. The results are made available as public
|
|
security advisories.
|
|
|
|
More information about RedTeam Pentesting can be found at:
|
|
https://www.redteam-pentesting.de/ |