Hi,
We are using Inno Setup for our installer. Recently we have discovered a DLL hijacking issue related to the installer. To reproduce it, it’s enough to build an x86 C++ library called `version.dll` and place it into a folder next to the installer.
We’ve found information in the Inno Setup log: https://jrsoftware.org/files/is5.5-whatsnew.htm - that this issue was mitigated in v5.3, and then the mitigation was improved in v5.5. We are currently using v6.0.2. We didn’t see any changes related to this in v6.0.3 or v6.0.4, so we assume that the problem is reproducible on the latest version.
This is a serious issue because our Setup runs in an administrator mode.
Do we miss something on how this can be fixed? Thanks!
Regards,
____________________________________________________________
Alexander Ovchinnikov
Software developer
We are using Inno Setup for our installer. Recently we have discovered a DLL hijacking issue related to the installer. To reproduce it, it’s enough to build an x86 C++ library called `version.dll` and place it into a folder next to the installer.
It's `Mendix-<version>-Setup.exe`. You are asking because of problems with `setup.exe`, right? But in our case it's not plain `setup`, we specifically change it in the [Setup] section of the script.
We are using Inno Setup for our installer. Recently we have discovered a DLL hijacking issue related to the installer. To reproduce it, it’s enough to build an x86 C++ library called `version.dll` and place it into a folder next to the installer.
We’ve found information in the Inno Setup log: https://jrsoftware.org/files/is5.5-whatsnew.htm - that this issue was mitigated in v5.3, and then the mitigation was improved in v5.5. We are currently using v6.0.2. We didn’t see any changes related to this in v6.0.3 or v6.0.4, so we assume that the problem is reproducible on the latest version.
This is a serious issue because our Setup runs in an administrator mode.
By the time you can call an API, you may have already lost.
Hi Martijn,
Thank you for the detailed response!
I understand this is the way Windows works, and also that there will always be at least `kernel32.dll` which will be loaded into the process immediately.
At the same time, it would be very weird if `kernel32.dll` could be loaded from the application directory. And apparently it cannot – because of the Known DLLs feature in Windows: https://docs.microsoft.com/en-us/archive/blogs/larryosterman/what-are-known-dlls-anyway . According to that article:
> it prevents people from exploiting weak application directory permissions by dropping in Trojan horse versions of system DLLs (since the key system DLLs are all known DLLs, the version of the file in the application directory will be ignored)
Would it make sense to reduce the potential attack surface on Inno Setup by delay-loading DLLs that are not on that list? `version.dll` is not on that list on my machine, as well as `NETAPI32.dll` (mentioned in the last post in the thread). Then, I guess, the `SetDefaultDllDirectories` mechanism will make sure those DLLs are delay-loaded from proper directories according to the order set by this function.
Regards,
Alexander
--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
innosetup+...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/innosetup/15dcdaae-789e-7b6d-df5f-3b804ada17f0%40gmail.com.
Hi,
We are using Inno Setup for our installer. Recently we have discovered a DLL hijacking issue related to the installer. To reproduce it, it’s enough to build an x86 C++ library called `version.dll` and place it into a folder next to the installer.
Dump of file Mendix-8.11.0.6347-Setup.exe
File Type: EXECUTABLE IMAGE
Image has the following dependencies:
kernel32.dll
comctl32.dll
version.dll
user32.dll
oleaut32.dll
netapi32.dll
advapi32.dll
Image has the following delay load dependencies:
kernel32.dll
user32.dll
kernel32.dll
Fortunately, there might be a simple workaround: add "loadFrom" entries to the manifest for the two DLLs as shown here:
https://github.com/curl/curl/issues/2326
Unfortunately, most modern browsers will automatically save downloaded
files to the same directory, so it's not that hard to plant DLLs
there…
Thanks, this works. I will make a new test build later.
On Saturday, May 16, 2020 at 12:51:20 PM UTC-5, Martijn Laan wrote:Thanks, this works. I will make a new test build later.
Thanks. Hopefully there are no side effects on earlier Windows versions...
On Saturday, May 16, 2020 at 12:51:20 PM UTC-5, Martijn Laan wrote:
Thanks, this works. I will make a new test build later.
Thanks. Hopefully there are no side effects on earlier Windows versions...
I tried with the Inno Setup 6.0.5 dev build and can confirm that the issue is fixed for version.dll and netapi32.dll.
In Windows 10 Creators Update we added a new process mitigation that can be used to mitigate the Application Directory DLL planting vulnerabilities. This new process mitigation, PreferSystem32, when opted in toggles the order of application directory and system32 in the DLL search order. Because of this any malicious system binary can’t be hijacked by planting it in the application directory. This can be enabled for the scenarios where the process creation can be controlled.
This uses the SetProcessMitigationPolicy call. Is this possible from Delphi?