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