Fix MSRC security vulnerabilities (#61)
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 `NetworkPolicy` resources to both `cloud-deployment-template.yml` and `local-deployment.yml` to restrict ingress traffic: - Default deny-all policy for the `adapter` namespace. - Only allow specific services (`mcpgateway`, `toolgateway`) to access certain pods and Redis. - Allow external traffic only to the `mcpgateway` service. [[1]](diffhunk://#diff-1a6715f71185cb188fc84f2c61ef6bf2127542be2f5ba9ffcb648ab5505d2f05R176-R227) [[2]](diffhunk://#diff-a6a5040caa97dd922cfefc658d778541ef2d2a8611dd517961078e4a0b0d6d76R209-R278) * Introduced a `Secret` for Redis credentials and updated Redis, `mcpgateway`, and `toolgateway` deployments to use this secret for secure password injection and connection string configuration. [[1]](diffhunk://#diff-a6a5040caa97dd922cfefc658d778541ef2d2a8611dd517961078e4a0b0d6d76R6-R14) [[2]](diffhunk://#diff-a6a5040caa97dd922cfefc658d778541ef2d2a8611dd517961078e4a0b0d6d76R34-R46) [[3]](diffhunk://#diff-a6a5040caa97dd922cfefc658d778541ef2d2a8611dd517961078e4a0b0d6d76R124-R136) [[4]](diffhunk://#diff-a6a5040caa97dd922cfefc658d778541ef2d2a8611dd517961078e4a0b0d6d76R184-R190) **Backend Validation and Security:** * Enforced validation of container image names and versions in both the API contract (`AdapterData`) and deployment manager using regular expressions to prevent path traversal and invalid image references. [[1]](diffhunk://#diff-d8b20d2faaafd46ea28c99f09c70531da8281111dc15ea03faa5cfe1708a693dR26-R33) [[2]](diffhunk://#diff-d53d903751767e9162063d89dd7aea8e0070b40cbf620093dfec731ef04abbd6R6) [[3]](diffhunk://#diff-d53d903751767e9162063d89dd7aea8e0070b40cbf620093dfec731ef04abbd6R18-R19) [[4]](diffhunk://#diff-d53d903751767e9162063d89dd7aea8e0070b40cbf620093dfec731ef04abbd6R35-R36) [[5]](diffhunk://#diff-d53d903751767e9162063d89dd7aea8e0070b40cbf620093dfec731ef04abbd6R153-R154) [[6]](diffhunk://#diff-d53d903751767e9162063d89dd7aea8e0070b40cbf620093dfec731ef04abbd6R238-R249) **HTTP Proxy Improvements:** * Improved the HTTP proxy logic to: - Only forward a safe subset of response headers to clients. - Exclude identity headers from being proxied, ensuring they are only set from the authenticated principal. - Correctly detect when to forward the request body. [[1]](diffhunk://#diff-8429a1276335d5b3df10e4ec2b5ab5ecc3fbe365a28765a9a74eb4fe9d8821fbR15-R22) [[2]](diffhunk://#diff-8429a1276335d5b3df10e4ec2b5ab5ecc3fbe365a28765a9a74eb4fe9d8821fbR31-L39) [[3]](diffhunk://#diff-8429a1276335d5b3df10e4ec2b5ab5ecc3fbe365a28765a9a74eb4fe9d8821fbR59-R92) **Tool Definition Provider Caching:** * Replaced the custom in-memory caching logic in `StorageToolDefinitionProvider` with `IMemoryCache` for thread-safe, efficient caching, and updated related tests and dependency injection. [[1]](diffhunk://#diff-bde579677550ab344d0d5628d56a6261f7a9eb35aefae9f4d188c1b4d52f6bc9R67) [[2]](diffhunk://#diff-98c69ee6f6a92647f6d3d08b140cdf93c13157e990c969727d8787d265324536R4) [[3]](diffhunk://#diff-98c69ee6f6a92647f6d3d08b140cdf93c13157e990c969727d8787d265324536R20-R27) [[4]](diffhunk://#diff-98c69ee6f6a92647f6d3d08b140cdf93c13157e990c969727d8787d265324536R36-R88) [[5]](diffhunk://#diff-ea5fa469f9dcb5f947f9f13488043c2ffabc5bb04ad2eaf8068176b03550bc4bR8) [[6]](diffhunk://#diff-ea5fa469f9dcb5f947f9f13488043c2ffabc5bb04ad2eaf8068176b03550bc4bR48) --------- Co-authored-by: Lili Xu <lilx@microsoft.com>
L
Lili Xu committed
4b77fff43bd6f68e2b0809c42d5f2c2244944aaa
Parent: 1ff882b
Committed by GitHub <noreply@github.com>
on 4/16/2026, 5:49:59 PM