.Net: Disable automatic HTTP redirects in HttpPlugin and WebFileDownloadPlugin default clients#14132
Merged
SergeyMenshykh merged 2 commits intoJul 2, 2026
Conversation
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
24ee753 to
739c9cb
Compare
Contributor
There was a problem hiding this comment.
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 switchesHttpPlugin/WebFileDownloadPlugindefault constructors to use non-redirecting clients. - .NET: Adds unit tests intended to verify redirect responses are not followed.
- Python: Enforces
excluded_functionsat 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.
…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>
739c9cb to
9803aae
Compare
westey-m
approved these changes
Jul 2, 2026
rogerbarreto
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default HTTP clients used by
HttpPluginandWebFileDownloadPluginnow haveAllowAutoRedirectset tofalse. This ensures theAllowedDomainsrestriction is enforced consistently regardless of server responses.GetNonRedirectingHttpClient()toHttpClientProvider(all target frameworks)