Skip to content

Commit 42badf6

Browse files
Reject path traversal in plugin/engine lookup name (GHSA-7pxc-h3rv-r257)
Validate plugin name before building DIR_PLUGINS path: reject /, \, and .. subsequences so dlopen cannot escape the plugins directory. Made-with: Cursor
1 parent b691650 commit 42badf6

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/yvalve/PluginManager.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ namespace
7979
file += newExt;
8080
}
8181

82+
// Reject path components in plugin/engine lookup names so DIR_PLUGINS/<name>
83+
// cannot escape the plugins directory (path traversal to dlopen).
84+
void validatePluginLookupName(const char* pluginName)
85+
{
86+
if (!pluginName)
87+
return;
88+
89+
for (const char* p = pluginName; *p; ++p)
90+
{
91+
const unsigned char c = static_cast<unsigned char>(*p);
92+
if (c == '/' || c == '\\')
93+
(Arg::Gds(isc_random) << "Invalid characters in plugin name").raise();
94+
}
95+
96+
if (strstr(pluginName, ".."))
97+
(Arg::Gds(isc_random) << "Invalid characters in plugin name").raise();
98+
}
99+
82100
// Holds a reference to plugins.conf file
83101
class StaticConfHolder
84102
{
@@ -780,6 +798,8 @@ namespace
780798

781799
explicit PluginLoadInfo(const char* pluginName)
782800
{
801+
validatePluginLookupName(pluginName);
802+
783803
// define default values for plugin ...
784804
curModule = fb_utils::getPrefix(IConfigManager::DIR_PLUGINS, pluginName);
785805
regName = pluginName;

0 commit comments

Comments
 (0)