Skip to content

Commit cb9bd1d

Browse files
authored
Customizable security descriptors for HTTP.sys (#35595)
1 parent 28cacf5 commit cb9bd1d

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

aspnetcore/release-notes/aspnetcore-10.0.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ This article highlights the most significant changes in ASP.NET Core in .NET 10
1313

1414
This article will be updated as new preview releases are made available. For breaking changes, see [Breaking changes in .NET](/dotnet/core/compatibility/breaking-changes).
1515

16-
<!-- New content should be added to ~/aspnetcore-9/includes/newFeatureName.md files. This will help prevent merge conflicts in this file. -->
1716

1817
## Blazor
1918

@@ -90,8 +89,9 @@ For more information, see [ASP.NET Core Authorization and Authentication metrics
9089

9190
This section describes miscellaneous new features in .NET 10.
9291

93-
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/testAppsTopLevel.md)]
92+
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/httpsys.md)]
9493

94+
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/testAppsTopLevel.md)]
9595

9696
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/jsonPatch.md)]
9797

@@ -116,3 +116,5 @@ if (RedirectHttpResult.IsLocalUrl(url))
116116
Thank you [@martincostello](https://github.com/martincostello) for this contribution!
117117

118118
## Related content
119+
120+
<xref:fundamentals/servers/httpsys>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
### Customizable security descriptors for HTTP.sys
2+
<!--PR: https://github.com/dotnet/aspnetcore/pull/61325-->
3+
4+
You can now specify a custom security descriptor for HTTP.sys request queues. The new [RequestQueueSecurityDescriptor](https://source.dot.net/#Microsoft.AspNetCore.Server.HttpSys/HttpSysOptions.cs,a556950881fd2d87) property on <xref:Microsoft.AspNetCore.Server.HttpSys.HttpSysOptions> enables more granular control over access rights for the request queue. This granular control lets you tailor security to your application's needs.
5+
6+
#### What you can do with the new property
7+
8+
A *request queue* in HTTP.sys is a kernel-level structure that temporarily stores incoming HTTP requests until your application is ready to process them. By customizing the security descriptor, you can allow or deny specific users or groups access to the request queue. This is useful in scenarios where you want to restrict or delegate HTTP.sys request handling at the operating system level.
9+
10+
#### How to use the new property
11+
12+
The `RequestQueueSecurityDescriptor` property applies only when creating a new request queue. The property doesn't affect existing request queues. To use this property, set it to a <xref:System.Security.AccessControl.GenericSecurityDescriptor> instance when configuring your HTTP.sys server.
13+
14+
For example, the following code allows all authenticated users but denies guests:
15+
[!code-csharp[](~/release-notes/aspnetcore-10/samples/HttpSysConfig/Program.cs)]
16+
17+
For more information, see <xref:fundamentals/servers/httpsys>.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Security.AccessControl;
2+
using System.Security.Principal;
3+
using Microsoft.AspNetCore.Server.HttpSys;
4+
5+
// Create a new security descriptor
6+
var securityDescriptor = new CommonSecurityDescriptor(isContainer: false, isDS: false, sddlForm: string.Empty);
7+
8+
// Create a discretionary access control list (DACL)
9+
var dacl = new DiscretionaryAcl(isContainer: false, isDS: false, capacity: 2);
10+
dacl.AddAccess(
11+
AccessControlType.Allow,
12+
new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null),
13+
-1,
14+
InheritanceFlags.None,
15+
PropagationFlags.None
16+
);
17+
dacl.AddAccess(
18+
AccessControlType.Deny,
19+
new SecurityIdentifier(WellKnownSidType.BuiltinGuestsSid, null),
20+
-1,
21+
InheritanceFlags.None,
22+
PropagationFlags.None
23+
);
24+
25+
// Assign the DACL to the security descriptor
26+
securityDescriptor.DiscretionaryAcl = dacl;
27+
28+
// Configure HTTP.sys options
29+
var builder = WebApplication.CreateBuilder();
30+
builder.WebHost.UseHttpSys(options =>
31+
{
32+
options.RequestQueueSecurityDescriptor = securityDescriptor;
33+
});

0 commit comments

Comments
 (0)