Skip to content

Conversation

@BrennanConroy
Copy link
Member

AppContext for HttpSys CBT hardening

Description

Request from a partner team to allow setting hardened security for their HTTP.Sys applications.

Customer Impact

By default there is no impact, this change is opt-in. If the change is enabled then it sets hardened security for the endpoints exposed by the HTTP.Sys application.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Purely opt-in change. We've also verified the change with the partner team.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@BrennanConroy BrennanConroy added this to the 9.0.x milestone Nov 10, 2025
Copilot AI review requested due to automatic review settings November 10, 2025 23:03
@BrennanConroy BrennanConroy added the Servicing-consider Shiproom approval is required for the issue label Nov 10, 2025
@dotnet-policy-service
Copy link
Contributor

Hi @@BrennanConroy. If this is not a tell-mode PR, please make sure to follow the instructions laid out in the servicing process document.
Otherwise, please add tell-mode label.

Copilot finished reviewing on behalf of BrennanConroy November 10, 2025 23:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an opt-in AppContext switch (Microsoft.AspNetCore.Server.HttpSys.EnableCBTHardening) that enables hardened Channel Binding Token (CBT) security for HTTP.Sys applications. This change was requested by a partner team to support enhanced security configurations.

Key changes:

  • Added support for HTTP_CHANNEL_BIND_INFO native structure
  • Implemented CBT hardening configuration in UrlGroup constructor with medium hardening level
  • Made the feature opt-in via AppContext switch to ensure no impact to existing applications

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Servers/HttpSys/src/NativeMethods.txt Added HTTP_CHANNEL_BIND_INFO to the list of native types for P/Invoke generation
src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs Implemented CBT hardening logic in UrlGroup constructor, checking AppContext switch and calling SetProperty with channel binding settings

ServiceNames = (HTTP_SERVICE_BINDING_BASE**)IntPtr.Zero,
NumberOfServiceNames = 0,
};
SetProperty(HTTP_SERVER_PROPERTY.HttpServerChannelBindProperty, new(&channelBindingSettings), (uint)ChannelBindInfoSize);
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SetProperty call in the constructor should handle potential errors. If this call fails, the UrlGroup is still constructed but without CBT hardening, which could lead to a silent security configuration failure. Consider adding error handling or logging similar to other property setters in this class, or document that failures are intentionally ignored during construction.

Suggested change
SetProperty(HTTP_SERVER_PROPERTY.HttpServerChannelBindProperty, new(&channelBindingSettings), (uint)ChannelBindInfoSize);
try
{
SetProperty(HTTP_SERVER_PROPERTY.HttpServerChannelBindProperty, new(&channelBindingSettings), (uint)ChannelBindInfoSize);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to set CBT hardening on UrlGroup during construction. Security configuration may be incomplete.");
// Optionally, rethrow or handle as needed for your application's security requirements.
}

Copilot uses AI. Check for mistakes.
@rbhanda rbhanda modified the milestones: 9.0.x, 9.0.12 Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Servicing-consider Shiproom approval is required for the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants