Native DLLs: only load imported DLLs from System32 #112359
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By using the /DEPENDENTLOADFLAG link.exe flag, we can tell the Windows loader to only look for referenced DLLs in the System32 directory. This prevents DLL injection, like #87495 fixed in 2023. This is a defense-in-depth change; it does not solve any known security problem.
This PR is a new version of #89311 which was merged in 2023 but reverted by #95540 shortly after. The reason the original PR was reverted is that
link.exedid not support changing/DEPENDENTLOADFLAGwhen consuming PGO data ( internal Microsoft issue link ). It appears that issue has been fixed in the version oflink.exeused to build .NET.