-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[release/10.0] AppContext for HttpSys CBT hardening #64298
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,8 @@ internal sealed partial class UrlGroup : IDisposable | |||||
| Marshal.SizeOf<HTTP_QOS_SETTING_INFO>(); | ||||||
| private static readonly int RequestPropertyInfoSize = | ||||||
| Marshal.SizeOf<HTTP_BINDING_INFO>(); | ||||||
| private static readonly int ChannelBindInfoSize = | ||||||
| Marshal.SizeOf<HTTP_CHANNEL_BIND_INFO>(); | ||||||
|
|
||||||
| private readonly ILogger _logger; | ||||||
|
|
||||||
|
|
@@ -42,6 +44,17 @@ internal unsafe UrlGroup(ServerSession serverSession, RequestQueue requestQueue, | |||||
|
|
||||||
| Debug.Assert(urlGroupId != 0, "Invalid id returned by HttpCreateUrlGroup"); | ||||||
| Id = urlGroupId; | ||||||
|
|
||||||
| if (AppContext.TryGetSwitch("Microsoft.AspNetCore.Server.HttpSys.EnableCBTHardening", out var enabled) && enabled) | ||||||
| { | ||||||
| var channelBindingSettings = new HTTP_CHANNEL_BIND_INFO | ||||||
| { | ||||||
| Hardening = HTTP_AUTHENTICATION_HARDENING_LEVELS.HttpAuthenticationHardeningMedium, | ||||||
| ServiceNames = (HTTP_SERVICE_BINDING_BASE**)IntPtr.Zero, | ||||||
| NumberOfServiceNames = 0, | ||||||
| }; | ||||||
| SetProperty(HTTP_SERVER_PROPERTY.HttpServerChannelBindProperty, new(&channelBindingSettings), (uint)ChannelBindInfoSize); | ||||||
|
||||||
| SetProperty(HTTP_SERVER_PROPERTY.HttpServerChannelBindProperty, new(&channelBindingSettings), (uint)ChannelBindInfoSize); | |
| SetProperty(HTTP_SERVER_PROPERTY.HttpServerChannelBindProperty, new IntPtr(&channelBindingSettings), (uint)ChannelBindInfoSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
HTTP_CHANNEL_BIND_INFOstruct is missing theFlagsfield initialization. All other similar HTTP_*_INFO structs in this codebase (e.g.,HTTP_BINDING_INFO,HTTP_CONNECTION_LIMIT_INFO,HTTP_TIMEOUT_LIMIT_INFO,HTTP_SERVER_AUTHENTICATION_INFO) setFlags = HttpApi.HTTP_PROPERTY_FLAGS_PRESENTto indicate the property is being set. This field should be added for consistency and to ensure proper property setting behavior.