-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncontrolled Search Path Element vulnerability On AHK installer v2.0.2 #9
Comments
All compiled scripts, and indeed most Win32 applications, can be affected by this. I tested 23 non-AutoHotkey programs that were sitting in my Downloads directory, and found the following:
I switched from 7z-sfx to a normal compiled script for v2 setup partly to avoid the use of the Temp directory, since writing there does not require elevation. Related details. (Writing to Downloads does not require elevation anyway, but the setup files could be distributed by more secure means.) The vulnerability described in this issue is ultimately caused by a Microsoft component loading a dll without specifying a full path or secure search order flags. I believe the onus is on Microsoft to fix this, and not for a hack-fix-workaround to be baked into every single portable application or setup program on Windows. Some details of the vulnerability are explained by twitter user Kurosh Dabbagh here. FileZilla developer Tim Kosse responded to an equivalent vulnerability report by closing it as "invalid". In an old blog post about a very similar situation, Raymond Chen argued that it was not a DLL planting vulernability, but rather an application directory attack. Of course, in this case the application directory is typically the downloads folder. Raymond says "Yup, the downloads folder is another hot tub filled with yucky water. This is related to the "carpet bombing" attack."
The linked article explains the search order in detail, but offers no guidelines. SetDllDirectory does not provide a solution, because it cannot be used to disable searching of the application directory. The application directory can be excluded from the search order with SetDefaultDllDirectories, but this must be called before the program creates any windows, since that is the point at which TextShaping.dll is loaded. The program creates the script's main window before the script executes. In other words, calling it within the script is ineffective. The default search order can't be changed within AutoHotkey.exe for backward-compatibility reasons. The remaining options are to compile the install script with a custom binary (which won't solve the issue for any other compiled scripts), or to add something like a directive to control the DLL search order/flags at load time (which means v2.1 at the earliest). SetDefaultDllDirectories must be dynamically linked for the program to run on Windows 7 systems, and it will be unavailable if KB2533623 is not installed. SetDefaultDllDirectories alone isn't sufficient, because even statically-linked DLLs can be loaded from the application directory, before the program's entry point executes. For instance, dwmapi.dll, because it is not in the KnownDLLs list. The hack-fix-workaround for this is purportedly to delay load all DLLs, and use a delay load hook to force them to load from system32. One implementation of this can be seen in the Rufus source code, but my attempt at applying this to AutoHotkey was unsuccessful. |
Thank you for taking your time and looking into this issue @Lexikos. Appreciate your detailed response. Hope you have a great day. |
Hello, @Lexikos. I'm opening this issue as advised by the AHK Discord mods.
AutoHotKey installer was found to have an untrusted search path vulnerability, since the installer is relying on the Windows default search order to load libraries. This could potentially allow an attacker to execute arbitrary code on a user's machine.
How to Reproduce (Proof of Concept)
Proof of concept worked on a Microsoft Windows 10 Home VM running version 10.0.19045 Build 19045 (with latest patches)
TextShaping.dll
C:\Users\<username>\Downloads
), drop the custom DLLTextShaping.dll
DLL is loaded before you would get the UAC (User Account Control) prompt.Remediation Steps
To fix this, Microsoft has multiple guidelines to perform safe DLL search order, such removing the current directory from the standard search path by calling SetDllDirectory
Please see below Microsoft's guidelines:
The text was updated successfully, but these errors were encountered: