Skip to content

Commit 35b3f01

Browse files
authored
tweak(network): Add file extension validation to network map transfer (#1818)
1 parent 336bfb5 commit 35b3f01

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,36 @@
5353
#include "GameClient/DisconnectMenu.h"
5454
#include "GameClient/InGameUI.h"
5555

56+
static Bool hasValidTransferFileExtension(const AsciiString& filePath)
57+
{
58+
static const char* const validExtensions[] = {
59+
"map",
60+
"ini",
61+
"str",
62+
"wak",
63+
"tga",
64+
"txt"
65+
};
66+
67+
const char* fileExt = strrchr(filePath.str(), '.');
68+
69+
if (fileExt == NULL || fileExt[1] == '\0')
70+
{
71+
return false;
72+
}
73+
74+
fileExt++;
75+
76+
for (Int i = 0; i < ARRAY_SIZE(validExtensions); ++i)
77+
{
78+
if (stricmp(fileExt, validExtensions[i]) == 0)
79+
{
80+
return true;
81+
}
82+
}
83+
84+
return false;
85+
}
5686

5787
/**
5888
* Le destructor.
@@ -665,6 +695,13 @@ void ConnectionManager::processFile(NetFileCommandMsg *msg)
665695
return;
666696
}
667697

698+
// TheSuperHackers @security bobtista 06/11/2025 Validate file extension to prevent arbitrary file types
699+
if (!hasValidTransferFileExtension(realFileName))
700+
{
701+
DEBUG_LOG(("File '%s' has invalid extension for transfer operations.", realFileName.str()));
702+
return;
703+
}
704+
668705
if (TheFileSystem->doesFileExist(realFileName.str()))
669706
{
670707
DEBUG_LOG(("File exists already!"));

0 commit comments

Comments
 (0)