Skip to content

.Net: Disable automatic HTTP redirects in HttpPlugin and WebFileDownloadPlugin default clients#14132

Merged
SergeyMenshykh merged 2 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-fix-redirect-ssrf
Jul 2, 2026
Merged

.Net: Disable automatic HTTP redirects in HttpPlugin and WebFileDownloadPlugin default clients#14132
SergeyMenshykh merged 2 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-fix-redirect-ssrf

Conversation

@SergeyMenshykh

@SergeyMenshykh SergeyMenshykh commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The default HTTP clients used by HttpPlugin and WebFileDownloadPlugin now have AllowAutoRedirect set to false. This ensures the AllowedDomains restriction is enforced consistently regardless of server responses.

  • Added GetNonRedirectingHttpClient() to HttpClientProvider (all target frameworks)
  • Updated both plugins to use non-redirecting clients by default
  • Added unit tests verifying redirect responses are not followed
  • Updated XML documentation

Copilot AI review requested due to automatic review settings July 1, 2026 15:22
@SergeyMenshykh SergeyMenshykh requested review from a team as code owners July 1, 2026 15:22
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
connectors
   mcp.py46420555%81, 86, 98, 108–117, 124–125, 128–129, 138–139, 146, 160–167, 175–179, 181–182, 184, 193, 296–302, 337–339, 344–346, 360–361, 364–365, 373–375, 407–408, 410, 412, 414–420, 424–426, 428–438, 442–443, 447–448, 452, 454, 458–459, 463, 471, 486, 501–509, 528–529, 544–545, 564–565, 568–569, 572–577, 581–582, 585–586, 589–595, 675, 677, 750, 752, 754, 756, 831, 833, 835, 837, 839, 903, 946–951, 953–956, 961, 1014, 1016, 1019, 1033, 1053–1055, 1070–1074, 1077–1080, 1083–1085, 1089–1093, 1096–1097, 1106–1107, 1109–1111, 1125–1126, 1128–1129, 1131–1133, 1136, 1143–1146, 1154, 1159–1164, 1169, 1171, 1174–1176
TOTAL28901565380% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4052 23 💤 0 ❌ 0 🔥 1m 22s ⏱️

@SergeyMenshykh SergeyMenshykh force-pushed the sergeymenshykh-fix-redirect-ssrf branch from 24ee753 to 739c9cb Compare July 1, 2026 15:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 tightens security around outbound HTTP usage by ensuring Semantic Kernel’s built-in web plugins don’t automatically follow HTTP redirects, preventing redirect-based bypasses of the domain allow-list. It also adds a Python MCP server hardening change to enforce excluded tools at call time.

Changes:

  • .NET: Introduces HttpClientProvider.GetNonRedirectingHttpClient() and switches HttpPlugin / WebFileDownloadPlugin default constructors to use non-redirecting clients.
  • .NET: Adds unit tests intended to verify redirect responses are not followed.
  • Python: Enforces excluded_functions at MCP call time (not only by omitting them from tool listings) and adds a unit test for that behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
python/tests/unit/connectors/mcp/test_mcp.py Adds a unit test asserting excluded MCP tools cannot be invoked.
python/semantic_kernel/connectors/mcp.py Enforces excluded tool names at call time by raising an MCP “method not found” error.
dotnet/src/Plugins/Plugins.Web/WebFileDownloadPlugin.cs Switches default HTTP client to non-redirecting and updates XML docs to clarify redirect behavior.
dotnet/src/Plugins/Plugins.UnitTests/Web/WebFileDownloadPluginTests.cs Adds a redirect-related test for file downloads.
dotnet/src/Plugins/Plugins.UnitTests/Core/HttpPluginTests.cs Adds a redirect-related test for HttpPlugin.
dotnet/src/Plugins/Plugins.Core/HttpPlugin.cs Switches default HTTP client to non-redirecting and updates XML docs to clarify redirect behavior.
dotnet/src/InternalUtilities/src/Http/HttpClientProvider.cs Adds a non-redirecting HttpClient factory backed by a handler with AllowAutoRedirect = false.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dotnet/src/Plugins/Plugins.UnitTests/Core/HttpPluginTests.cs
…oadPlugin default clients

The default HTTP clients used by HttpPlugin and WebFileDownloadPlugin now have
AllowAutoRedirect set to false. This ensures the AllowedDomains restriction
cannot be circumvented by following redirects to hosts outside the allow-list.

- Added GetNonRedirectingHttpClient() to HttpClientProvider
- Updated both plugins to use non-redirecting clients by default
- Added unit tests verifying redirect responses are not followed
- Updated XML documentation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SergeyMenshykh SergeyMenshykh force-pushed the sergeymenshykh-fix-redirect-ssrf branch from 739c9cb to 9803aae Compare July 1, 2026 15:33
@giles17 giles17 added the .NET Issue or Pull requests regarding .NET code label Jul 2, 2026
@SergeyMenshykh SergeyMenshykh self-assigned this Jul 2, 2026
@SergeyMenshykh SergeyMenshykh moved this to In Review in Agent Framework Jul 2, 2026
@SergeyMenshykh SergeyMenshykh enabled auto-merge July 2, 2026 08:32
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Jul 2, 2026
Merged via the queue into microsoft:main with commit e6c9673 Jul 2, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this to Sprint: Done in Semantic Kernel Jul 2, 2026
@github-project-automation github-project-automation Bot moved this from In Review to Done in Agent Framework Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issue or Pull requests regarding .NET code

Projects

Status: Done
Status: Sprint: Done

Development

Successfully merging this pull request may close these issues.

5 participants