Misconfiguration in build environment allows DLL preloading attack
The Monero GUI wallet executable attempts to load certain DLLs that are not present in its own directory, so Windows searches other locations such as the system root and directories listed in the PATH environment variable. An attacker who can write to any directory in the PATH can place a malicious DLL there and achieve arbitrary code execution when the application runs.
- Triaged in 19 months
- Fixed in 19 months
- Disclosed after 20 months
Summary:
monero-wallet-gui.exe tries to dynamically load some dynamic link libraries(DLL) which are not present in the applications directory, so LoadLibraryA system-call will search other directories such as Windows root and %PATH% for them. An attacker can gain arbitrary code execution if he/she has write permission to any of the directories within the %PATH%.
List of DDLs:
ZLIB1.dllperf.dllloaded byatio6axx.dll(AMD OpenGL)
Releases Affected:
Tried on v0.16.0.0 on Windows 10 Home Edition with AMD GPU
Steps To Reproduce:
- Create a DLL and put the exploit in
DLL_PROCESS_ATTACHevent. - Rename the DLL to
ZLIB1.dll - Copy the DLL to any directory in the path(
echo %PATH%) - Run
monero-wallet-gui.exe
Supporting Material/References:
PoC DLL:
#include <windows.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
system("cmd /Q /D /C calc.exe");
case DLL_PROCESS_DETACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
Housekeeping
Address: 8C5XAD3aAH9CfwCh7M8vhXgzyLPCLQTPWJk6nXnxGPpH2dGfEShuWWzdXqz92tWu2874A13BEwp6SeGhWK6MAJzvKCxZW4L
Impact
Arbitrary code execution and privilege escalation
Attachments
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application does not use safe DLL search settings or verify the integrity of loaded libraries, allowing DLL preloading from directories in the PATH.
Impact
An attacker could achieve arbitrary code execution and privilege escalation, but only if they already have write access to a directory in the PATH.
What the attacker needed
Write access to a directory in PATH; Windows system; Monero GUI wallet installed
How it was found
- Create a DLL with malicious code in its DllMain function.
- Rename the DLL to ZLIB1.dll.
- Copy the DLL to any directory listed in the PATH environment variable.
- Run monero-wallet-gui.exe.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a Windows program starts, it often needs extra code stored in files called DLLs. If the program does not find a DLL in its own folder, Windows looks in other folders, including ones listed in a system setting called PATH. If an attacker can put a file with the right name into one of those folders, the program will load and run the attacker's code instead of the real DLL.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.