From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1wKO-0007RK-Ml for qemu-devel@nongnu.org; Tue, 01 Jul 2014 07:34:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1wKJ-00052S-QK for qemu-devel@nongnu.org; Tue, 01 Jul 2014 07:34:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65271) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1wKJ-00052G-Hk for qemu-devel@nongnu.org; Tue, 01 Jul 2014 07:34:19 -0400 From: Gerd Hoffmann Date: Tue, 1 Jul 2014 13:34:00 +0200 Message-Id: <1404214441-5106-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1404214441-5106-1-git-send-email-kraxel@redhat.com> References: <1404214441-5106-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 1/2] ui/vnc: limit client_cut_text msg payload size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Lieven , Gerd Hoffmann , Anthony Liguori From: Peter Lieven currently a malicious client could define a payload size of 2^32 - 1 bytes and send up to that size of data to the vnc server. The server would allocated that amount of memory which could easily create an out of memory condition. This patch limits the payload size to 1MB max. Please note that client_cut_text messages are currently silently ignored. Signed-off-by: Peter Lieven Signed-off-by: Gerd Hoffmann --- ui/vnc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 14a86c3..19ce988 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2165,13 +2165,20 @@ static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len) pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4)); break; case VNC_MSG_CLIENT_CUT_TEXT: - if (len == 1) + if (len == 1) { return 8; - + } if (len == 8) { uint32_t dlen = read_u32(data, 4); - if (dlen > 0) + if (dlen > (1 << 20)) { + error_report("vnc: client_cut_text msg payload has %u bytes" + " which exceeds our limit of 1MB.", dlen); + vnc_client_error(vs); + break; + } + if (dlen > 0) { return 8 + dlen; + } } client_cut_text(vs, read_u32(data, 4), data + 8); -- 1.8.3.1