Newspost Buffer Overflow in socket_getline() Lets Remote Users Crash the Process
|
|
SecurityTracker Alert ID: 1013056
|
|
SecurityTracker URL: http://securitytracker.com/id?1013056
|
|
CVE Reference: CAN-2005-0101
(Links to External Site)
|
Date: Feb 2 2005
|
Impact: Denial of service via network, Execution of arbitrary code via network
|
Version(s): 2.1.1
|
Description: A vulnerability was reported in newspost. A remote user can cause newspost to crash or potentially execute arbitrary code.
Niels Heinen reported that a remote server can trigger a buffer overflow in the socket_getline() function. A remote server can supply
a specially crafted response to cause the connecting newspost process to crash. It may be possible to execute arbitrary code, but
code execution was not confirmed in the report.
The flaw resides in 'base/socket.c'.
|
Impact: A remote NNTP server can cause the connecting newspost process to crash.
|
Solution: No vendor solution was available at the time of this entry.
An unofficial patch is available at:
http://people.freebsd.org/~niels/issues/newspost-20050114.txt
|
Vendor URL: newspost.unixcab.org/ (Links to External Site)
|
Cause: Boundary error
|
Underlying OS: Linux (Any), UNIX (Any)
|
|
Message History:
None.
|
Source Message Contents
|
Date: Tue, 1 Feb 2005 19:48:47 -0500
Subject: http://people.freebsd.org/~niels/issues/newspost-20050114.txt
|
Bug description:
----------------
An overflow exists in the socket_getline() function. This function
reads a string from the socket into a given array and is used by
the nntp_get_response function.
The problem code is:
while (TRUE) {
retval = read(sockfd, pi, 1);
if(retval < 0)
ui_socket_error(errno);
read_count += retval;
pi++;
if (buffer[i] == '\n')
break;
i++;
}
The pi array is the buffer and data is read into it until a '\n'
is received. So to overflow the buffer one has to provide a long
string without newline characters.
Testing the overflow:
---------------------
Create a server:
perl -e 'print "A" x 1024;print "BBBBCCCCDDDDEEEE"'| nc -v -l -p 119
Connect to it:
newspost -s test -i localhost -f me@me.nl -n news.news /etc/hosts
Break the connection by ^C'ing the netcat and you will see that
newspost segfaults immediately.
Fix for the problem:
--------------------
A rather simple fix would be to apply the patch below. It does the
job because all buffers handed to the socket_getline function are
STRING_BUFSIZE big.
--- base/socket.c.orig Tue Jan 18 11:08:02 2005
+++ base/socket.c Tue Jan 18 11:10:08 2005
@@ -126,7 +126,7 @@
i = 0;
pi = buffer;
- while (TRUE) {
+ while (read_count < STRING_BUFSIZE - 1) {
retval = read(sockfd, pi, 1);
if(retval < 0)
ui_socket_error(errno);
|
|