Skip to content

[Breaking change]: .NET 9 enables CET support by default #42600

@janvorli

Description

@janvorli

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

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

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:

Feature area

Interop

Affected APIs

No response


Associated WorkItem - 320279

Metadata

Metadata

Assignees

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.binary incompatibleExisting binaries may encounter a breaking change in behavior.breaking-changeIndicates a .NET Core breaking changein-prThis issue will be closed (fixed) by an active pull request.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions