Hi @Mashuk Raza , Welcome to Microsoft Q&A,
The references give you some suggestions, which cannot guarantee that they can directly solve your problem. You can refer to them appropriately.
Even if you have administrator access, you should try to limit the permissions required by the application when it runs, and ensure that it has only the minimum permissions required to perform the task. This can reduce the risk of injection attacks.
Make sure your application only loads DLL files from trusted locations. Limit DLL loading by setting the appropriate DLL search path.
Windows API: Use SetDllDirectory and AddDllDirectory to control the DLL search path.
.NET: You can use AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", "path") to set a dedicated binary directory.
Signing and verifying DLLs can ensure that only verified and signed DLLs can be loaded into your application.
C# and .NET: Use Strong Name Signing and code signing certificates to sign DLLs and verify the signature when loading.
C++: Use Authenticode code signing
Limit the executable files and DLLs that can run on the system through application whitelisting.
AppLocker or Windows Defender Application Control (WDAC): These tools allow you to create policies to control which DLLs and executables can run.
ASLR randomizes memory addresses in a process, making it harder for attackers to predict memory addresses.
Windows: Starting with Windows Vista, ASLR is enabled by default, but make sure you compile with the /DYNAMICBASE option.
.NET and C++: Make sure you compile with ASLR support.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.