Skip to content

Commit 9b2cb9f

Browse files
committed
fix security bug
1 parent ca323e5 commit 9b2cb9f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

files/lib/data/discord/bot/DiscordBot.class.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use wcf\data\file\File;
77
use wcf\system\cache\builder\DiscordGuildChannelCacheBuilder;
88
use wcf\system\discord\DiscordApi;
9+
use wcf\system\WCF;
910

1011
/**
1112
* Discord-Bot-Objekt
@@ -95,4 +96,17 @@ public function getWebhookAvatarData(): ?string
9596

9697
return 'data:' . $file->mimeType . ';base64,' . \base64_encode(\file_get_contents($file->getPathname()));
9798
}
99+
100+
public static function findByFileID(int $fileID): ?DiscordBot
101+
{
102+
$sql = "
103+
SELECT *
104+
FROM wcf1_discord_bot
105+
WHERE botID = ?
106+
";
107+
$stmnt = WCF::getDB()->prepare($sql);
108+
$stmnt->execute([$fileID]);
109+
110+
return $stmnt->fetchObject(DiscordBot::class);
111+
}
98112
}

files/lib/system/file/DiscordWebhookAvatarFileProcessor.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ public function validateUpload(File $file): void
4545
}
4646
}
4747

48+
#[Override]
49+
public function canAdopt(File $file, array $context): bool
50+
{
51+
return DiscordBot::findByFileID($file->fileID) === null;
52+
}
53+
4854
#[Override]
4955
public function adopt(File $file, array $context): void
5056
{

0 commit comments

Comments
 (0)