Skip to content

Commit 1e04a74

Browse files
Merge pull request #42643 from dotnet/main
Merge main into live
2 parents 7365afb + 864db99 commit 1e04a74

File tree

3 files changed

+63
-57
lines changed

3 files changed

+63
-57
lines changed

docs/core/deploying/native-aot/index.md

Lines changed: 16 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@ The benefit of Native AOT is most significant for workloads with a high number o
1414

1515
The Native AOT deployment model uses an ahead-of-time compiler to compile IL to native code at the time of publish. Native AOT apps don't use a just-in-time (JIT) compiler when the application runs. Native AOT apps can run in restricted environments where a JIT isn't allowed. Native AOT applications target a specific runtime environment, such as Linux x64 or Windows x64, just like publishing a [self-contained app](../index.md#publish-self-contained).
1616

17-
## Limitations in the .NET Native AOT deployment model
18-
19-
### [.NET 7](#tab/net7)
20-
21-
Native AOT is targeted towards console-type apps. Only a limited number of libraries are fully compatible with Native AOT.
22-
23-
### [.NET 8+](#tab/net8plus)
24-
25-
AOT support in .NET 8 is more comprehensive than in .NET 7. However, there are still some limitations. For more information, see [Limitations of Native AOT deployment](#limitations-of-native-aot-deployment).
26-
27-
---
28-
2917
## Prerequisites
3018

3119
# [Windows](#tab/windows)
@@ -84,12 +72,6 @@ Check out the [Native AOT samples](https://github.com/dotnet/samples/tree/main/c
8472

8573
## AOT-compatibility analyzers
8674

87-
### [.NET 7](#tab/net7)
88-
89-
AOT-compatibility analyzers are available only in .NET 8 and later versions.
90-
91-
### [.NET 8+](#tab/net8plus)
92-
9375
The `IsAotCompatible` property is used to indicate whether a library is compatible with Native AOT. Consider when a library sets the `IsAotCompatible` property to `true`, for example:
9476

9577
```xml
@@ -107,24 +89,8 @@ The preceding configuration assigns a default of `true` to the following propert
10789

10890
These analyzers help to ensure that a library is compatible with Native AOT.
10991

110-
---
111-
11292
## Native debug information
11393

114-
### [.NET 7](#tab/net7)
115-
116-
Native AOT publishing follows platform conventions for native toolchains. The default behavior of native toolchains on Windows is to produce debug information in a separate *.pdb* file. The default behavior of native toolchains on Linux is to include the debug information in the native binary, which makes the native binary larger.
117-
118-
Set the `StripSymbols` property to `true` to produce the debug information in a separate *.dbg* file and exclude it from the native binary on Linux. (This property has no effect on Windows.)
119-
120-
```xml
121-
<PropertyGroup>
122-
<StripSymbols>true</StripSymbols>
123-
</PropertyGroup>
124-
```
125-
126-
### [.NET 8+](#tab/net8plus)
127-
12894
By default, Native AOT publishing produces debug information in a separate file:
12995

13096
- Linux: *.dbg*
@@ -139,8 +105,6 @@ The debug file is necessary for running the app under the [debugger or inspectin
139105
</PropertyGroup>
140106
```
141107

142-
---
143-
144108
## Limitations of Native AOT deployment
145109

146110
Native AOT apps have the following limitations:
@@ -154,35 +118,16 @@ Native AOT apps have the following limitations:
154118
- Apps include required runtime libraries (just like [self-contained apps](../index.md#publish-self-contained), increasing their size as compared to framework-dependent apps).
155119
- <xref:System.Linq.Expressions> always use their interpreted form, which is slower than run-time generated compiled code.
156120
- Not all the runtime libraries are fully annotated to be Native AOT compatible. That is, some warnings in the runtime libraries aren't actionable by end developers.
157-
158-
The publish process analyzes the entire project and its dependencies for possible limitations. Warnings are issued for each limitation the published app may encounter at run time.
159-
160-
### Version specific limitations
161-
162-
### [.NET 7](#tab/net7)
163-
164-
- Should be targeted for console type apps. ASP.NET Core is ***not*** supported.
165-
- Limited diagnostic support for debugging and profiling.
166-
167-
### [.NET 8+](#tab/net8plus)
168-
169121
- [Diagnostic support for debugging and profiling](./diagnostics.md) with some limitations.
170122
- Support for some ASP.NET Core features. For more information, see [ASP.NET Core support for Native AOT](/aspnet/core/fundamentals/native-aot/).
171123

172-
---
124+
The publish process analyzes the entire project and its dependencies for possible limitations. Warnings are issued for each limitation the published app might encounter at run time.
173125

174126
## Platform/architecture restrictions
175127

176128
The following table shows supported compilation targets.
177129

178-
### [.NET 7](#tab/net7)
179-
180-
| Platform | Supported architecture |
181-
|----------|------------------------|
182-
| Windows | x64, Arm64 |
183-
| Linux | x64, Arm64 |
184-
185-
### [.NET 8+](#tab/net8plus)
130+
### [.NET 8](#tab/net8)
186131

187132
| Platform | Supported architecture | Notes |
188133
|----------|------------------------|----------------------|
@@ -196,4 +141,18 @@ The following table shows supported compilation targets.
196141
| MacCatalyst | x64, Arm64 | Experimental support |
197142
| Android | x64, Arm64 | Experimental, no built-in Java interop |
198143

144+
### [.NET 9+](#tab/net9plus)
145+
146+
| Platform | Supported architecture | Notes |
147+
|----------|------------------------|----------------------|
148+
| Windows | x64, Arm64, x86 | |
149+
| Linux | x64, Arm64, Arm | |
150+
| macOS | x64, Arm64 | |
151+
| iOS | Arm64 | |
152+
| iOSSimulator | x64, Arm64 | |
153+
| tvOS | Arm64 | |
154+
| tvOSSimulator | x64, Arm64 | |
155+
| MacCatalyst | x64, Arm64 | |
156+
| Android | x64, Arm64, Arm | Experimental, no built-in Java interop |
157+
199158
---
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Security
3+
description: Learn about security features available with native AOT.
4+
author: MichalStrehovsky
5+
ms.author: michals
6+
ms.date: 09/11/2024
7+
---
8+
9+
# Security features
10+
11+
.NET offers many facilities to help address security concerns when building apps. Native AOT deployment builds on top of these facilities and provides several that can help harden your apps.
12+
13+
## No run-time code generation
14+
15+
Since native AOT generates all code at the time of publishing the app, no new executable code needs to be generated at run time. This allows running your apps in environments that disallow creation of new executable code pages at run time. All the code that the CPU executes can be digitally signed.
16+
17+
## Restricted reflection surface
18+
19+
When apps are published with native AOT, the compiler analyzes the usage of reflection within the app. Only the program elements that were deemed to be targets of reflection are available for reflection at run time. Places within the program that attempt to do unconstrained reflection are flagged using [trimming warnings](../trimming/fixing-warnings.md). Program elements that weren't intended to be targets of reflection cannot be reflected on. This restriction can prevent a class of issues where a malicious actor gets in control of what the program reflects on and invokes unintended code. This restriction includes approaches that use `Assembly.LoadFrom` or `Reflection.Emit` - neither of those work with native AOT, and their use is flagged with a warning at build time.
20+
21+
## Control Flow Guard
22+
23+
[Control Flow Guard](/windows/win32/secbp/control-flow-guard) is a highly optimized platform security feature on Windows that was created to combat memory corruption vulnerabilities. By placing tight restrictions on where an application can execute code from, it makes it much harder for exploits to execute arbitrary code through vulnerabilities such as buffer overflows.
24+
25+
To enable Control Flow Guard on your native AOT app, set the `ControlFlowGuard` property in the published project.
26+
27+
```xml
28+
<PropertyGroup>
29+
<!-- Enable control flow guard -->
30+
<ControlFlowGuard>Guard</ControlFlowGuard>
31+
</PropertyGroup>
32+
```
33+
34+
## Control-flow Enforcement Technology Shadow Stack (.NET 9+)
35+
36+
Control-flow Enforcement Technology (CET) Shadow Stack is a computer processor feature. It provides capabilities to defend against return-oriented programming (ROP) based malware attacks.
37+
38+
CET is enabled by default when publishing for Windows. To disable CET, set the `CetCompat` property in the published project.
39+
40+
```xml
41+
<PropertyGroup>
42+
<!-- Disable Control-flow Enforcement Technology -->
43+
<CetCompat>false</CetCompat>
44+
</PropertyGroup>
45+
```

docs/navigate/devops-testing/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ items:
495495
href: ../../core/deploying/native-aot/libraries.md
496496
- name: Cross-compilation
497497
href: ../../core/deploying/native-aot/cross-compile.md
498+
- name: Security
499+
href: ../../core/deploying/native-aot/security.md
498500
- name: Intro to AOT warnings
499501
href: ../../core/deploying/native-aot/fixing-warnings.md
500502
- name: Intrinsic APIs marked RequiresDynamicCode

0 commit comments

Comments
 (0)