2017-02-06 17:47:30 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2017-02-06 17:44:11 +00:00
|
|
|
From: Frediano Ziglio <fziglio@redhat.com>
|
|
|
|
Date: Tue, 13 Dec 2016 14:39:48 +0000
|
2017-02-06 17:47:30 +00:00
|
|
|
Subject: [spice-server] Prevent possible DoS attempts during protocol
|
2017-02-06 17:44:11 +00:00
|
|
|
handshake
|
|
|
|
|
|
|
|
The limit for link message is specified using a 32 bit unsigned integer.
|
|
|
|
This could cause possible DoS due to excessive memory allocations and
|
|
|
|
some possible crashes.
|
|
|
|
For instance a value >= 2^31 causes a spice_assert to be triggered in
|
|
|
|
async_read_handler (reds-stream.c) due to an integer overflow at this
|
|
|
|
line:
|
|
|
|
|
|
|
|
int n = async->end - async->now;
|
|
|
|
|
|
|
|
This could be easily triggered with a program like
|
|
|
|
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import socket
|
|
|
|
import time
|
|
|
|
from struct import pack
|
|
|
|
|
|
|
|
server = '127.0.0.1'
|
|
|
|
port = 5900
|
|
|
|
|
|
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
s.connect((server, port))
|
|
|
|
data = pack('<4sIII', 'REDQ', 2, 2, 0xaaaaaaaa)
|
|
|
|
s.send(data)
|
|
|
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
without requiring any authentication (the same can be done
|
|
|
|
with TLS).
|
|
|
|
|
|
|
|
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
|
|
|
|
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
|
|
|
|
---
|
|
|
|
server/reds.c | 3 ++-
|
|
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/server/reds.c b/server/reds.c
|
|
|
|
index 8ef4efe..e7ebc43 100644
|
|
|
|
--- a/server/reds.c
|
|
|
|
+++ b/server/reds.c
|
|
|
|
@@ -2270,7 +2270,8 @@ static void reds_handle_read_header_done(void *opaque)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (header->size < sizeof(SpiceLinkMess)) {
|
|
|
|
+ /* the check for 4096 is to avoid clients to cause arbitrary big memory allocations */
|
|
|
|
+ if (header->size < sizeof(SpiceLinkMess) || header->size > 4096) {
|
|
|
|
reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
|
|
|
|
spice_warning("bad size %u", header->size);
|
|
|
|
reds_link_free(link);
|