Skip to contentSkip to conversation

possible denial of service via VNC

Qemu-devel Peter Lieven 3 participants 6 messages Jun 29, 2014 – Jun 30, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

while debugging a VNC issue I found this:

    case VNC_MSG_CLIENT_CUT_TEXT:
        if (len == 1)
            return 8;

        if (len == 8) {
            uint32_t dlen = read_u32(data, 4);
            if (dlen > 0)
                return 8 + dlen;
        }

        client_cut_text(vs, read_u32(data, 4), data + 8);
        break;

in protocol_client_msg().

Is this really a good idea? This allows for letting the vs->input buffer to grow up to 2^32 + 8 byte which will possibly result in an out of memory condition.

Peter

#1 lore raw
Quoted 17 lines · Peter Lieven

Hi,

while debugging a VNC issue I found this:

    case VNC_MSG_CLIENT_CUT_TEXT:
        if (len == 1)
            return 8;

        if (len == 8) {
            uint32_t dlen = read_u32(data, 4);
            if (dlen > 0)
                return 8 + dlen;
        }

        client_cut_text(vs, read_u32(data, 4), data + 8);
        break;
Quoted 4 lines

in protocol_client_msg().

Is this really a good idea? This allows for letting the vs->input buffer to grow up to 2^32 + 8 byte which will possibly result in an out of memory condition.

The spec allows cut operations of this size. What would a reasonable limit be?

Regards,

Anthony Liguori

Quoted 3 lines

PeterY

#2 lore raw
In reply to Peter Lieven
Quoted 17 lines · Peter Lieven

Hi,

while debugging a VNC issue I found this:

    case VNC_MSG_CLIENT_CUT_TEXT:
        if (len == 1)
            return 8;

        if (len == 8) {
            uint32_t dlen = read_u32(data, 4);
            if (dlen > 0)
                return 8 + dlen;
        }

        client_cut_text(vs, read_u32(data, 4), data + 8);
        break;
Quoted 4 lines

in protocol_client_msg().

Is this really a good idea? This allows for letting the vs->input buffer to grow up to 2^32 + 8 byte which will possibly result in an out of memory condition.

Applying a limit there looks reasonable to me. Patches welcome. As this is text only a megabyte should be more than enough for all practical purposes. Question is what to do when the limit is exceeded? Disconnect? Read & throw away?

cheers,
Gerd

#3 lore raw
Quoted 18 lines · Gerd Hoffmann
Quoted 17 lines · Peter Lieven

Hi,

while debugging a VNC issue I found this:

     case VNC_MSG_CLIENT_CUT_TEXT:
         if (len == 1)
             return 8;

         if (len == 8) {
             uint32_t dlen = read_u32(data, 4);
             if (dlen > 0)
                 return 8 + dlen;
         }

         client_cut_text(vs, read_u32(data, 4), data + 8);
         break;
Quoted 8 lines
Quoted 4 lines

in protocol_client_msg().

Is this really a good idea? This allows for letting the vs->input buffer to grow up to 2^32 + 8 byte which will possibly result in an out of memory condition.

Applying a limit there looks reasonable to me. Patches welcome. As this is text only a megabyte should be more than enough for all practical purposes. Question is what to do when the limit is exceeded? Disconnect? Read & throw away?

I would also think something in the order of megabytes should be fine. I would vote for disconnect as soon as the limit specified is too big. Otherwise we had to rewrite the whole receive logic which could introduce additional bugs.

Peter

Signature · 16 lines
Mit freundlichen Grüßen

Peter Lieven

...........................................................

  KAMP Netzwerkdienste GmbH
  Vestische Str. 89-91 | 46117 Oberhausen
  Tel: +49 (0) 208.89 402-50 | Fax: +49 (0) 208.89 402-40
  [email protected] | http://www.kamp.de

  Geschäftsführer: Heiner Lante | Michael Lante
  Amtsgericht Duisburg | HRB Nr. 12154
  USt-Id-Nr.: DE 120607556

...........................................................
#4 lore raw

Hi,

Quoted 3 lines

I would vote for disconnect as soon as the limit specified is too big. Otherwise we had to rewrite the whole receive logic which could introduce additional bugs.

Sounds sensible.

cheers,
Gerd

#5 lore raw
Quoted 6 lines · Gerd Hoffmann
   Hi,
Quoted 3 lines

I would vote for disconnect as soon as the limit specified is too big. Otherwise we had to rewrite the whole receive logic which could introduce additional bugs.

Sounds sensible.

Especially since client_cut_text is currently a NOP.

Peter