-
Notifications
You must be signed in to change notification settings - Fork 1.1k
RakNetDOS (!) #102
Description
RakNet DoS attack.
The problem lays in ACKs and NAKs system in function:
ReliabilityLayer::HandleSocketReceiveFromConnectedPlayer
commit e97c4bb didn't fix it
Specially crafted packet can hang RakNet thread for quite a while or freeze it for good.
ReliabilityLayer.cpp
Line 736:
for (i=0; i<incomingAcks.ranges.Size();i++)
{
...
...
Line 746:
for (datagramNumber=incomingAcks.ranges[i].minIndex; datagramNumber >= incomingAcks.ranges[i].minIndex && datagramNumber <= incomingAcks.ranges[i].maxIndex; datagramNumber++)
}
and
Line 818:
for (i=0; i<incomingNAKs.ranges.Size();i++)
{
...
...
Line 831:
for (messageNumber=incomingNAKs.ranges[i].minIndex; messageNumber >= incomingNAKs.ranges[i].minIndex && messageNumber <= incomingNAKs.ranges[i].maxIndex; messageNumber++)
}
When ranges[i].minIndex = 0 and ranges[i].maxIndex = 0xFFFFFFFE then loop will be executed 4294967294 times. Which is a lot. What is more, a single packet can contain
even 200 "ranges" or more. So loop at line 746 and 818 going to be executed 200 * 4294967294 = 858993458800 times, because ranges.Size() = 200;
This can hang RakNet thread for a while, so no new incoming connections are going to be accepted and all peers already connected will timeout.
Special case:
incomingNAKs.ranges[i].minIndex = 0 and incomingNAKs.ranges[i].maxIndex = 0xFFFFFFFF then loop at line 818 will never end.
In this case RakNet thread will be trapped in an endless loop.