Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed server freezing vulnerabiity in multiple packets #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/EmoteListPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ public function getEmoteIds() : array{ return $this->emoteIds; }
protected function decodePayload(PacketSerializer $in) : void{
$this->playerActorRuntimeId = $in->getActorRuntimeId();
$this->emoteIds = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$len = $in->getUnsignedVarInt();

// While EmoteListPacket doesn't really freeze the server, its abusing can increase server load by 10-20%
if($len > 100){
throw new PacketDecodeException("Too many emote ids");
}

for($i = 0; $i < $len; ++$i){
$this->emoteIds[] = $in->getUUID();
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/PurchaseReceiptPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public static function create(array $entries) : self{

protected function decodePayload(PacketSerializer $in) : void{
$count = $in->getUnsignedVarInt();

if($count > 50) {
throw new PacketDecodeException("Too many entries");
}

for($i = 0; $i < $count; ++$i){
$this->entries[] = $in->getString();
}
Expand Down
3 changes: 3 additions & 0 deletions src/ResourcePackClientResponsePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public static function create(int $status, array $packIds) : self{
protected function decodePayload(PacketSerializer $in) : void{
$this->status = $in->getByte();
$entryCount = $in->getLShort();
if($entryCount > 100) {
throw new PacketDecodeException("Too many pack ids");
}
$this->packIds = [];
while($entryCount-- > 0){
$this->packIds[] = $in->getString();
Expand Down
5 changes: 5 additions & 0 deletions src/TextPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ protected function decodePayload(PacketSerializer $in) : void{
case self::TYPE_JUKEBOX_POPUP:
$this->message = $in->getString();
$count = $in->getUnsignedVarInt();

if($count > 20) {
throw new PacketDecodeException("Too many parameters");
}

for($i = 0; $i < $count; ++$i){
$this->parameters[] = $in->getString();
}
Expand Down