]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/spice/0001-Prevent-possible-DoS-attempts-during-protocol-handsh.patch
lrzsz: install symlinks for XMODEM and YMODEM
[coffee/buildroot.git] / package / spice / 0001-Prevent-possible-DoS-attempts-during-protocol-handsh.patch
1 From 1c6517973095a67c8cb57f3550fc1298404ab556 Mon Sep 17 00:00:00 2001
2 From: Frediano Ziglio <fziglio@redhat.com>
3 Date: Tue, 13 Dec 2016 14:39:48 +0000
4 Subject: [PATCH] Prevent possible DoS attempts during protocol handshake
5
6 The limit for link message is specified using a 32 bit unsigned integer.
7 This could cause possible DoS due to excessive memory allocations and
8 some possible crashes.
9 For instance a value >= 2^31 causes a spice_assert to be triggered in
10 async_read_handler (reds-stream.c) due to an integer overflow at this
11 line:
12
13    int n = async->end - async->now;
14
15 This could be easily triggered with a program like
16
17   #!/usr/bin/env python
18
19   import socket
20   import time
21   from struct import pack
22
23   server = '127.0.0.1'
24   port = 5900
25
26   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
27   s.connect((server, port))
28   data = pack('<4sIII', 'REDQ', 2, 2, 0xaaaaaaaa)
29   s.send(data)
30
31   time.sleep(1)
32
33 without requiring any authentication (the same can be done
34 with TLS).
35
36 [Peter: fixes CVE-2016-9578]
37 Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
38 Acked-by: Christophe Fergeau <cfergeau@redhat.com>
39 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
40 ---
41  server/reds.c | 3 ++-
42  1 file changed, 2 insertions(+), 1 deletion(-)
43
44 diff --git a/server/reds.c b/server/reds.c
45 index f40b65c1..86a33d53 100644
46 --- a/server/reds.c
47 +++ b/server/reds.c
48 @@ -2202,7 +2202,8 @@ static void reds_handle_read_header_done(void *opaque)
49  
50      reds->peer_minor_version = header->minor_version;
51  
52 -    if (header->size < sizeof(SpiceLinkMess)) {
53 +    /* the check for 4096 is to avoid clients to cause arbitrary big memory allocations */
54 +    if (header->size < sizeof(SpiceLinkMess) || header->size > 4096) {
55          reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
56          spice_warning("bad size %u", header->size);
57          reds_link_free(link);
58 -- 
59 2.11.0
60