Skip to content

Commit d82b481

Browse files
authored
CET supported by default (#42839)
1 parent 401bace commit d82b481

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

docs/core/compatibility/9.0.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
6060

6161
| Title | Type of change | Introduced version |
6262
|-----------------------------------------------------------------------------------|---------------------|--------------------|
63-
| [Deprecated desktop Windows/macOS/Linux MonoVM runtime packages](deployment/9.0/monovm-packages.md) | Source incompatible | Preview 7 |
63+
| [Deprecated desktop Windows/macOS/Linux MonoVM runtime packages](deployment/9.0/monovm-packages.md) | Source incompatible | Preview 7 |
64+
65+
## Interop
66+
67+
| Title | Type of change | Introduced version |
68+
|--------------------------------------------------------|---------------------|--------------------|
69+
| [CET supported by default](interop/9.0/cet-support.md) | Binary incompatible | Preview 6 |
6470

6571
## JIT compiler
6672

@@ -73,7 +79,7 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
7379

7480
| Title | Type of change | Introduced version |
7581
|-----------------------------------------------------------------------------------|---------------------|--------------------|
76-
| [HttpClientFactory logging redacts header values by default](networking/9.0/redact-headers.md) | Behavioral change | RC 1 |
82+
| [HttpClientFactory logging redacts header values by default](networking/9.0/redact-headers.md) | Behavioral change | RC 1 |
7783
| [HttpListenerRequest.UserAgent is nullable](networking/9.0/useragent-nullable.md) | Source incompatible | Preview 1 |
7884

7985
## SDK and MSBuild
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "Breaking change: CET supported by default"
3+
description: Learn about the breaking change in interop in .NET 9 where CET is supported by default.
4+
ms.date: 10/04/2024
5+
---
6+
# CET supported by default
7+
8+
`apphost` and `singlefilehost` are now marked as Intel CET—compatible (they're compiled with the `/CETCOMPAT` option). This change was made to enhance security of .NET applications. However, it imposes a limitation on the shared libraries that .NET apps can load and interop with. Libraries aren't allowed to set thread context to a location with an instruction pointer that's not present on the shadow stack or in a table of allowed continuation addresses for exception handling.
9+
10+
## Previous behavior
11+
12+
Previously, shared libraries loaded into the .NET process were able to set thread context using [SetThreadContext](/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadcontext), [RtlRestoreContext](/windows/win32/api/winnt/nf-winnt-rtlrestorecontext)/`NtContinue`, or their exception handlers to any location in the process address space.
13+
14+
## New behavior
15+
16+
Starting in .NET 9, shared libraries loaded into the .NET process are only allowed to set thread context using [SetThreadContext](/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadcontext), [RtlRestoreContext](/windows/win32/api/winnt/nf-winnt-rtlrestorecontext)/`NtContinue`, or their exception handlers to locations that are either:
17+
18+
- Present on the shadow stack.
19+
- In a table of allowed continuation addresses for exception handling (generated by the `/EHCONT` compiler option or the `SetProcessDynamicEHContinuationTargets` API).
20+
21+
If libraries try to change a thread context to any other location, the process is terminated.
22+
23+
## Version introduced
24+
25+
.NET 9 Preview 6
26+
27+
## Type of breaking change
28+
29+
This change can affect [binary compatibility](../../categories.md#binary-compatibility).
30+
31+
## Reason for change
32+
33+
Enabling CET enhances the security of .NET applications by adding hardware-enforced stack protection that offers robust protection against ROP exploits (return-oriented programming).
34+
35+
## Recommended action
36+
37+
Workarounds:
38+
39+
- You can opt out of CET by adding `<CETCompat>false</CETCompat>` to your app's project file (for example, *.csproj* file).
40+
- Use the Windows Security app or a group policy to opt out of the hardware-supported stack enforcement for the specific .NET application. For more information, see [Enable exploit protection](/defender-endpoint/enable-exploit-protection).
41+
42+
## Affected APIs
43+
44+
- N/A

docs/core/compatibility/toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ items:
6060
items:
6161
- name: Deprecated desktop Windows/macOS/Linux MonoVM runtime packages
6262
href: deployment/9.0/monovm-packages.md
63+
- name: Interop
64+
items:
65+
- name: CET supported by default
66+
href: interop/9.0/cet-support.md
6367
- name: JIT compiler
6468
items:
6569
- name: Floating point to integer conversions are saturating
@@ -1620,6 +1624,10 @@ items:
16201624
href: globalization.md
16211625
- name: Interop
16221626
items:
1627+
- name: .NET 9
1628+
items:
1629+
- name: CET supported by default
1630+
href: interop/9.0/cet-support.md
16231631
- name: .NET 8
16241632
items:
16251633
- name: CreateObjectFlags.Unwrap only unwraps on target instance

0 commit comments

Comments
 (0)