Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 3 tasks
janvorli opened this issue Sep 11, 2024 · 1 comment · Fixed by #42839
Closed
1 of 3 tasks

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

janvorli opened this issue Sep 11, 2024 · 1 comment · Fixed by #42839
Assignees
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.

Comments

@janvorli
Copy link
Member

janvorli commented Sep 11, 2024

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

@janvorli janvorli added doc-idea Indicates issues that are suggestions for new topics [org][type][category] breaking-change Indicates a .NET Core breaking change Pri1 High priority, do before Pri2 and Pri3 labels Sep 11, 2024
@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged binary incompatible Existing binaries may encounter a breaking change in behavior. labels Sep 11, 2024
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Sep 11, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Sep 11, 2024
@jkotas
Copy link
Member

jkotas commented Sep 12, 2024

In the description, we can include a link to https://techcommunity.microsoft.com/t5/windows-os-platform-blog/developer-guidance-for-hardware-enforced-stack-protection/ba-p/2163340 that provides additional technical details.

The primary recommended actions should be ones that do not compromise security: fix the native library to be CET compatible, or to request the fix from the native library maintainer; or avoid dependency on the offending native library.

@gewarren gewarren added 🗺️ reQUEST Triggers an issue to be imported into Quest. and removed ⌚ Not Triaged Not triaged labels Oct 1, 2024
@dotnetrepoman dotnetrepoman bot added 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. and removed 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. labels Oct 1, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Oct 2, 2024
@dotnetrepoman dotnetrepoman bot added ⌚ Not Triaged Not triaged and removed ⌚ Not Triaged Not triaged labels Oct 2, 2024
@dotnet-policy-service dotnet-policy-service bot added the in-pr This issue will be closed (fixed) by an active pull request. label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

4 participants