Skip to contentSkip to conversation

libvncserver: add security patches

PATCH New Gustavo Zacarias 2 participants 2 messages Sep 30, 2014 – Oct 1, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libvncserver: add security patches

Fixes:
CVE-2014-6051 and
CVE-2014-6052 denial of service and possible code execution via integer overflow and lack of malloc error handling in MallocFrameBuffer()
CVE-2014-6053 denial of service via large ClientCutText message. CVE-2014-6054 denial of service via zero scaling factor. CVE-2014-6055 denial of service and possible code execution via stack overflows in File Transfer feature.

---
 .../libvncserver-0001-CVE-2014-6051-6052.patch     |  85 ++++++++++++
 .../libvncserver-0002-CVE-2014-6053.patch          |  21 +++
 .../libvncserver-0003-CVE-2014-6054.patch          |  87 ++++++++++++
 .../libvncserver-0004-CVE-2014-6055.patch          | 150 +++++++++++++++++++++
 4 files changed, 343 insertions(+)
 create mode 100644 package/libvncserver/libvncserver-0001-CVE-2014-6051-6052.patch
 create mode 100644 package/libvncserver/libvncserver-0002-CVE-2014-6053.patch
 create mode 100644 package/libvncserver/libvncserver-0003-CVE-2014-6054.patch
 create mode 100644 package/libvncserver/libvncserver-0004-CVE-2014-6055.patch
