core/sm: Harden plugin loading path requirements (#1437)
* Harden plugin loading path requirements Restrict loading of plugins to the `sourcemod/plugins` folder and require the `.smx` file extension. Symlinks inside the `plugins` folder are fine. This behavior was abused as part of justCTF 2020 in the PainterHell challenge by cypis. Thank you! * Restrict extension loading to extensions folder * Add NULL file extension check in LoadExtension hi @KyleS
This commit is contained in:
@@ -631,9 +631,15 @@ IExtension *CExtensionManager::FindExtensionByName(const char *ext)
|
||||
|
||||
IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength)
|
||||
{
|
||||
if (strstr(file, "..") != NULL)
|
||||
{
|
||||
ke::SafeStrcpy(error, maxlength, "Cannot load extensions outside the \"extensions\" folder.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Remove platform extension if it's there. Compat hack. */
|
||||
const char *ext = libsys->GetFileExtension(file);
|
||||
if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
|
||||
if (ext && strcmp(ext, PLATFORM_LIB_EXT) == 0)
|
||||
{
|
||||
char path2[PLATFORM_MAX_PATH];
|
||||
ke::SafeStrcpy(path2, sizeof(path2), file);
|
||||
|
||||
Reference in New Issue
Block a user