Merged
Conversation
likms
previously approved these changes
Apr 8, 2026
There was a problem hiding this comment.
Pull request overview
This PR addresses MSRC-reported security/reliability gaps by tightening Kubernetes network exposure, hardening backend validation and proxying behavior, and improving tool definition caching behavior in the .NET services.
Changes:
- Added Kubernetes
NetworkPolicyresources (cloud + local) to restrict ingress paths to gateway/tool/adapter pods. - Hardened .NET services: validated container image references, tightened HTTP proxy header/body handling, and replaced custom tool-definition caching with
IMemoryCache. - Updated local Kubernetes manifests to inject Redis credentials via a
Secretand to require Redis AUTH.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/Microsoft.McpGateway.Tools/test/StorageToolDefinitionProviderTests.cs | Updates tests for new IMemoryCache dependency in the provider. |
| dotnet/Microsoft.McpGateway.Tools/src/Services/StorageToolDefinitionProvider.cs | Switches to IMemoryCache + locking for tool resource caching. |
| dotnet/Microsoft.McpGateway.Tools/src/Program.cs | Registers AddMemoryCache() for the tools service DI container. |
| dotnet/Microsoft.McpGateway.Service/src/HttpProxy.cs | Adjusts request body forwarding logic and restricts proxied response headers. |
| dotnet/Microsoft.McpGateway.Management/src/Deployment/KubernetesAdapterDeploymentManager.cs | Adds regex-based validation for image name/tag before creating/updating K8s workloads. |
| dotnet/Microsoft.McpGateway.Management/src/Contracts/AdapterData.cs | Adds regex validation attributes for image name/tag in the API contract. |
| deployment/k8s/local-deployment.yml | Adds Redis Secret, enables Redis AUTH, and introduces local NetworkPolicy rules. |
| deployment/k8s/cloud-deployment-template.yml | Adds namespace default-deny ingress + explicit allow policies for gateway/adapter access. |
Comments suppressed due to low confidence (1)
dotnet/Microsoft.McpGateway.Tools/test/StorageToolDefinitionProviderTests.cs:556
- A new required constructor dependency (
IMemoryCache) was introduced, but there’s no constructor test asserting it throws whencacheis null (similar to the other null-guard tests). Add a test to cover theArgumentNullExceptionpath for thecacheparameter.
[TestMethod]
public void Constructor_ShouldThrowArgumentNullException_WhenToolResourceStoreIsNull()
{
// Act
var act = () => new StorageToolDefinitionProvider(
null!,
_permissionProviderMock.Object,
_httpContextAccessorMock.Object,
new MemoryCache(new MemoryCacheOptions()),
_loggerMock.Object);
// Assert
act.Should().Throw<ArgumentNullException>();
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dsp05
approved these changes
Apr 16, 2026
- Harden ForwardedIdentityHeaders and SimplePermissionProvider authorization - Add security headers to Kubernetes deployment templates - Add input validation in HttpProxy - Add security configuration in Tools Program.cs - Update README with security guidance
songpeidu
approved these changes
Apr 16, 2026
askwenhan
approved these changes
Apr 16, 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.
Fix MSRC security vulnerabilities, internal ticket for more info.
This pull request introduces several security and reliability improvements across the Kubernetes deployment configuration, the .NET backend, and the tool definition provider. The most significant updates include stricter network policies for Kubernetes deployments, secure handling of Redis credentials, validation of container image references, improved HTTP proxy header handling, and enhanced caching for tool definitions.
Kubernetes Deployment and Security Enhancements:
Added multiple
NetworkPolicyresources to bothcloud-deployment-template.ymlandlocal-deployment.ymlto restrict ingress traffic:adapternamespace.mcpgateway,toolgateway) to access certain pods and Redis.mcpgatewayservice. [1] [2]Introduced a
Secretfor Redis credentials and updated Redis,mcpgateway, andtoolgatewaydeployments to use this secret for secure password injection and connection string configuration. [1] [2] [3] [4]Backend Validation and Security:
AdapterData) and deployment manager using regular expressions to prevent path traversal and invalid image references. [1] [2] [3] [4] [5] [6]HTTP Proxy Improvements:
Tool Definition Provider Caching:
StorageToolDefinitionProviderwithIMemoryCachefor thread-safe, efficient caching, and updated related tests and dependency injection. [1] [2] [3] [4] [5] [6]