package/libvncserver/libvncserver-0001-CVE-2014-6051-6052.patch new file +85 -0
new file mode 100644
index 0000000..6c21b1d
@@ -0,0 +1,85 @@
+Description: fix denial of service and possible code execution via
+ integer overflow and lack of malloc error handling in MallocFrameBuffer()
+Origin: backport, https://github.com/newsoft/libvncserver/commit/045a044e8ae79db9244593fbce154cdf6e843273
+Origin: backport, https://github.com/newsoft/libvncserver/commit/85a778c0e45e87e35ee7199f1f25020648e8b812
+
+Signed-off-by: Gustavo Zacarias <[email protected]>
+
+Index: libvncserver-0.9.9+dfsg/libvncclient/rfbproto.c
+===================================================================
+--- libvncserver-0.9.9+dfsg.orig/libvncclient/rfbproto.c	2012-05-04 10:19:00.000000000 -0400
++++ libvncserver-0.9.9+dfsg/libvncclient/rfbproto.c	2014-09-25 11:11:55.884057336 -0400
+@@ -1807,7 +1807,8 @@
+ 	client->updateRect.x = client->updateRect.y = 0;
+ 	client->updateRect.w = client->width;
+ 	client->updateRect.h = client->height;
+-	client->MallocFrameBuffer(client);
++	if (!client->MallocFrameBuffer(client))
++	  return FALSE;
+ 	SendFramebufferUpdateRequest(client, 0, 0, rect.r.w, rect.r.h, FALSE);
+ 	rfbClientLog("Got new framebuffer size: %dx%d\n", rect.r.w, rect.r.h);
+ 	continue;
+@@ -2260,7 +2261,8 @@
+     client->updateRect.x = client->updateRect.y = 0;
+     client->updateRect.w = client->width;
+     client->updateRect.h = client->height;
+-    client->MallocFrameBuffer(client);
++    if (!client->MallocFrameBuffer(client))
++      return FALSE;
+     SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);
+     rfbClientLog("Got new framebuffer size: %dx%d\n", client->width, client->height);
+     break;
+@@ -2276,7 +2278,9 @@
+     client->updateRect.x = client->updateRect.y = 0;
+     client->updateRect.w = client->width;
+     client->updateRect.h = client->height;
+-    client->MallocFrameBuffer(client);
++    if (!client->MallocFrameBuffer(client))
++      return FALSE;
++
+     SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);
+     rfbClientLog("Got new framebuffer size: %dx%d\n", client->width, client->height);
+     break;
+Index: libvncserver-0.9.9+dfsg/libvncclient/vncviewer.c
+===================================================================
+--- libvncserver-0.9.9+dfsg.orig/libvncclient/vncviewer.c	2012-05-04 10:19:00.000000000 -0400
++++ libvncserver-0.9.9+dfsg/libvncclient/vncviewer.c	2014-09-25 11:10:29.984055035 -0400
+@@ -82,9 +82,27 @@
+ #endif
+ }
+ static rfbBool MallocFrameBuffer(rfbClient* client) {
++uint64_t allocSize;
++
+   if(client->frameBuffer)
+     free(client->frameBuffer);
+-  client->frameBuffer=malloc(client->width*client->height*client->format.bitsPerPixel/8);
++
++  /* SECURITY: promote 'width' into uint64_t so that the multiplication does not overflow
++     'width' and 'height' are 16-bit integers per RFB protocol design
++     SIZE_MAX is the maximum value that can fit into size_t
++  */
++  allocSize = (uint64_t)client->width * client->height * client->format.bitsPerPixel/8;
++
++  if (allocSize >= SIZE_MAX) {
++    rfbClientErr("CRITICAL: cannot allocate frameBuffer, requested size is too large\n");
++    return FALSE;
++  }
++
++  client->frameBuffer=malloc( (size_t)allocSize );
++
++  if (client->frameBuffer == NULL)
++    rfbClientErr("CRITICAL: frameBuffer allocation failed, requested size too large or not enough memory?\n");
++
+   return client->frameBuffer?TRUE:FALSE;
+ }
+ 
+@@ -225,7 +243,8 @@
+ 
+   client->width=client->si.framebufferWidth;
+   client->height=client->si.framebufferHeight;
+-  client->MallocFrameBuffer(client);
++  if (!client->MallocFrameBuffer(client))
++    return FALSE;
+ 
+   if (!SetFormatAndEncodings(client))
+     return FALSE;
package/libvncserver/libvncserver-0002-CVE-2014-6053.patch new file +21 -0
new file mode 100644
index 0000000..23b8ada
@@ -0,0 +1,21 @@
+Description: fix denial of service via large ClientCutText message
+Origin: backport, https://github.com/newsoft/libvncserver/commit/6037a9074d52b1963c97cb28ea1096c7c14cbf28
+
+Signed-off-by: Gustavo Zacarias <[email protected]>
+
+Index: libvncserver-0.9.9+dfsg/libvncserver/rfbserver.c
+===================================================================
+--- libvncserver-0.9.9+dfsg.orig/libvncserver/rfbserver.c	2012-05-04 10:19:00.000000000 -0400
++++ libvncserver-0.9.9+dfsg/libvncserver/rfbserver.c	2014-09-25 11:12:36.124058413 -0400
+@@ -2457,6 +2457,11 @@
+ 	msg.cct.length = Swap32IfLE(msg.cct.length);
+ 
+ 	str = (char *)malloc(msg.cct.length);
++	if (str == NULL) {
++		rfbLogPerror("rfbProcessClientNormalMessage: not enough memory");
++		rfbCloseClient(cl);
++		return;
++	}
+ 
+ 	if ((n = rfbReadExact(cl, str, msg.cct.length)) <= 0) {
+ 	    if (n != 0)
package/libvncserver/libvncserver-0003-CVE-2014-6054.patch new file +87 -0

87 lines not on this page · raw message

package/libvncserver/libvncserver-0004-CVE-2014-6055.patch new file +150 -0

150 lines not on this page · raw message

Signature · 1 line
2.0.4
#1 lore raw

PATCH 1/1 libvncserver: add security patches

Quoted 12 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Gustavo" == Gustavo Zacarias <[email protected]> writes:

Fixes:
CVE-2014-6051 and
CVE-2014-6052 denial of service and possible code execution via integer overflow and lack of malloc error handling in MallocFrameBuffer()
CVE-2014-6053 denial of service via large ClientCutText message. CVE-2014-6054 denial of service via zero scaling factor. CVE-2014-6055 denial of service and possible code execution via stack overflows in File Transfer feature.

Quoted 1 line

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard