-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix vunerablity to DLL Search Order Hijacking by delay loading version.dll #1838
Conversation
…n.dll Hypothetically if the user's current directory contains a malicious DLL named version.dll, this DLL will be loaded instead of the one in System32. I checked the list of DLLs referenced by rufus.exe against the KnownDLLs list visible in Sysinternal's winobj.exe. On both Windows 7 and Windows 11, version.dll was the only DLL not on the KnownDLLs list and thus vunerable to this attack. To confirm that this work, I used dumpbin.exe /IMPORTS to make sure version.dll is delay loaded. I then put a breakpoint in the delay load hook and confirmed that the hook is used. This can be triggered by loading a Windows installation ISO file.
This implementation was inspire by dotnet/coreclr@c64a137 |
Thanks for the PR. As you've seen, I've been trying to mitigate these sideloading vulnerabilities, but Microsoft makes it quite difficult to plug them all, especially when linking libraries during compilation (a process which you'd think Microsoft would have hardened by default against side-loading but which they don't). And as you can also see, trying to service both MSVC and MinGW compilation is tricky, because things that apply to MSVC, such as |
I'm not sure this is actually the correct thing to do. Why is there an extra const?
Oh, that's too bad. A 10 year old stack overflow post says there is no GCC equivalent, but I'll spend some time next weekend digging into GCC and |
Yeah, I saw the same stackoverflow entry, which is why I fear the only solution that'll apply to both compilers is not to link with |
I did figure out a way in MinGW to create a delay-load import library for an existing DLL. See this repo for the complete example: https://github.com/AustinWise/delay-load-mingw I'm thinking that the effort involved in maintaining the MSVC compiler flags and generating a custom import library for GCC is more effort than it is worth. I think it is simpler to just |
Yes, I agree. I'm planning to take care of that when I have some time. But I'm also still planning to apply your delayed loading proposal for MSVC, as it's definitely something worth to have there. |
Sorry for the delay. I have now altered Rufus so that we manually load the calls we need from Thanks again for your contribution! |
* This is part of #1838, where we need to sort the version.dll sideloading problem for MinGW. * A subsequent patch will be applied to MSVC, to more generally delay the loading of DLLs. * Also fix a typo with an assert expression.
Hypothetically if the user's current directory contains a malicious DLL
named version.dll, this DLL will be loaded instead of the one in System32.
I checked the list of DLLs referenced by rufus.exe against the KnownDLLs
list visible in Sysinternal's winobj.exe. On both Windows 7 and Windows 11,
version.dll was the only DLL not on the KnownDLLs list and thus vunerable
to this attack.
To confirm that this work, I used dumpbin.exe /IMPORTS to make sure
version.dll is delay loaded. I then put a breakpoint in the delay load hook
and confirmed that the hook is used. This can be triggered by loading a
Windows installation ISO file.
I also removed
kernel32_path
, since kernel32.dll is on the KnownDLLslist and is not vulnerable to this attack.
For information about KnownDLLs, see this article.
For information about delay-load DLL hooks, see this article