[Breaking change]: .NET 9 enables CET support by default #42600
Labels
binary incompatible
Existing binaries may encounter a breaking change in behavior.
breaking-change
Indicates a .NET Core breaking change
doc-idea
Indicates issues that are suggestions for new topics [org][type][category]
in-pr
This issue will be closed (fixed) by an active pull request.
Pri1
High priority, do before Pri2 and Pri3
📌 seQUESTered
Identifies that an issue has been imported into Quest.
Description
In .NET 9 Preview 6, the apphost and singlefilehost started to be marked as Intel CET compatible (they are compiled with /CETCOMPAT option). It was done to enhance security of .NET applications. That imposes a limitation on shared libraries that .NET applications can load and interop with. They are not allowed to set thread context to a location with instruction pointer that is not present on the shadow stack or in a table of allowed continuation addresses for exception handling.
Version
Other (please put exact version in description textbox)
Previous behavior
Shared libraries loaded into .NET process were able to set thread context using SetThreadContext, RtlRestoreContext/NtContinue or using their exception handlers to any location in the process address space.
New behavior
Shared libraries loaded into .NET process are only allowed to set thread context using SetThreadContext, RtlRestoreContext/NtContinue or using their exception handlers to locations that are present on the shadow stack or in a table of allowed continuation addresses for exception handling (generated by /EHCONT compiler option or the
SetProcessDynamicEHContinuationTargets
API). Trying to change a thread context to any other location results in termination of the process.Type of breaking change
Reason for change
Enabling CET for .NET applications enhance the security of the .NET applications by adding hardware-enforced stack protection that offers robust protection against ROP exploits (return oriented programming).
Recommended action
Workarounds:
<CETCompat>false</CETCompat>
to the .csproj of the application opts out of the CETFeature area
Interop
Affected APIs
No response
Associated WorkItem - 320279
The text was updated successfully, but these errors were encountered: