feat(typescript): add MCP protocol governance with full OWASP coverage#791
feat(typescript): add MCP protocol governance with full OWASP coverage#791jackbatzner wants to merge 1 commit intomicrosoft:mainfrom
Conversation
|
Welcome to the Agent Governance Toolkit! Thanks for your first pull request. |
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Code Review for feat(typescript): add MCP protocol governance with full OWASP coverage
🔴 CRITICAL: Security Issues
-
Missing Replay Protection in
McpMessageSigner:- Issue: The
McpMessageSignerimplementation does not include a mechanism to track and prevent replay attacks. While HMAC-SHA256 is used for signing, without nonce tracking or timestamp validation, an attacker could replay a previously valid signed message. - Recommendation: Implement a nonce or timestamp validation mechanism to ensure that each message is unique and cannot be replayed. Store used nonces in a database or in-memory store with a TTL to prevent reuse.
- Issue: The
-
Potential Credential Leakage in Audit Logs:
- Issue: The
auditSink.recordmethod inMcpGatewayincludesparamsin the audit log, even though it is redacted. However, there is no guarantee that the redaction process will catch all sensitive data, especially if custom patterns are not comprehensive. - Recommendation: Ensure that the
CredentialRedactoris thoroughly tested with a wide range of sensitive data patterns. Additionally, consider hashing or encrypting sensitive fields before logging them, even if they are redacted.
- Issue: The
-
Blocked Patterns and Dangerous Patterns:
- Issue: The
checkSanitizationmethod inMcpGatewayuses hardcoded patterns (BUILTIN_DANGEROUS_PATTERNS) and user-suppliedblockedPatterns. However, there is no validation or sanitization of these patterns, which could lead to unexpected behavior or even ReDoS (Regular Expression Denial of Service) vulnerabilities. - Recommendation: Validate and sanitize all user-supplied patterns to ensure they are safe and efficient. Consider using libraries like
safe-regexto detect potentially unsafe regular expressions.
- Issue: The
-
Fail-Closed Behavior in
McpGateway:- Issue: While the
McpGatewayis designed to fail closed on errors, thefinalizemethod catches errors and returns a generic "Internal error - access denied (fail-closed)" message. This could potentially mask critical issues in the system. - Recommendation: Log detailed error information (excluding sensitive data) to help diagnose the root cause of failures. Consider adding a mechanism to alert administrators when such errors occur frequently.
- Issue: While the
🟡 WARNING: Potential Breaking Changes
-
Public API Stability:
- Issue: The PR introduces a new package (
@microsoft/agentmesh-mcp-governance) marked as "Public Preview" with a disclaimer that APIs may change before GA. This could lead to breaking changes for early adopters. - Recommendation: Clearly document the expected timeline for API stabilization and provide guidance for users on how to handle potential breaking changes in future releases.
- Issue: The PR introduces a new package (
-
Dual-Package Architecture:
- Issue: The introduction of a dual-package architecture (
@microsoft/agentmesh-sdkand@microsoft/agentmesh-mcp-governance) may confuse users about which package to use. - Recommendation: Provide clear documentation and decision trees to help users choose the appropriate package for their use case.
- Issue: The introduction of a dual-package architecture (
💡 Suggestions for Improvement
-
Enhanced OWASP Coverage:
- Observation: The PR claims compliance with 11 out of 12 sections of the OWASP MCP Security Cheat Sheet. However, §11 (Consent UI) is marked as "N/A" because it is a server-side SDK.
- Suggestion: Consider adding guidance or APIs to facilitate the implementation of consent UI in client applications that use the SDK. This would provide a more comprehensive solution.
-
Test Coverage:
- Observation: While the PR includes Jest configuration and mentions tests, the actual test files are not included in the diff.
- Suggestion: Ensure that all critical components, especially security-related ones like
McpMessageSigner,McpGateway, andCredentialRedactor, have comprehensive unit and integration tests. Include tests for edge cases, such as malformed inputs and high-concurrency scenarios.
-
Concurrency and Thread Safety:
- Observation: The
McpGatewayclass uses an in-memory rate limiter (McpSlidingRateLimiter) by default. This could lead to race conditions in multi-threaded or distributed environments. - Suggestion: Clearly document that the in-memory rate limiter is not thread-safe and recommend using a distributed store (e.g., Redis) for production deployments.
- Observation: The
-
Type Safety:
- Observation: The TypeScript types are generally well-defined, but there are some areas where stricter typing could improve robustness. For example, the
paramsargument inevaluateToolCallis typed asRecord<string, unknown>, which is very generic. - Suggestion: Use stricter types or schemas (e.g., with
zodorio-ts) to validate the structure ofparamsand other inputs.
- Observation: The TypeScript types are generally well-defined, but there are some areas where stricter typing could improve robustness. For example, the
-
Documentation:
- Observation: The README for
@microsoft/agentmesh-mcp-governanceprovides a good overview but lacks detailed examples for advanced use cases, such as integrating with custom storage backends or implementingapprovalHandler. - Suggestion: Expand the documentation to include more detailed examples and best practices for using the package in production environments.
- Observation: The README for
-
Performance Considerations:
- Observation: The
CredentialRedactorprocesses strings and objects recursively, which could lead to performance issues with deeply nested structures. - Suggestion: Add a maximum recursion depth to prevent potential stack overflows or performance degradation when processing deeply nested objects.
- Observation: The
-
Error Handling:
- Observation: The
McpGatewayclass has a generic error handling mechanism that catches all errors and returns a fail-closed decision. - Suggestion: Differentiate between recoverable and non-recoverable errors. For example, if the rate limiter fails, it might be better to allow the request rather than deny it, depending on the use case.
- Observation: The
-
Logging:
- Observation: The
McpGatewayclass does not include detailed logging for debugging purposes. - Suggestion: Add structured logging for key events, such as policy evaluations, rate limit checks, and audit log writes. Ensure that sensitive data is excluded from logs.
- Observation: The
Summary of Recommendations
- Critical: Address replay protection in
McpMessageSigner, validate user-supplied patterns, and ensure audit logs are secure. - Warning: Clearly communicate the potential for breaking changes in the new package and provide guidance for users.
- Suggestions: Improve test coverage, documentation, type safety, and logging. Address potential performance and concurrency issues.
Let me know if you need further clarification or assistance!
🤖 AI Agent: security-scanner — Security Review of PR: `feat(typescript): add MCP protocol governance with full OWASP coverage`Security Review of PR:
|
| Category | Severity | Description |
|---|---|---|
| Prompt Injection Defense | 🔴 CRITICAL | Insufficient sanitization for nested/obfuscated payloads. |
| Policy Engine Circumvention | 🟠 HIGH | Optional policyEvaluator allows bypassing policy checks. |
| Trust Chain Weaknesses | 🟠 HIGH | Lack of SPIFFE/SVID validation and certificate pinning. |
| Credential Exposure | 🟡 MEDIUM | Limited redaction patterns may expose sensitive data in logs. |
| Sandbox Escape | 🔴 CRITICAL | Incomplete shell injection detection allows sandbox escape. |
| Deserialization Attacks | 🟠 HIGH | Lack of schema validation for deserialized objects. |
| Race Conditions | 🟡 MEDIUM | Potential race condition in nonce replay cache. |
| Supply Chain Risks | 🟡 MEDIUM | No dependency pinning or verification against supply chain attacks. |
Recommendations
-
Prompt Injection Defense:
- Use a robust input sanitization library.
- Expand dangerous pattern detection to include nested and obfuscated payloads.
-
Policy Engine:
- Make
policyEvaluatormandatory or provide a default fail-closed implementation.
- Make
-
Trust Chain:
- Integrate SPIFFE/SVID validation and certificate pinning.
-
Credential Redaction:
- Allow dynamic pattern definitions and implement a fallback redaction mechanism.
-
Sandbox Escape:
- Use a comprehensive shell injection detection library and enforce strict input validation.
-
Deserialization:
- Enforce schema validation and limit payload size.
-
Race Conditions:
- Use a thread-safe cache for nonce replay protection.
-
Supply Chain:
- Pin dependencies, scan for vulnerabilities, and implement an allowlist.
Final Assessment
This PR introduces critical security features but also contains several high-risk vulnerabilities that must be addressed before merging. Immediate attention should be given to prompt injection defense, sandbox escape prevention, and policy engine enforcement.
| } | ||
| } | ||
| for (const pattern of BUILTIN_DANGEROUS_PATTERNS) { | ||
| if (pattern.test(serialized)) { |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
There was a problem hiding this comment.
Resolved. All flagged regex patterns have been replaced with non-regex string scanning in subsequent commits.
|
|
||
| export function hasMatch(pattern: RegExp, value: string): boolean { | ||
| pattern.lastIndex = 0; | ||
| return pattern.test(value); |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
There was a problem hiding this comment.
Resolved. All flagged regex patterns have been replaced with non-regex string scanning in subsequent commits.
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Review Summary
This pull request introduces a new TypeScript package, @microsoft/agentmesh-mcp-governance, which provides standalone MCP (Model Context Protocol) governance primitives. The implementation aims to address 11 out of 12 sections of the OWASP MCP Security Cheat Sheet, with a focus on security, modularity, and extensibility. The PR also includes updates to CI/CD workflows, documentation, and configuration files.
The implementation appears well-structured and adheres to modern TypeScript and security best practices. However, there are some areas that require attention to ensure correctness, security, and maintainability.
🔴 CRITICAL
-
Fail-Closed Behavior in
McpGateway- The
McpGatewayclass has a fail-closed mechanism in theevaluateToolCallmethod, which is a good practice. However, thefinalizemethod also has a try-catch block that defaults to a fail-closed decision in case of an error. While this is generally a good approach, it is critical to ensure that theauditSink.recordandmetrics.recordDecisioncalls cannot throw exceptions that would inadvertently trigger the fail-closed behavior. If these methods throw exceptions, it could result in legitimate requests being denied. Consider wrapping these calls in their own try-catch blocks to ensure that the fail-closed mechanism is only triggered by critical errors.
- The
-
Credential Redaction
- The
CredentialRedactorclass uses a default set of patterns for sensitive data redaction. While this is a good starting point, the patterns may not cover all possible sensitive data formats. For example, there is no pattern for credit card CVV codes or other sensitive information. Additionally, theSENSITIVE_KEY_PATTERNregex might produce false positives or false negatives. Consider allowing users to provide their own sensitive key patterns or extending the default patterns to cover more cases.
- The
-
Replay Protection in
McpMessageSigner- The PR mentions HMAC-SHA256 message signing with timestamp and nonce replay protection, but the implementation of
McpMessageSigneris not included in the diff. Ensure that the replay protection mechanism is robust and that nonces are stored securely and checked for uniqueness. If this is not implemented correctly, it could lead to replay attacks. Please confirm that this is handled securely.
- The PR mentions HMAC-SHA256 message signing with timestamp and nonce replay protection, but the implementation of
-
Blocked Patterns in
McpGateway- The
checkSanitizationmethod inMcpGatewayuses both user-provided and built-in patterns to detect dangerous or blocked patterns. However, the built-in patterns (BUILTIN_DANGEROUS_PATTERNS) include some generic patterns like\b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b(credit card numbers) and;\s*(?:rm|del|format|mkfs)\b. These patterns could produce false positives, especially in non-English contexts or when processing legitimate data. Consider providing a mechanism to customize or disable built-in patterns to reduce the risk of false positives.
- The
🟡 WARNING
-
Potential Breaking Changes
- The introduction of the new package
@microsoft/agentmesh-mcp-governanceand its integration into the existing@microsoft/agentmesh-sdkpackage may introduce breaking changes for users of the SDK. While the PR mentions that the new package is in "Public Preview" and APIs may change before GA, it is important to clearly communicate this to users in the documentation and release notes. Consider adding a prominent warning in the README and changelog.
- The introduction of the new package
-
Backward Compatibility
- The new package introduces several new APIs and changes to the existing SDK. Ensure that these changes are backward-compatible with the current version of the SDK. If any breaking changes are introduced, they should be documented in the changelog, and a major version bump should be considered.
💡 SUGGESTIONS
-
Testing Coverage
- While the PR mentions that tests have been added, the diff does not include the test files. Ensure that the following areas are thoroughly tested:
- Fail-closed behavior in
McpGatewayandCredentialRedactor. - Edge cases for
CredentialRedactor, including nested objects, circular references, and edge cases for regex patterns. - Replay protection in
McpMessageSigner. - Rate limiting behavior in
McpSlidingRateLimiter, including edge cases like burst traffic and long-term usage. - Integration tests for
McpGatewaywith all security primitives enabled.
- Fail-closed behavior in
- While the PR mentions that tests have been added, the diff does not include the test files. Ensure that the following areas are thoroughly tested:
-
Documentation
- The README for
@microsoft/agentmesh-mcp-governanceis clear and well-written. However, consider adding more examples for advanced use cases, such as customizing patterns inCredentialRedactoror implementing a customapprovalHandler.
- The README for
-
Type Safety
- Ensure that all exported types and interfaces are well-documented and include examples of usage. This will help developers understand how to use the new APIs correctly.
-
Thread Safety
- The PR does not provide details about thread safety, especially for shared resources like the
rateLimiterandauditSink. Ensure that these components are thread-safe and can handle concurrent requests without race conditions.
- The PR does not provide details about thread safety, especially for shared resources like the
-
Performance
- The
CredentialRedactorandMcpGatewayclasses perform regex operations on potentially large objects. Consider benchmarking these operations to ensure they do not introduce significant performance overhead, especially in high-throughput scenarios.
- The
-
Error Handling
- While the fail-closed behavior is a good practice, consider adding more granular error messages to help developers debug issues. For example, if the
auditSink.recordmethod fails, the error message should indicate that the failure occurred during audit logging.
- While the fail-closed behavior is a good practice, consider adding more granular error messages to help developers debug issues. For example, if the
Summary of Actionable Feedback
🔴 CRITICAL
- Ensure that the fail-closed behavior in
McpGatewaydoes not inadvertently deny legitimate requests due to non-critical errors. - Expand the default sensitive data patterns in
CredentialRedactorand allow users to customize them. - Confirm that the replay protection in
McpMessageSigneris robust and secure. - Provide a mechanism to customize or disable built-in dangerous patterns in
McpGateway.
🟡 WARNING
- Clearly document potential breaking changes and consider a major version bump if necessary.
- Verify backward compatibility with the existing SDK.
💡 SUGGESTIONS
- Ensure comprehensive test coverage for all new features and edge cases.
- Enhance documentation with advanced usage examples.
- Verify and document thread safety for shared resources.
- Benchmark performance of regex-heavy operations in
CredentialRedactorandMcpGateway. - Improve error handling to provide more granular and actionable error messages.
Let me know if you need further clarification or additional feedback!
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Review Summary
This pull request introduces a new TypeScript package, @microsoft/agentmesh-mcp-governance, which provides standalone MCP governance primitives for the AgentMesh platform. The implementation is robust and aligns with the OWASP MCP Security Cheat Sheet, covering 11 out of 12 sections. The package includes features like centralized policy enforcement, session authentication, message signing, rate limiting, and credential redaction. The code is well-structured, with a focus on security, modularity, and testability.
However, there are some areas that require attention to ensure the robustness, security, and maintainability of the codebase. Below are the detailed findings and recommendations:
🔴 CRITICAL
-
Fail-Closed Behavior in
McpGateway- The
evaluateToolCallmethod inMcpGatewayhas a catch-allcatchblock that defaults to a fail-closed decision. While this is a good security practice, the catch block does not log the error or provide any mechanism for debugging. This could make it difficult to identify and fix issues during runtime. - Recommendation: Log the error details in the
catchblock using a secure logging mechanism that ensures sensitive data is not exposed.
} catch (error) { console.error('Error in evaluateToolCall:', error); // Replace with a secure logging mechanism return { allowed: false, reason: 'Internal error - access denied (fail-closed)', redactedParams: this.redactor.redact(params).redacted as Record<string, unknown>, findings: [], }; }
- The
-
Credential Redaction
- The
CredentialRedactorclass uses a default set of patterns for detecting sensitive information. However, there is no mechanism to validate the custom patterns provided in theCredentialRedactorConfig. Malformed or overly broad patterns could lead to unintended behavior, such as excessive redaction or missed sensitive data. - Recommendation: Add validation for custom patterns to ensure they are valid regular expressions and do not conflict with built-in patterns.
- The
-
Replay Protection in
McpMessageSigner- While the
McpMessageSigneris mentioned as providing HMAC-SHA256 payload signing with timestamp and nonce replay protection, the actual implementation of replay protection is not included in the provided diff. - Recommendation: Ensure that the
McpMessageSignerimplementation includes robust replay protection mechanisms, such as maintaining a cache of used nonces and timestamps to prevent replay attacks.
- While the
-
Blocked Patterns in
McpGateway- The
checkSanitizationmethod inMcpGatewayuses a combination of string matching and regular expressions to identify blocked patterns. However, there is no validation to ensure that the patterns provided inconfig.blockedPatternsare safe and do not introduce performance issues or false positives. - Recommendation: Validate the
blockedPatternsduring initialization to ensure they are well-formed and do not contain overly broad or inefficient patterns.
- The
🟡 WARNING
- Potential Breaking Changes
- The introduction of a new package,
@microsoft/agentmesh-mcp-governance, and its integration into the existing@microsoft/agentmesh-sdkpackage could potentially introduce breaking changes for existing users of the SDK. While the PR mentions that this is a non-breaking change, the dual-package architecture might require users to update their imports or configurations. - Recommendation: Clearly document the migration path for existing users and provide examples of how to update their code to use the new package.
- The introduction of a new package,
💡 SUGGESTIONS
-
Test Coverage
- While the PR mentions that tests have been added, there is no information about the extent of test coverage for the new package.
- Recommendation: Ensure that all critical paths, especially security-related features like rate limiting, message signing, and credential redaction, are thoroughly tested. Include tests for edge cases, such as malformed input and unexpected errors.
-
Documentation
- The README for the new package provides a good overview of its features and usage. However, it would be helpful to include more detailed examples, especially for advanced use cases like integrating with custom storage backends or implementing custom approval handlers.
- Recommendation: Expand the documentation to include detailed examples and best practices for using the package in production environments.
-
Type Safety
- The codebase appears to use TypeScript effectively, but there are some areas where type safety could be improved. For example, the
redactNodemethod inCredentialRedactorusesunknownas the type for thevalueparameter, which could lead to runtime errors if the type is not properly checked. - Recommendation: Use more specific types or type guards to ensure type safety and reduce the risk of runtime errors.
- The codebase appears to use TypeScript effectively, but there are some areas where type safety could be improved. For example, the
-
Performance Optimization
- The
redactStringmethod inCredentialRedactorusesmatchAllto find all matches for a pattern and then iterates over them to apply redactions. This could be optimized to reduce the number of iterations and improve performance. - Recommendation: Consider using a single pass through the string to apply all patterns, or explore more efficient string processing techniques.
- The
-
Concurrency and Thread Safety
- The
McpSlidingRateLimiterand other stateful components likeInMemoryMCPAuditSinkmay not be thread-safe, especially in multi-threaded or distributed environments. - Recommendation: Clearly document the thread-safety guarantees of these components and provide guidance on how to use them safely in multi-threaded or distributed systems.
- The
-
Backward Compatibility
- The PR mentions that APIs may change before GA. This could impact users who adopt the package during the public preview phase.
- Recommendation: Use semantic versioning to clearly indicate breaking changes and provide a migration guide for each major version update.
Summary of Actions
- 🔴 CRITICAL: Add error logging in
McpGatewayfail-closed behavior. - 🔴 CRITICAL: Validate custom patterns in
CredentialRedactorConfig. - 🔴 CRITICAL: Ensure robust replay protection in
McpMessageSigner. - 🔴 CRITICAL: Validate
blockedPatternsinMcpGatewayConfig. - 🟡 WARNING: Document potential breaking changes and provide a migration guide.
- 💡 SUGGESTION: Expand test coverage for critical paths and edge cases.
- 💡 SUGGESTION: Improve documentation with advanced use case examples.
- 💡 SUGGESTION: Enhance type safety in methods like
redactNode. - 💡 SUGGESTION: Optimize
redactStringfor better performance. - 💡 SUGGESTION: Document thread-safety guarantees for stateful components.
Let me know if you need further clarification or assistance!
imran-siddique
left a comment
There was a problem hiding this comment.
The TypeScript MCP governance code looks good, but this PR modifies ci.yml and publish.yml (same issue as #775). Please remove the .github/ changes and submit the code portion only — we'll handle CI integration for new language targets.
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
This pull request introduces a new TypeScript package, @microsoft/agentmesh-mcp-governance, which implements comprehensive MCP (Model Context Protocol) governance primitives. The implementation claims to cover 11 out of 12 sections of the OWASP MCP Security Cheat Sheet, with a focus on security, compliance, and extensibility.
🔴 CRITICAL
1. Potential Denial of Service via Regex DoS
- File:
credential-redactor.ts,gateway.ts - Issue: The use of regular expressions in
CredentialRedactorandMcpGatewayintroduces the risk of Regular Expression Denial of Service (ReDoS) attacks. Specifically:CredentialRedactoruses multiple regex patterns, including user-supplied custom patterns, without validating their complexity.McpGatewayuses regex patterns for blocked and dangerous pattern detection, which could be exploited with crafted inputs to cause excessive backtracking.
- Recommendation:
- Use safe regex libraries like safe-regex to validate regex patterns before use.
- Implement a timeout mechanism for regex execution to prevent long-running operations from blocking the event loop.
2. Credential Leakage in Audit Logs
- File:
gateway.ts - Issue: While the
CredentialRedactoris used to redact sensitive information, there is no guarantee that all sensitive data is redacted before being logged in the audit sink. This could lead to credential leakage in logs. - Recommendation:
- Add a validation step to ensure that all audit log entries are free from sensitive information before they are logged.
- Consider adding a test case to verify that no sensitive information is logged.
3. Insufficient Replay Protection
- File: Not explicitly shown in the diff, but relevant to
MCPSessionAuthenticatorandMCPMessageSigner. - Issue: While
MCPMessageSignerimplements HMAC-SHA256 for message signing, there is no explicit mention of nonce storage or validation to prevent replay attacks. - Recommendation:
- Ensure that nonces are stored in a secure, tamper-proof manner (e.g., in a database or in-memory store with expiration).
- Add tests to verify that replayed requests with the same nonce are rejected.
🟡 WARNING
1. Potential Breaking Changes
- Issue: The introduction of a new package,
@microsoft/agentmesh-mcp-governance, and its integration into the existing@microsoft/agentmesh-sdkcould potentially introduce breaking changes for users of the SDK. While the PR mentions that this is a non-breaking change, the dual-package architecture might lead to confusion or unexpected behavior for existing users. - Recommendation:
- Clearly document the migration path for existing users.
- Ensure backward compatibility by maintaining the existing API surface in
@microsoft/agentmesh-sdkwhile introducing the new functionality.
💡 SUGGESTIONS
1. Enhanced Test Coverage
- Observation: While the PR mentions that tests have been added, the diff does not include any test files.
- Recommendation:
- Ensure that all critical functionalities, especially security-related ones, are covered by unit and integration tests.
- Add tests for edge cases, such as malformed inputs, large payloads, and concurrent requests.
2. Thread Safety
- Observation: The
McpGatewayandCredentialRedactorclasses use shared resources likeWeakMapandRegexScanBudget. There is no explicit mention of thread safety mechanisms. - Recommendation:
- Ensure that shared resources are accessed in a thread-safe manner, especially if the library is intended to be used in multi-threaded environments.
- Consider using thread-safe data structures or synchronization primitives if necessary.
3. Input Validation
- Observation: The
evaluateToolCallmethod inMcpGatewayacceptsparamsas aRecord<string, unknown>without any validation. - Recommendation:
- Use a schema validation library (e.g.,
zodoryup) to validate the structure and types ofparams. - This will help prevent unexpected behavior due to malformed or malicious inputs.
- Use a schema validation library (e.g.,
4. Documentation Improvements
- Observation: The README provides a good overview of the package, but it lacks detailed examples for advanced use cases, such as integrating with custom storage backends or implementing custom approval handlers.
- Recommendation:
- Add detailed examples for advanced use cases to the documentation.
- Include a section on best practices for secure deployment, such as using durable storage for nonces and rate limits.
5. Error Handling
- Observation: The
evaluateToolCallmethod has a catch-all error handler that returns a generic error message. - Recommendation:
- Log the actual error details (excluding sensitive information) for debugging purposes.
- Consider categorizing errors to provide more specific feedback to developers.
6. Performance Considerations
- Observation: The use of
stableStringifyincheckSanitizationcould be a performance bottleneck for large objects. - Recommendation:
- Evaluate the performance impact of
stableStringifyon large payloads. - Consider alternative approaches, such as streaming serialization or partial serialization, to improve performance.
- Evaluate the performance impact of
7. Type Safety
- Observation: The use of
unknowninredactandredactNodemethods inCredentialRedactorcould lead to runtime errors if the input is not properly validated. - Recommendation:
- Use stricter TypeScript types or runtime type checks to ensure that the input conforms to the expected structure.
8. Backward Compatibility
- Observation: The PR introduces a new package and updates the SDK. While it is stated that this is a non-breaking change, there is no explicit mention of how existing users will be impacted.
- Recommendation:
- Perform a thorough analysis of the impact on existing users.
- Clearly communicate any changes in the release notes or documentation.
Summary
This PR introduces a robust and well-architected MCP governance package with a strong focus on security and extensibility. However, there are critical issues related to regex DoS, potential credential leakage, and replay protection that need to be addressed before merging. Additionally, there are some potential breaking changes and areas for improvement in testing, documentation, and type safety.
Action Items:
- Address the critical issues related to regex DoS, credential leakage, and replay protection.
- Add comprehensive test coverage for all new functionalities.
- Improve documentation with advanced usage examples and best practices.
- Ensure backward compatibility and communicate changes clearly.
Let me know if you need further clarification or assistance!
Addressing Review Feedback@imran-siddique — thanks for the review! Here's what we've done: ✅ Imran's Review: Remove .github/ changes
Fixed: All ✅ Bot Review Fixes (Proactive)We proactively addressed the same patterns flagged on #774 and #775:
Validation
|
5173bbc to
93035f2
Compare
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review for feat(typescript): add MCP protocol governance with full OWASP coverage
Summary
This pull request introduces a new TypeScript SDK for the AgentMesh project, which includes a standalone @microsoft/agentmesh-mcp-governance package. The implementation focuses on providing comprehensive security governance for the Model Context Protocol (MCP) and addresses 11 out of 12 sections of the OWASP MCP Security Cheat Sheet. The PR includes new security primitives, enterprise-grade patterns, and a dual-package architecture.
Review Feedback
🔴 CRITICAL
-
Fail-Closed Mechanism in
MCPGateway:- The
evaluateToolCallmethod inMCPGatewayimplements a fail-closed mechanism by catching all errors and denying access. While this is a good practice, the catch block does not log the error details. This could make debugging and incident response more difficult.- Recommendation: Log the error details in the catch block to aid in debugging and auditing. For example:
} catch (error) { console.error('MCPGateway evaluation error:', error); return this.finalize( agentId, toolName, params, { allowed: false, reason: 'Internal gateway error - access denied (fail closed)', auditParams: this.redactor.redact(params).redacted as Record<string, unknown>, findings: [], }, ); }
- Recommendation: Log the error details in the catch block to aid in debugging and auditing. For example:
- The
-
Credential Redaction:
- The
CredentialRedactorclass uses a hardcoded list of patterns for sensitive data detection. While this is a good starting point, it may not cover all possible sensitive data patterns, especially for custom or less common use cases.- Recommendation: Provide a mechanism for users to dynamically update or extend the list of sensitive data patterns at runtime. This will make the redactor more adaptable to different environments.
- The
-
Policy Evaluation Logic:
- The
policyEvaluatorinMCPGatewayis invoked but not validated for its return type or behavior. If thepolicyEvaluatorreturns unexpected results, it could lead to incorrect decisions.- Recommendation: Validate the output of
policyEvaluatorto ensure it adheres to the expected types and values (e.g.,allow,deny,review). Log a warning or error if the return value is invalid.
- Recommendation: Validate the output of
- The
-
Regex Injection Risk:
- The
toGlobalPatternfunction inCredentialRedactordynamically constructs regular expressions. If user-provided patterns are passed to this function, it could lead to regex injection vulnerabilities.- Recommendation: Sanitize or validate user-provided patterns before constructing the regex. For example, ensure that the pattern does not contain malicious constructs like
(?=...).
- Recommendation: Sanitize or validate user-provided patterns before constructing the regex. For example, ensure that the pattern does not contain malicious constructs like
- The
🟡 WARNING
-
Breaking Changes in Public API:
- The
index.tsfile introduces several new exports, includingCredentialRedactor,MCPResponseScanner,MCPGateway, and others. While these additions are non-breaking, they significantly expand the public API surface.- Recommendation: Clearly document these new exports and their intended use cases in the release notes to ensure users are aware of the changes.
- The
-
TypeScript Version Requirement:
- The
package.jsonspecifies TypeScript version5.7.3. This is a relatively new version and may not be compatible with all existing projects.- Recommendation: Consider testing the SDK with older versions of TypeScript (e.g., 4.x) to ensure broader compatibility or explicitly document the minimum required version.
- The
💡 SUGGESTIONS
-
Audit Logging Enhancements:
- The
MCPGatewayclass maintains an in-memory audit log (auditEntries). While this is useful for debugging, it may lead to memory bloat in long-running processes.- Suggestion: Provide a mechanism to periodically flush the in-memory audit log to a persistent storage or limit its size.
- The
-
Test Coverage:
- While the PR mentions that tests have been added, it is not clear if all edge cases, especially for security-critical components like
CredentialRedactorandMCPGateway, have been covered.- Suggestion: Ensure that test cases cover the following scenarios:
- All sensitive data patterns in
CredentialRedactor. - Fail-closed behavior in
MCPGateway. - Edge cases for
policyEvaluatorandapprovalHandler. - Rate-limiting behavior under high load.
- All sensitive data patterns in
- Suggestion: Ensure that test cases cover the following scenarios:
- While the PR mentions that tests have been added, it is not clear if all edge cases, especially for security-critical components like
-
Documentation:
- The PR mentions that documentation has been updated, but it is unclear if the new features are comprehensively documented.
- Suggestion: Ensure that the documentation includes:
- Detailed examples of how to use the new MCP governance features.
- Guidance on configuring and extending the
CredentialRedactor. - Explanation of the fail-closed mechanism and its implications.
- Suggestion: Ensure that the documentation includes:
- The PR mentions that documentation has been updated, but it is unclear if the new features are comprehensively documented.
-
Thread Safety:
- The
MCPGatewayclass uses an in-memory audit log and rate limiter. In a multi-threaded or distributed environment, this could lead to race conditions or inconsistent state.- Suggestion: Consider using thread-safe data structures or external storage solutions (e.g., Redis) for shared state. Alternatively, document the limitations of using the in-memory implementations in multi-threaded environments.
- The
-
OWASP MCP Security Cheat Sheet Coverage:
- The PR claims coverage for 11 out of 12 sections of the OWASP MCP Security Cheat Sheet. However, it does not specify which section is not covered.
- Suggestion: Clearly document the missing section and provide a rationale for its exclusion. If possible, outline a roadmap for addressing it in the future.
- The PR claims coverage for 11 out of 12 sections of the OWASP MCP Security Cheat Sheet. However, it does not specify which section is not covered.
Conclusion
The PR introduces significant security enhancements and aligns well with OWASP MCP guidelines. However, there are critical areas that need attention, particularly around error handling, regex injection risks, and thread safety. Addressing these issues will improve the robustness and security of the implementation. Additionally, clear documentation and comprehensive test coverage will ensure a smooth adoption of these new features.
|
|
||
| if (this.enableBuiltinSanitization) { | ||
| for (const pattern of BUILTIN_DANGEROUS_PATTERNS) { | ||
| if (pattern.test(serialized)) { |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
There was a problem hiding this comment.
Resolved. Replaced the shell-expansion regex with indexOf-based string detection. See 006a9fa and afaa7a9.
| } | ||
|
|
||
| for (const pattern of HIDDEN_COMMENT_PATTERNS) { | ||
| const match = description.match(pattern); |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
There was a problem hiding this comment.
Resolved. Replaced HTML/markdown comment detection regex with delimiter-based string scanning. See 006a9fa and afaa7a9.
PR Split UpdateThis PR has been updated to contain only the core MCP security primitives and tests for easier review. The original monolithic PR has been split into 3 stacked PRs:
Merge order: #791 → #827 → #825 All previous review feedback has been addressed in this updated branch. |
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
🔴 CRITICAL: Security Issues
-
Replay Protection in
McpMessageSigner- The PR mentions "bounded nonce replay cache and concurrent replay protection," but the implementation of
McpMessageSigneris not visible in this diff. Ensure that:- Nonces are cryptographically secure and unique.
- Nonce expiration and storage are implemented securely to prevent replay attacks.
- The nonce store is thread-safe and resistant to race conditions.
- If
InMemoryMCPNonceStoreis used, it must be clearly documented that it is not suitable for distributed systems or production environments.
- The PR mentions "bounded nonce replay cache and concurrent replay protection," but the implementation of
-
Credential Redaction (
CredentialRedactor)- The
CredentialRedactoruses regular expressions to identify sensitive data. However:- 🔴 Regex DoS Risk: Some of the regex patterns (e.g.,
/(password|passwd|pwd|secret|token|api[_-]?key|connection.?string|accountkey|sharedaccesssignature|sas)/i) could be vulnerable to Regular Expression Denial of Service (ReDoS) attacks. Consider using more efficient regex patterns or limiting the input size before applying regex. - 🔴 Incomplete Coverage: The
BUILTIN_PATTERNSlist might not cover all sensitive data patterns. For example, it lacks patterns for private keys (e.g., RSA private keys) or other sensitive data formats. Consider adding more comprehensive patterns or allowing users to configure additional patterns dynamically.
- 🔴 Regex DoS Risk: Some of the regex patterns (e.g.,
- The
-
Policy Evaluation in
MCPGateway- The
policyEvaluatoris invoked in theevaluatemethod, but its implementation is not visible in this PR. Ensure that:- The policy evaluation logic is deterministic and free from side effects.
- The policy evaluation does not introduce any time-of-check-to-time-of-use (TOCTOU) vulnerabilities.
- The
policyEvaluatoris thread-safe and does not introduce race conditions when accessed concurrently.
- The
-
Sanitization in
MCPGateway- The
checkSanitizationmethod is not visible in this diff. Ensure that:- It uses robust and efficient methods for input sanitization.
- It prevents injection attacks (e.g., SQL injection, command injection) by properly escaping or rejecting malicious input.
- The
blockedPatternsarray andBUILTIN_DANGEROUS_PATTERNSare comprehensive and updated regularly to include new attack vectors.
- The
-
Approval Handler in
MCPGateway- The
approvalHandleris invoked for sensitive tools or when the policy decision is "review." Ensure that:- The approval process is auditable and tamper-proof.
- The
approvalHandlerimplementation is secure and cannot be bypassed. - The approval status is validated and cannot be forged by malicious actors.
- The
-
Audit Logging in
MCPGateway- The
auditParamsare redacted usingCredentialRedactor, but ensure that:- The redaction process is fail-safe and does not accidentally expose sensitive data.
- The audit logs are immutable and stored securely to prevent tampering.
- The
auditSinkimplementation is thread-safe and resistant to race conditions.
- The
🟡 WARNING: Potential Breaking Changes
-
Public API Changes
- The PR introduces several new exports in
src/index.ts, includingCredentialRedactor,MCPGateway, and related types. While these are new additions and do not directly break existing functionality, they expand the public API surface. Ensure that these APIs are well-documented and tested, as they will need to be maintained for backward compatibility in future releases.
- The PR introduces several new exports in
-
Behavioral Changes in
AgentIdentity- The
suspendandrevokemethods now ignore thereasonparameter (_reasonis unused). If any consumers rely on this parameter, this change could lead to unexpected behavior. Consider documenting this change or deprecating the parameter explicitly.
- The
💡 Suggestions for Improvement
-
Thread Safety
- Ensure that all shared resources (e.g.,
InMemoryMCPAuditSink,InMemoryMCPNonceStore,MCPSlidingRateLimiter) are thread-safe, especially in concurrent environments. Consider using locks or atomic operations where necessary.
- Ensure that all shared resources (e.g.,
-
Testing
- Add comprehensive tests for the new functionality, including edge cases and error scenarios. Specifically:
- Test the
CredentialRedactorwith various input sizes and edge cases to ensure it handles all scenarios correctly. - Test the
MCPGatewaywith different configurations (e.g., with and withoutrateLimiter,approvalHandler, andpolicyEvaluator). - Test the
McpMessageSignerfor replay protection and nonce handling.
- Test the
- Add comprehensive tests for the new functionality, including edge cases and error scenarios. Specifically:
-
OWASP MCP Security Cheat Sheet
- The PR claims compliance with 11 out of 12 sections of the OWASP MCP Security Cheat Sheet. Consider adding a checklist or documentation to explicitly map the implementation to the relevant sections of the cheat sheet.
-
Documentation
- Provide detailed documentation for the new classes and methods, including usage examples, configuration options, and potential pitfalls. This will help users understand how to use the new features securely and effectively.
-
Regex Optimization
- Optimize the regex patterns in
CredentialRedactorto prevent potential performance issues. For example:- Replace
/(password|passwd|pwd|secret|token|api[_-]?key|connection.?string|accountkey|sharedaccesssignature|sas)/iwith more specific patterns. - Use non-capturing groups (
(?:...)) where capturing is not needed.
- Replace
- Optimize the regex patterns in
-
Error Handling
- In the
evaluateToolCallmethod ofMCPGateway, the catch block returns a generic error message. Consider logging the actual error (without exposing sensitive information) to aid in debugging.
- In the
-
Rate Limiting
- If
MCPSlidingRateLimiteris used as the default rate limiter, ensure that it is well-documented and tested for edge cases, such as high concurrency or distributed deployments.
- If
-
TypeScript Config
- Ensure that the TypeScript configuration (
tsconfig.json) is set to strict mode ("strict": true) to enforce type safety across the codebase.
- Ensure that the TypeScript configuration (
Summary
This PR introduces significant new functionality to the TypeScript Agent Mesh SDK, including MCP protocol governance and OWASP compliance. While the changes are well-structured and align with the project's goals, there are critical security concerns (e.g., replay protection, regex DoS, and audit log integrity) that need to be addressed before merging. Additionally, there are potential breaking changes in the public API and behavioral changes in existing methods that should be documented and communicated to users. Finally, additional testing, documentation, and optimizations are recommended to ensure the robustness and maintainability of the new features.
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
Summary
This PR introduces MCP (Model Context Protocol) security primitives to the TypeScript Agent Mesh SDK, aiming for comprehensive OWASP MCP Security Cheat Sheet compliance. The changes include new classes and utilities for HMAC signing, session management, input sanitization, credential redaction, and more. The implementation appears to be well-structured and adheres to modern TypeScript practices.
🔴 CRITICAL: Security Issues
1. Replay Protection in McpMessageSigner
- Issue: The PR mentions "bounded nonce replay cache and concurrent replay protection" in
McpMessageSignerandMcpMessageValidator. However, the implementation ofSignerNonceStoreis not included in this PR. Without reviewing the implementation, it is unclear if the nonce replay protection is robust and resistant to attacks. - Impact: If the nonce replay protection is improperly implemented, it could allow attackers to replay signed messages, leading to potential security breaches.
- Action: Ensure that
SignerNonceStoreis implemented securely, with proper eviction policies and resistance to timing attacks. Add unit tests to validate nonce replay protection.
2. Credential Redaction Patterns
- Issue: The
CredentialRedactorincludes built-in patterns for sensitive data detection (e.g., OpenAI keys, GitHub tokens, AWS keys). However, these patterns may not cover all possible sensitive data formats, and the regex patterns may not be exhaustive or robust against edge cases. - Impact: Failure to redact sensitive data could lead to accidental leakage of credentials in logs, violating OWASP A3: Sensitive Data Exposure.
- Action:
- Perform a thorough review of the regex patterns to ensure they cover all common sensitive data formats.
- Consider adding a mechanism for users to test their custom patterns against sample data.
- Add tests for edge cases to ensure the patterns work as expected.
3. Policy Evaluation Fail-Closed Behavior
- Issue: The
MCPGatewayclass has atry-catchblock in theevaluateToolCallmethod that defaults to denying access on any error. While this is a good practice, the catch block swallows the error without logging it. - Impact: Swallowing errors without logging them could make debugging and incident response more difficult.
- Action: Log the error details in the catch block before returning the fail-closed decision.
🟡 WARNING: Potential Breaking Changes
1. Public API Changes
- Issue: The PR introduces new exports in
src/index.ts, includingCredentialRedactor,MCPResponseScanner,MCPGateway, and others. While these are new features, they expand the public API of the package. - Impact: Any changes to these new APIs in the future could result in breaking changes for consumers.
- Action: Clearly document these new APIs and mark them as experimental if they are subject to change.
2. Behavioral Changes in AgentIdentity
- Issue: The
suspendandrevokemethods inAgentIdentitynow ignore thereasonparameter by prefixing it with an underscore (_reason). This is a breaking change for any consumers relying on thereasonparameter. - Impact: Existing consumers may experience runtime errors or unexpected behavior if they rely on the
reasonparameter. - Action: Deprecate the
reasonparameter instead of removing it outright. Log a warning if the parameter is provided but not used, and document the deprecation in the changelog.
💡 Suggestions for Improvement
1. Thread Safety
- Observation: The
CredentialRedactorandMCPGatewayclasses use shared state (e.g.,this.auditEntriesinMCPGatewayandthis.patternsinCredentialRedactor). While the PR mentions thread safety, there is no explicit use of synchronization mechanisms to prevent race conditions. - Suggestion: Use thread-safe data structures or synchronization primitives (e.g.,
MutexorSemaphore) to ensure thread safety in concurrent environments. Add tests to simulate concurrent access and verify correctness.
2. Input Sanitization
- Observation: The
McpInputSanitizeruses regex-based input validation with a time-budget fail-closed behavior. However, the implementation of this class is not included in the PR. - Suggestion: Ensure that the regex patterns are designed to prevent ReDoS (Regular Expression Denial of Service) attacks. Add tests to validate the time-budget behavior under various input scenarios.
3. Rate Limiting
- Observation: The
MCPSlidingRateLimiteris used for rate-limiting agent requests. However, the implementation ofMCPSlidingRateLimiteris not included in this PR. - Suggestion: Review the implementation of
MCPSlidingRateLimiterto ensure it is resistant to timing attacks and other potential vulnerabilities. Add tests to validate its behavior under high concurrency.
4. Error Handling
- Observation: The
MCPGatewayclass has several points where errors could occur (e.g., policy evaluation, rate limiting, approval handling). While theevaluateToolCallmethod has a fail-closed mechanism, other methods do not. - Suggestion: Add error handling and logging to all methods in
MCPGatewayto ensure that unexpected errors do not cause undefined behavior.
5. Backward Compatibility
- Observation: The PR introduces new features and modifies existing methods. While the changes are mostly additive, there are some potential breaking changes (e.g.,
suspendandrevokemethods inAgentIdentity). - Suggestion: Clearly document all changes in the changelog and consider adding deprecation warnings for modified methods.
Tests
Coverage
- The PR includes tests for the new features, but it is unclear if all edge cases are covered.
- Action: Add tests for:
- Edge cases in regex patterns for
CredentialRedactor. - Concurrent access to shared state in
MCPGatewayandCredentialRedactor. - Time-budget behavior in
McpInputSanitizer. - Rate-limiting behavior under high concurrency.
- Edge cases in regex patterns for
Test Path Ignoring
- The
jest.config.jsfile now includestestPathIgnorePatterns: ['/node_modules/', '/dist/']. - Action: Ensure that this change does not inadvertently exclude any relevant test files.
Documentation
API Documentation
- The new classes and methods introduced in this PR need to be documented thoroughly, especially since they are security-related.
- Action: Add detailed JSDoc comments for all new classes, methods, and types. Include examples of usage where applicable.
OWASP Compliance
- The PR claims to cover 11 out of 12 sections of the OWASP MCP Security Cheat Sheet.
- Action: Provide a detailed mapping of the implemented features to the OWASP MCP Security Cheat Sheet sections in the documentation or PR description.
Final Notes
This PR introduces significant security-related functionality to the TypeScript Agent Mesh SDK. While the implementation appears well-structured, there are critical areas that require further review and testing to ensure robustness and security. Addressing the issues and suggestions outlined above will help ensure the reliability and security of the new features.
Priority Actions
- Address the nonce replay protection issue in
McpMessageSigner. - Review and enhance the regex patterns in
CredentialRedactor. - Add error logging in the
evaluateToolCallmethod ofMCPGateway.
Once these issues are resolved, the PR will be in a much stronger position for merging.
Addressing Review Feedback — Updated@imran-siddique — thanks for the review! Here's the current state: ✅ Review 1: Remove .github/ changes
Fixed — All Additional security hardening (from internal review):
|
Addressing AI Reviewer Findings"Replay Protection not visible in diff" — The CodeQL ReDoS — Working on a second round of regex hardening to replace remaining polynomial patterns with non-backtracking alternatives. Fix incoming. "Credential Redaction Incompleteness" — The |
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
🔴 CRITICAL: Security Issues
-
Replay Protection in
McpMessageSigner- The implementation mentions "bounded nonce replay cache and concurrent replay protection," but the PR does not include the actual code for
McpMessageSigner. Ensure that the nonce replay cache is cryptographically secure and resistant to timing attacks. If the nonce cache is implemented in memory, it may be vulnerable to overflow or eviction attacks. - Action: Verify the nonce replay cache implementation and ensure it uses a cryptographically secure mechanism with proper eviction policies.
- The implementation mentions "bounded nonce replay cache and concurrent replay protection," but the PR does not include the actual code for
-
Regex-based Input Validation (
McpInputSanitizer)- The use of regex for input validation (
CredentialRedactor,MCPGateway) is prone to catastrophic backtracking, especially for complex patterns like PEM blocks. This can lead to Denial of Service (DoS) attacks if an attacker crafts malicious input. - Action: Use a library like
re2for regex processing to prevent catastrophic backtracking.
- The use of regex for input validation (
-
Credential Redaction (
CredentialRedactor)- The redaction mechanism relies on regex patterns to identify sensitive data. While this is useful, it may miss edge cases or custom formats. For example, proprietary API keys or tokens not matching the predefined patterns will not be redacted.
- Action: Provide a mechanism for users to dynamically add patterns at runtime or fallback to a heuristic-based approach for unknown sensitive data.
-
Rate Limiting (
MCPSlidingRateLimiter)- The rate limiter implementation is not included in this PR, but its usage in
MCPGatewaysuggests it operates on an agent-level basis. Ensure that the rate limiter is resistant to bypass techniques, such as distributed attacks using multiple agent IDs. - Action: Confirm that the rate limiter has protections against distributed attacks and supports IP-based throttling as a fallback.
- The rate limiter implementation is not included in this PR, but its usage in
-
Sandbox Escape (
MCPGateway)- The
blockedPatternsinMCPGatewayinclude dangerous shell commands (rm,del,mkfs) and command injection patterns ($(), backticks). While this is a good start, it is insufficient for comprehensive sandbox escape prevention. - Action: Implement a more robust sandboxing mechanism, such as restricting execution environments or using syscall filtering (e.g., seccomp).
- The
🟡 WARNING: Potential Breaking Changes
-
Public API Changes (
index.ts)- The addition of multiple new exports (
CredentialRedactor,MCPGateway,MCPSessionAuthenticator, etc.) significantly expands the public API surface. This may lead to compatibility issues for consumers of the SDK who rely on specific imports. - Action: Clearly document these changes and provide migration guides for existing users.
- The addition of multiple new exports (
-
Behavioral Changes in
AgentIdentity- The
_reasonparameter insuspendandrevokemethods is now ignored. This could break existing integrations that rely on thereasonparameter for audit logging or other purposes. - Action: Deprecate the
reasonparameter instead of removing its functionality outright. Log a warning when it is used.
- The
💡 Suggestions for Improvement
-
Thread Safety
- The PR introduces several classes (
CredentialRedactor,MCPGateway,InMemoryMCPAuditSink) that manage shared state (e.g., audit entries, redactions). Ensure these classes are thread-safe, especially in concurrent agent execution scenarios. - Action: Use locks or atomic operations where shared state is modified.
- The PR introduces several classes (
-
OWASP MCP Compliance
- While the PR claims full OWASP MCP Security Cheat Sheet coverage (11/12 sections), the absence of §11 (Consent UI) should be explicitly documented in the SDK's README to avoid confusion.
- Action: Add a section in the documentation clarifying the scope of OWASP compliance.
-
Type Safety
- The
CredentialRedactorandMCPGatewayclasses rely heavily onRecord<string, unknown>for parameters. This weakens type safety and increases the risk of runtime errors. - Action: Use stricter types or Pydantic-style validation for input parameters.
- The
-
Audit Logging
- The audit logging mechanism in
MCPGateway(auditSink) is implemented as an in-memory store. This is not suitable for production environments where persistence and scalability are required. - Action: Provide an interface for pluggable audit sinks (e.g., database, cloud storage).
- The audit logging mechanism in
-
Backward Compatibility
- The removal of
LegacyPolicyDecisionfromaudit.tsmay break integrations relying on this type. Consider marking it as deprecated instead of removing it outright. - Action: Add a deprecation warning for
LegacyPolicyDecision.
- The removal of
Summary
This PR introduces critical features for MCP protocol governance but has several security and compatibility concerns. Addressing the replay protection, regex vulnerabilities, and sandbox escape vectors should be prioritized. Additionally, ensure backward compatibility and thread safety across the new classes.
Recommended Actions
- 🔴 Address replay protection and regex vulnerabilities.
- 🟡 Document public API changes and provide migration guides.
- 💡 Improve thread safety, type validation, and audit logging mechanisms.
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
🔴 CRITICAL: Security Issues
-
Replay Protection in
McpMessageSignerandMcpMessageValidator:- While the PR mentions bounded nonce replay cache and concurrent replay protection, there is no explicit code demonstrating how the nonce cache is implemented or how it handles edge cases like cache eviction or collisions. Without proper implementation, this could lead to replay attacks.
- Action: Ensure the nonce cache is implemented securely with eviction policies and collision handling. Add tests to validate the behavior under high concurrency and edge cases.
-
Regex Injection in
CredentialRedactorandMCPGateway:- The
blockedPatternsandcustomPatternsaccept user-provided regular expressions. This can lead to potential regex denial-of-service (ReDoS) attacks if the regex patterns are crafted maliciously. - Action: Validate and sanitize user-provided regex patterns to prevent ReDoS vulnerabilities. Consider limiting regex complexity (e.g., maximum length, nesting depth).
- The
-
Fail-Closed Behavior in
MCPGateway:- The
evaluateToolCallmethod defaults to fail-closed on internal errors, which is good. However, the error handling does not log or propagate detailed error information, which could hinder debugging and auditing. - Action: Enhance error logging to include detailed stack traces and context for debugging while ensuring sensitive information is redacted.
- The
-
Sensitive Key Redaction in
CredentialRedactor:- The
SENSITIVE_KEY_PATTERNregex may miss certain sensitive keys due to its limited scope. For example, it does not account for variations like "auth_token" or "access_secret". - Action: Expand the regex to cover more variations of sensitive keys. Consider allowing configurable patterns for specific use cases.
- The
-
Approval Handler in
MCPGateway:- The approval handler is optional, and the default behavior is to deny access if no handler is provided. This is a good security practice. However, there is no mechanism to ensure that the approval handler itself is secure or that it cannot be bypassed.
- Action: Add validation for the approval handler to ensure it meets security requirements. Document best practices for implementing secure approval handlers.
🟡 WARNING: Potential Breaking Changes
-
Public API Expansion:
- The addition of multiple new exports (
CredentialRedactor,MCPGateway,MCPSessionAuthenticator, etc.) significantly expands the public API surface. This could lead to backward compatibility issues if these APIs are modified in the future. - Action: Clearly document these new APIs and mark them as stable or experimental. Add versioning policies for future changes.
- The addition of multiple new exports (
-
Behavior Change in
AgentIdentity.suspendandAgentIdentity.revoke:- The
_reasonparameter is now ignored, which changes the behavior of these methods. This could break existing code that relies on thereasonparameter. - Action: Deprecate the
reasonparameter with a warning message instead of silently ignoring it.
- The
💡 Suggestions for Improvement
-
Thread Safety in
CredentialRedactorandMCPGateway:- The
CredentialRedactoruses aWeakMapfor tracking seen objects, which is not inherently thread-safe. Similarly,MCPGatewaydoes not explicitly address thread safety in concurrent evaluations. - Action: Add thread safety mechanisms (e.g., locks or atomic operations) for shared resources. Document concurrency guarantees.
- The
-
OWASP MCP Security Cheat Sheet Coverage:
- While the PR claims coverage of 11/12 sections, it would be beneficial to explicitly list the covered sections and provide tests or documentation demonstrating compliance.
- Action: Add a compliance matrix to the documentation, mapping implemented features to OWASP sections.
-
Rate Limiter Configuration:
- The rate limiter in
MCPGatewayis configurable, but there is no validation for extreme values (e.g., very high or very low limits). - Action: Add validation for rate limiter configurations to prevent misconfigurations.
- The rate limiter in
-
Credential Redaction Preview:
- The
truncatePreviewfunction is used to limit the size of redacted text previews. Consider making the truncation length configurable for better flexibility. - Action: Add a configuration option for truncation length.
- The
-
Test Coverage:
- While the PR mentions tests, there is no evidence of comprehensive test coverage for edge cases like high concurrency, large payloads, or malicious inputs.
- Action: Add tests for edge cases and stress scenarios. Include tests for fail-closed behavior under various error conditions.
Summary
This PR introduces significant security features and OWASP compliance improvements to the TypeScript SDK. However, there are critical security issues related to replay protection, regex injection, and sensitive key redaction that need immediate attention. Additionally, potential breaking changes and thread safety concerns should be addressed to ensure robustness and backward compatibility.
Recommended Actions:
- Address 🔴 CRITICAL security issues before merging.
- Resolve 🟡 WARNING breaking changes or document them clearly.
- Implement 💡 Suggestions for improved security, usability, and maintainability.
| } | ||
|
|
||
| function hasNestedQuantifier(source: string): boolean { | ||
| return /\((?:[^()\\]|\\.)*[+*{][^()]*\)[+*{?]/.test(source); |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
There was a problem hiding this comment.
Resolved. Replaced the regex-based nested-quantifier detector with a pure stack-based character scanner — zero regex literals remain in this file. See afaa7a9.
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
🔴 CRITICAL: Security Issues
-
Replay Protection in
McpMessageSigner:- The nonce replay cache implementation is not included in this PR. Without a robust mechanism to prevent replay attacks, the HMAC-SHA256 signing can be bypassed by reusing valid signatures.
- Action: Ensure that the
SignerNonceStoreimplementation is fail-closed and includes bounded storage with eviction policies. Add tests to validate replay protection under concurrent conditions.
-
Regex Injection in
CredentialRedactor:- The
toGlobalPatternfunction accepts arbitrary regex patterns. If these patterns are user-defined, they could lead to catastrophic backtracking or denial-of-service attacks. - Action: Validate regex complexity using a library like
safe-regexor implement a timeout mechanism for regex execution.
- The
-
Sanitization in
MCPGateway:- The
checkSanitizationmethod is not fully implemented, leaving potential sandbox escape vectors unaddressed. Dangerous patterns likerm,del, andmkfsare flagged but not comprehensively handled. - Action: Expand sanitization checks to cover OWASP Injection flaws comprehensively. Add fail-closed behavior for unrecognized patterns.
- The
-
Approval Handler Trust Boundary:
- The
approvalHandlermechanism relies on external human reviewers but does not enforce cryptographic integrity for the approval decision. This could lead to tampering. - Action: Implement cryptographic signing for approval decisions to ensure integrity and authenticity.
- The
🟡 WARNING: Potential Breaking Changes
-
Export Changes in
index.ts:- The addition of new exports (
CredentialRedactor,MCPResponseScanner, etc.) changes the public API of the TypeScript SDK. This could break existing consumers of the library if they rely on the previous export structure. - Action: Document these changes clearly in the release notes and consider versioning the package appropriately.
- The addition of new exports (
-
Behavioral Changes in
AgentIdentity:- The
_reasonparameter insuspendandrevokemethods is now unused. This could lead to confusion for developers expecting the parameter to be functional. - Action: Either remove the parameter entirely or implement its functionality. Update the documentation to reflect the intended behavior.
- The
💡 Suggestions for Improvement
-
Thread Safety in
CredentialRedactor:- The
WeakMapused for circular reference detection inredactNodeis not inherently thread-safe. While JavaScript is single-threaded, consider documenting this limitation for environments like Node.js where concurrency might be simulated.
- The
-
Rate Limiting in
MCPGateway:- The
rateLimiterimplementation is optional, but its absence could lead to abuse. Consider making rate limiting mandatory for sensitive tools.
- The
-
Backward Compatibility:
- The removal of
LegacyPolicyDecisionfromaudit.tscould break compatibility for consumers relying on this type. - Action: Deprecate the type first and provide migration guidance.
- The removal of
-
Testing Coverage:
- Add tests for edge cases in
CredentialRedactor, such as deeply nested objects, circular references, and large payloads.
- Add tests for edge cases in
-
OWASP MCP Security Cheat Sheet Compliance:
- While 11/12 sections are covered, the absence of §11 Consent UI should be explicitly documented as out of scope for server-side SDKs.
Summary
This PR introduces critical security primitives for MCP governance but has several gaps in replay protection, regex validation, and sandbox sanitization. Addressing these issues is essential to ensure the robustness and security of the implementation. Additionally, the changes to the public API and behavioral modifications require careful documentation to avoid breaking existing consumers.
Recommended Actions:
- Address the 🔴 CRITICAL issues immediately.
- Document and version changes flagged as 🟡 WARNING.
- Implement the 💡 SUGGESTIONS to improve overall quality and compliance.
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
🔴 CRITICAL: Security Issues
-
Replay Protection in
McpMessageSignerandMcpMessageValidator:- The implementation mentions "bounded nonce replay cache and concurrent replay protection," but the code for nonce management and replay protection is not included in the diff. Ensure that:
- Nonces are unique and securely stored.
- Replay protection is enforced across distributed systems (e.g., using a shared nonce store or database).
- Nonce expiration is handled to prevent memory exhaustion.
- Missing or flawed nonce handling could allow replay attacks, bypassing security measures.
Action: Verify nonce storage implementation and add tests for replay protection.
- The implementation mentions "bounded nonce replay cache and concurrent replay protection," but the code for nonce management and replay protection is not included in the diff. Ensure that:
-
Regex Injection in
CredentialRedactor:- The
toGlobalPatternfunction dynamically compiles regex patterns. If user-provided patterns are passed without validation, this could lead to regex injection vulnerabilities. - Although
validateRegexis called, ensure it includes safeguards against catastrophic backtracking and denial-of-service attacks.
Action: Harden
validateRegexto reject unsafe patterns and add tests for edge cases. - The
-
Blocked Patterns in
MCPGateway:- The
blockedPatternsarray allows custom regex patterns. If these are user-defined, they could introduce vulnerabilities (e.g., bypassing sanitization or causing denial-of-service). - Ensure that all patterns are validated using
validateRegex.
Action: Add stricter validation for
blockedPatternsand document safe usage. - The
-
Fail-Closed Behavior in
evaluateToolCall:- The
evaluateToolCallmethod defaults to fail-closed behavior on errors, which is good. However, the error message (Internal gateway error - access denied) could leak implementation details if logged or exposed externally.
Action: Ensure error messages are generic and do not reveal sensitive information.
- The
🟡 WARNING: Potential Breaking Changes
-
Public API Changes in
index.ts:- The addition of multiple new exports (e.g.,
CredentialRedactor,MCPGateway,MCPSessionAuthenticator) significantly expands the API surface. This could lead to compatibility issues for downstream consumers relying on the previous API structure.
Action: Document all new exports and provide migration guidance for existing users.
- The addition of multiple new exports (e.g.,
-
Behavior Change in
AgentIdentity.suspendandAgentIdentity.revoke:- The
_reasonparameter is now prefixed with an underscore, indicating it is unused. This change could affect consumers relying on the parameter for logging or audit purposes.
Action: Deprecate the parameter explicitly and provide alternatives for users who rely on it.
- The
💡 Suggestions for Improvement
-
Thread Safety in
CredentialRedactor:- The
redactNodemethod uses aWeakMapfor cycle detection. While this is a good approach, consider documenting its thread safety and ensuring it is not shared across threads.
Action: Add comments or documentation clarifying thread safety guarantees.
- The
-
OWASP MCP Security Cheat Sheet Compliance:
- The PR mentions compliance with 11/12 sections of the OWASP MCP Security Cheat Sheet. Consider adding a checklist or documentation showing how each section is addressed.
Action: Include a compliance matrix in the documentation.
-
Rate Limiting in
MCPGateway:- The rate limiter (
MCPSlidingRateLimiter) is configurable, but its behavior under high concurrency is unclear. Ensure that:- Rate limits are enforced consistently across distributed systems.
- Retry logic is robust and does not introduce race conditions.
Action: Add stress tests for rate limiting under high concurrency.
- The rate limiter (
-
Credential Redaction Logging:
- The
CredentialRedactorclass provides redaction for sensitive data. Consider adding an option to log redacted entries for audit purposes, ensuring logs remain safe for external review.
Action: Add a configurable logging mechanism for redacted credentials.
- The
-
Test Coverage:
- While the PR mentions tests, ensure that edge cases (e.g., invalid regex patterns, high-concurrency rate limiting) are covered.
Action: Expand test coverage for edge cases and document test results.
Summary
This PR introduces critical security features for MCP governance, aligning with OWASP guidelines. However, several areas require attention to ensure robustness and backward compatibility:
- 🔴 Address replay protection, regex injection, and blocked pattern validation.
- 🟡 Document API changes and deprecate unused parameters.
- 💡 Improve thread safety, compliance documentation, and test coverage.
Once these issues are resolved, the PR will significantly enhance the security posture of the Agent Mesh SDK.
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Review Summary
This pull request introduces MCP (Model Context Protocol) governance primitives to the TypeScript Agent Mesh SDK, aiming for comprehensive OWASP MCP Security Cheat Sheet coverage. While the implementation is robust and security-focused, several areas require attention to ensure compliance with security standards, thread safety, and backward compatibility.
🔴 CRITICAL: Security Issues
-
Replay Attack Mitigation in
McpMessageSignerandMcpMessageValidator:- The PR mentions "bounded nonce replay cache and concurrent replay protection," but the implementation details are missing. Ensure that:
- Nonces are unique and cannot be reused.
- Nonce expiration is properly handled.
- Concurrency issues (e.g., race conditions) are addressed when checking and storing nonces.
- Action: Provide detailed implementation for nonce replay protection and ensure robust testing for edge cases.
- The PR mentions "bounded nonce replay cache and concurrent replay protection," but the implementation details are missing. Ensure that:
-
Regex Injection in
CredentialRedactorandMCPGateway:- The
validateRegexfunction is used to validate regex patterns, but its implementation is not included in the diff. If improperly implemented, this could lead to regex injection vulnerabilities. - Action: Ensure
validateRegexproperly sanitizes and limits regex patterns to prevent catastrophic backtracking or denial-of-service attacks.
- The
-
Fail-Closed Behavior in
MCPGateway:- The
evaluateToolCallmethod uses a fail-closed approach when encountering errors. While this is good practice, ensure that all exceptions are logged securely and that sensitive data is not exposed in logs. - Action: Review logging mechanisms to ensure sensitive data is redacted and error messages do not leak information.
- The
-
Sensitive Data Redaction in
CredentialRedactor:- The
CredentialRedactorclass uses regex patterns to redact sensitive data. Ensure that:- The patterns cover all possible sensitive data formats (e.g., JWTs, OAuth tokens, API keys).
- The redaction process is fail-safe and does not leave sensitive data unredacted in edge cases.
- Action: Expand test coverage for edge cases, including malformed inputs and large payloads.
- The
-
Policy Engine Evaluation:
- The
policyEvaluatorinMCPGatewayis optional, and its absence could lead to security bypasses. If no policy evaluator is provided, the SDK should fail closed. - Action: Add explicit checks to ensure that the absence of a policy evaluator results in a denied decision.
- The
🟡 WARNING: Potential Breaking Changes
-
Public API Changes:
- The addition of new exports in
index.ts(e.g.,CredentialRedactor,MCPGateway,MCPMessageSigner) expands the public API surface. Ensure that these additions are well-documented and backward-compatible. - Action: Verify that existing functionality is unaffected and document the new API changes thoroughly.
- The addition of new exports in
-
Behavior Change in
AgentIdentity.suspendandAgentIdentity.revoke:- The
_reasonparameter is now prefixed with an underscore, which may break existing code relying on the previous method signature. - Action: Add deprecation warnings for the old method signature and provide clear migration guidance.
- The
💡 Suggestions for Improvement
-
Thread Safety in
CredentialRedactor:- The
redactNodemethod uses aWeakMapto track seen objects, which is thread-safe in single-threaded environments but may cause issues in concurrent execution. - Suggestion: Consider adding explicit thread-safety mechanisms or documenting that this class is not safe for concurrent use.
- The
-
OWASP MCP Compliance:
- The PR mentions 11/12 sections of OWASP MCP Security Cheat Sheet coverage. Document the missing section (§11 Consent UI) and clarify its exclusion to avoid confusion.
- Suggestion: Add a roadmap for future compliance with §11 Consent UI.
-
Testing Coverage:
- While the PR mentions tests, ensure that edge cases for all security-sensitive components (e.g., nonce replay, regex validation, redaction) are covered.
- Suggestion: Add fuzz testing for regex patterns and nonce handling.
-
Logging Best Practices:
- Ensure that all logs in
MCPGatewayand other components are sanitized to prevent sensitive data leakage. - Suggestion: Use structured logging and integrate with a secure logging framework.
- Ensure that all logs in
-
Documentation:
- The new features (e.g.,
MCPGateway,CredentialRedactor) should be accompanied by detailed documentation, including usage examples and security considerations. - Suggestion: Add inline comments and update the SDK documentation.
- The new features (e.g.,
-
Backward Compatibility Testing:
- Run regression tests to ensure that existing functionality is unaffected by the new additions.
- Suggestion: Add a compatibility matrix to verify support for older versions of the SDK.
Conclusion
The PR introduces valuable security features and aligns with OWASP MCP guidelines. However, critical issues related to replay attack mitigation, regex injection, and policy engine correctness must be addressed before merging. Additionally, potential breaking changes and thread safety concerns should be resolved or documented. With these improvements, the PR will significantly enhance the security and functionality of the Agent Mesh SDK.
|
CI Status Summary — All findings addressed ✅ All CI checks pass except:
This is the Core PR in a 3-PR stack. Merge order: #791 (Core) → #827 (Package) → #825 (Docs). |
|
Approved and ready to merge, but this PR has merge conflicts with main (likely from #774 merging). Please rebase on latest main to resolve conflicts, then we can merge. |
afaa7a9 to
28bd13b
Compare
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Review Summary
This pull request introduces significant security features to the TypeScript Agent Mesh SDK, particularly focusing on the Model Context Protocol (MCP). The implementation appears to be well-structured and adheres to many OWASP guidelines. However, there are several areas that require attention, particularly regarding security, potential breaking changes, and overall code quality.
Actionable Feedback
🔴 CRITICAL Issues
-
Replay Protection: While the
McpMessageSignerincludes a bounded nonce replay cache, ensure that the nonce generation is truly unique and unpredictable. If the nonce can be predicted or reused, it could lead to replay attacks. Consider using a cryptographically secure random number generator for nonce creation. -
Input Sanitization: The
McpInputSanitizeruses regex-based validation. Ensure that the regex patterns are thoroughly tested against potential injection attacks (e.g., SQL injection, XSS). It’s crucial to validate that the regex patterns do not allow for bypassing the intended sanitization. -
Error Handling: In the
evaluateToolCallmethod ofMCPGateway, ensure that sensitive information is not leaked in error messages. The current implementation logs the error but does not specify how sensitive data is handled in the logs. Implement a mechanism to redact sensitive information from logs. -
Thread Safety: The
McpToolRegistryclaims to have thread-safe operations. Ensure that all shared resources are properly synchronized to prevent race conditions, especially in concurrent environments. Consider using locks or other synchronization mechanisms where necessary.
🟡 WARNING Issues
-
Public API Changes: The addition of new classes and methods (e.g.,
CredentialRedactor,McpMessageSigner) may introduce breaking changes for users relying on previous versions of the SDK. Ensure that the versioning follows semantic versioning principles, and document any breaking changes clearly in the release notes. -
Type Safety: The introduction of new types in
index.tsand other files should be reviewed for consistency with existing types. Ensure that all new types are well-documented and that their usage does not introduce type safety issues.
💡 SUGGESTION Improvements
-
Documentation: Enhance the documentation for the new features, especially around the security primitives. Provide examples of how to use the
McpMessageSigner,McpSessionManager, andCredentialRedactor. Clear documentation will help users understand the security implications and usage patterns. -
Testing: Ensure that comprehensive unit tests cover all new classes and methods. Pay special attention to edge cases, especially in the
redactmethods and theMCPGatewayevaluation logic. Consider adding integration tests to validate the interactions between components. -
Configuration Validation: In the
MCPGatewayconstructor, consider adding validation for the configuration parameters. For instance, ensure thatallowedToolsanddeniedToolsdo not overlap, and that patterns inblockedPatternsare valid regex. -
Performance Considerations: Review the performance implications of using regex for input sanitization and credential redaction. If performance is a concern, consider optimizing the regex patterns or using alternative methods for sanitization.
-
Code Consistency: Maintain consistent formatting and style throughout the codebase. For example, ensure that comments and documentation follow the same style guide. This will improve readability and maintainability.
Conclusion
Overall, the PR introduces valuable security features to the TypeScript Agent Mesh SDK. However, attention to the highlighted critical issues is essential to ensure the security and robustness of the implementation. Addressing the warnings and suggestions will further enhance the quality and usability of the code.
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Review Summary
This pull request introduces MCP (Model Context Protocol) governance primitives to the TypeScript Agent Mesh SDK. The implementation appears robust and well-structured, addressing OWASP MCP Security Cheat Sheet coverage (11/12 sections). However, there are several areas that require attention to ensure correctness, security, and maintainability.
🔴 CRITICAL Issues
-
Replay Protection in
McpMessageSigner- The bounded nonce replay cache implementation is not included in the diff. If the nonce cache is not thread-safe or does not enforce strict uniqueness, it could allow replay attacks, which are a critical security vulnerability.
- Action: Ensure that the nonce cache is thread-safe and strictly enforces uniqueness for nonces. Consider using a cryptographically secure mechanism for nonce generation and validation.
-
Regex Injection in
CredentialRedactor- The
CredentialRedactorallows custom regex patterns viaCredentialRedactorConfig. However, there is no validation of these patterns beyond checking if they are valid regex. This opens the door to potential regex denial-of-service (ReDoS) attacks. - Action: Implement a mechanism to limit the complexity of user-provided regex patterns. For example, use libraries like
safe-regexto validate regex patterns before accepting them.
- The
-
Sanitization Timeout in
CredentialRedactor- The
redactStringmethod uses a time budget (scanTimeoutMs) for regex-based sanitization. If the timeout is exceeded, the method fails closed. However, the behavior in case of timeout is not defined in the code snippet provided. - Action: Ensure that a timeout does not lead to partial sanitization or incomplete redaction. Consider logging a critical error and rejecting the input entirely if the timeout is exceeded.
- The
-
Policy Evaluation Fail-Closed Behavior
- The
evaluateToolCallmethod defaults to fail-closed behavior in case of an error. However, the error message is generic (Internal gateway error - access denied). This could lead to operational challenges in debugging. - Action: Log detailed error information securely (e.g., to a secure audit log) while maintaining fail-closed behavior for external responses.
- The
-
Sensitive Key Redaction
- The
SENSITIVE_KEY_PATTERNinCredentialRedactoris case-insensitive but may not cover all sensitive keys. For example, keys like "authToken" or "sessionKey" are not included. - Action: Expand the
SENSITIVE_KEY_PATTERNto include additional common sensitive key names. Consider making this pattern configurable.
- The
🟡 WARNING: Potential Breaking Changes
-
Public API Changes
- The addition of new exports in
index.ts(e.g.,CredentialRedactor,MCPMessageSigner,MCPGateway) expands the public API. While this is expected for new features, ensure that these additions do not conflict with existing APIs or introduce ambiguity. - Action: Document these new APIs thoroughly and ensure backward compatibility with existing functionality.
- The addition of new exports in
-
Behavioral Changes in
AgentIdentity.suspendandAgentIdentity.revoke- The
_reasonparameter is now ignored (_reason?: string). If external consumers relied on this parameter for logging or auditing, this change could break their implementations. - Action: Deprecate the parameter instead of ignoring it outright, and provide a migration path for consumers.
- The
💡 Suggestions for Improvement
-
Thread Safety in
CredentialRedactor- The
redactNodemethod uses aWeakMapfor tracking seen objects. While this prevents circular references, it does not guarantee thread safety in concurrent environments. - Suggestion: Add thread-safety mechanisms (e.g., locks or atomic operations) to ensure correctness in multi-threaded scenarios.
- The
-
Audit Logging in
MCPGateway- The
auditSinkimplementation (InMemoryMCPAuditSink) stores audit entries in memory. This could lead to memory exhaustion in high-throughput environments. - Suggestion: Provide an option for persistent audit logging (e.g., to a database or file system) and implement log rotation mechanisms.
- The
-
Regex Complexity Budget
- The
createRegexScanBudgetfunction is used for sanitization but is not included in the diff. Ensure that it accounts for regex complexity to prevent ReDoS attacks. - Suggestion: Use libraries like
safe-regexor implement a custom complexity checker.
- The
-
Rate Limiter Configuration
- The
rateLimiterconfiguration inMCPGatewaydefaults toundefinedifrateLimitis not provided. This could lead to accidental omission of rate limiting in production environments. - Suggestion: Log a warning if rate limiting is disabled, and consider enabling it by default with reasonable limits.
- The
-
Testing Coverage
- While the PR mentions that tests have been added, the diff does not include test files. Ensure that all critical paths (e.g., nonce replay protection, regex sanitization, policy evaluation) are thoroughly tested.
- Suggestion: Add unit tests for edge cases, such as invalid regex patterns, replay attacks, and rate limit exhaustion.
-
Documentation
- The PR mentions that documentation will be added in Part 3 (#825). However, the new APIs introduced in this PR should have at least basic documentation (e.g., JSDoc comments) to aid reviewers and future developers.
- Suggestion: Add JSDoc comments for all new classes, methods, and types.
Final Recommendation
- Address the 🔴 CRITICAL issues before merging.
- Consider the 🟡 WARNING items and provide clear documentation for any breaking changes.
- Implement the 💡 SUGGESTIONS to improve security, maintainability, and developer experience.
Once the critical issues are resolved and the necessary tests are added, this PR can be approved for merging.
f39b6e0 to
6b00da5
Compare
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
🔴 CRITICAL Issues
-
Replay Protection in
McpMessageSigner/McpMessageValidator:- The PR mentions "bounded nonce replay cache and concurrent replay protection," but the implementation details are not visible in the diff. Ensure that:
- Nonces are cryptographically secure and unique per message.
- The replay cache is robust against race conditions in concurrent environments.
- Expired nonces are properly evicted to prevent memory exhaustion.
- Action: Add tests for nonce replay protection under high concurrency and edge cases (e.g., nonce expiration).
- The PR mentions "bounded nonce replay cache and concurrent replay protection," but the implementation details are not visible in the diff. Ensure that:
-
Regex Injection in
CredentialRedactor:- The
CredentialRedactoraccepts custom regex patterns viaCredentialRedactorConfig. If these patterns are user-supplied, they could lead to denial-of-service attacks (e.g., catastrophic backtracking). - Action: Validate all regex patterns using a strict timeout mechanism or a regex complexity analyzer. Consider rejecting overly complex patterns.
- The
-
Sandbox Escape in
MCPGateway:- The
blockedPatternsfeature inMCPGatewayincludes dangerous patterns likerm,del, andmkfs. However, the sanitization logic does not explicitly prevent command injection or sandbox escapes. - Action: Add explicit checks for command injection (e.g.,
;,&&,|,>). Ensure that all user-supplied inputs are sanitized before being passed to external tools or APIs.
- The
-
Approval Handler Trust Boundary:
- The
approvalHandlerinMCPGatewaydelegates sensitive decisions to human reviewers. If the handler is compromised, it could allow malicious approvals. - Action: Implement audit logging for all approval decisions, including reviewer identity and timestamps. Consider adding cryptographic signing for audit logs.
- The
🟡 WARNING: Potential Breaking Changes
-
Export Changes in
index.ts:- The PR introduces new exports (e.g.,
CredentialRedactor,MCPGateway,MCPMessageSigner) and modifies existing ones. This could break consumers relying on the previous export structure. - Action: Document all new exports and provide migration guidance for existing users.
- The PR introduces new exports (e.g.,
-
Behavioral Changes in
AgentIdentity:- The
suspendandrevokemethods now ignore thereasonparameter. This could affect downstream consumers relying on thereasonfor logging or auditing. - Action: Deprecate the
reasonparameter with a clear warning in the documentation.
- The
💡 Suggestions for Improvement
-
Thread Safety in
CredentialRedactor:- The
redactNodemethod uses aWeakMapfor tracking seen objects. While this prevents infinite recursion, it may not be thread-safe in concurrent environments. - Suggestion: Add explicit thread safety mechanisms or document that the class is not thread-safe.
- The
-
OWASP MCP Security Cheat Sheet Compliance:
- While the PR claims coverage of 11/12 sections, it does not address §11 (Consent UI). Consider adding a placeholder or documentation for future implementation.
-
Testing Coverage:
- Ensure comprehensive tests for:
- Rate limiting in
MCPSlidingRateLimiter. - Credential redaction for edge cases (e.g., nested objects, circular references).
- Gateway decision logic under various configurations (e.g., conflicting allow/deny lists).
- Rate limiting in
- Ensure comprehensive tests for:
-
Performance Optimization:
- The
CredentialRedactorusesmatchAllandreplaceiteratively, which may degrade performance for large inputs. Consider optimizing the regex matching process.
- The
-
Documentation:
- The new classes (
MCPGateway,CredentialRedactor, etc.) lack detailed documentation. Add usage examples and configuration guidelines.
- The new classes (
Summary
This PR introduces critical security features for the MCP protocol governance in the TypeScript SDK. While the implementation is robust and addresses many OWASP concerns, there are critical issues related to replay protection, regex injection, sandbox escape, and trust boundary handling that must be addressed before merging. Additionally, potential breaking changes should be documented, and further improvements can be made to enhance thread safety, performance, and testing coverage.
Recommended Actions:
- Address the 🔴 CRITICAL issues before merging.
- Document 🟡 WARNING changes to ensure backward compatibility.
- Consider implementing 💡 SUGGESTIONS for better performance, thread safety, and developer experience.
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
Summary
This PR introduces MCP (Model Context Protocol) security primitives to the TypeScript Agent Mesh SDK, aiming for compliance with 11 out of 12 sections of the OWASP MCP Security Cheat Sheet. The implementation includes several security-focused features such as HMAC-SHA256 signing, nonce replay protection, session management, input sanitization, and credential redaction.
🔴 CRITICAL Issues
-
Replay Cache Size and Eviction Policy:
- The
McpMessageSignerandMcpMessageValidatoruse a bounded nonce replay cache for replay protection. However, the PR does not specify the eviction policy or the size of the cache. If the cache size is too small or eviction is not handled properly, this could lead to a security vulnerability where older nonces are reused. - Action: Clearly define the eviction policy and ensure that the cache size is configurable. Add tests to verify the behavior when the cache is full.
- The
-
Regex Injection in
CredentialRedactor:- The
CredentialRedactorallows custom regex patterns to be added viaCredentialRedactorConfig. While thevalidateRegexfunction is used, the implementation does not specify what validation is performed. If the validation is insufficient, this could lead to regex injection vulnerabilities. - Action: Ensure
validateRegexproperly checks for malicious or overly complex regex patterns that could lead to denial-of-service attacks. Add tests to verify the robustness of the validation logic.
- The
-
Sanitization Timeout:
- The
MCPGatewayuses ascanTimeoutMsparameter for sanitization, but there is no fallback mechanism if the timeout is exceeded. This could lead to fail-open behavior, allowing malicious input to bypass sanitization. - Action: Implement a fail-closed mechanism for cases where the sanitization process exceeds the timeout. Add tests to verify this behavior.
- The
-
Approval Handler Default Behavior:
- The
MCPGatewayrelies on anapprovalHandlerfor sensitive tools or policy decisions requiring human review. If the handler is not provided, the default behavior is to setapprovalStatustoPending. This could lead to operational delays or fail-open scenarios. - Action: Define a clear fallback mechanism for cases where the
approvalHandleris not provided or fails to respond. Consider defaulting toApprovalStatus.Deniedfor fail-closed behavior.
- The
🟡 WARNING Issues
-
Breaking Changes in Public API:
- The
index.tsfile introduces several new exports (CredentialRedactor,MCPGateway, etc.) and modifies existing ones. While these additions are non-breaking, they significantly expand the API surface area, which could lead to compatibility issues in downstream projects. - Action: Clearly document all new exports and their intended usage. Provide migration guides if necessary.
- The
-
Backward Compatibility for
AuditConfigandAuditEntry:- The removal of
LegacyPolicyDecisionfromaudit.tsmay break compatibility for users relying on this type. - Action: Deprecate
LegacyPolicyDecisioninstead of removing it outright. Add a warning in the documentation about its future removal.
- The removal of
💡 Suggestions for Improvement
-
Thread Safety:
- The
CredentialRedactoruses aWeakMapto track seen objects during recursive redaction. While this approach avoids circular references, it is unclear whether the implementation is thread-safe. - Suggestion: Add explicit documentation about thread safety and consider using locks or other synchronization mechanisms if concurrent usage is expected.
- The
-
OWASP MCP Compliance Gap:
- The PR mentions that §11 (Consent UI) is out of scope for server-side SDKs. While this is reasonable, consider adding a note in the documentation to clarify this limitation for users.
- Suggestion: Provide examples or guidelines for implementing client-side consent UI to achieve full OWASP MCP compliance.
-
Logging and Debugging:
- The
debugSecurityFailurefunction is used for logging security failures, but its behavior is not defined in the PR. - Suggestion: Ensure that sensitive information is not logged. Add tests to verify that logs do not leak sensitive data.
- The
-
Rate Limiter Configuration:
- The
MCPSlidingRateLimiteris used for rate limiting, but its configuration options are not fully documented. - Suggestion: Provide detailed documentation for configuring the rate limiter, including examples of usage.
- The
-
Credential Redaction Coverage:
- The
CredentialRedactorincludes a set of built-in patterns for sensitive data. While comprehensive, it may not cover all use cases (e.g., custom API keys or proprietary tokens). - Suggestion: Allow users to dynamically update the list of patterns at runtime, and provide a mechanism to validate these patterns.
- The
-
Test Coverage:
- While the PR mentions that tests have been added, the diff does not include the test files. It is crucial to ensure that all new features are thoroughly tested, especially for edge cases and failure scenarios.
- Suggestion: Verify that tests cover all critical paths, including fail-closed scenarios, edge cases for regex validation, and concurrent usage.
Final Assessment
This PR introduces significant security improvements and new features to the TypeScript Agent Mesh SDK. However, there are critical issues related to replay protection, regex validation, and fail-closed behavior that must be addressed before merging. Additionally, potential breaking changes and areas for improvement should be documented and tested thoroughly.
Recommended Actions Before Merge:
- Address the 🔴 CRITICAL issues.
- Provide documentation for new features and API changes.
- Ensure comprehensive test coverage for all new functionality.
Once these issues are resolved, the PR can be considered for merging.
🤖 AI Agent: docs-sync-checker — Issues Found📝 Documentation Sync ReportIssues Found
Suggestions
Example Docstring for
|
🤖 AI Agent: breaking-change-detector — Summary🔍 API Compatibility ReportSummaryThis pull request introduces new features to the TypeScript SDK for Agent Mesh, specifically adding MCP (Model Context Protocol) governance capabilities. The changes are primarily additive, with new classes, methods, and types introduced. There are no breaking changes identified in the Python packages or the TypeScript SDK. Findings
Migration GuideFor 🟡 Potentially Breaking Changes:
For 🔵 Additive Changes:
Conclusion✅ No breaking changes were found in the Python packages. The TypeScript SDK changes are mostly additive, with one minor potentially breaking change due to parameter renaming in two methods. |
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review for feat(typescript): add MCP protocol governance with full OWASP coverage
🔴 CRITICAL: Security Issues
-
Replay Protection in
McpMessageSignerandMcpMessageValidator:- The implementation mentions bounded nonce replay cache and concurrent replay protection but does not provide details about the size of the cache or its eviction policy. If the cache size is too small or eviction is not handled properly, it could lead to replay attacks.
- Recommendation: Ensure that the nonce cache size is configurable and sufficiently large to handle high-throughput scenarios. Implement a robust eviction policy (e.g., LRU) to avoid cache overflow.
-
Regex Injection in
CredentialRedactor:- The
toGlobalPatternfunction dynamically compiles regex patterns, which could lead to regex injection if the input is not properly sanitized. - Recommendation: Validate and sanitize all user-provided regex patterns before compiling them. Consider rejecting overly complex or potentially malicious patterns.
- The
-
Blocked Patterns in
MCPGateway:- The
blockedPatternsarray allows user-defined regex patterns. If these patterns are not properly validated, they could introduce vulnerabilities such as denial-of-service attacks due to catastrophic backtracking. - Recommendation: Ensure that all regex patterns in
blockedPatternsare validated for performance and safety using a library likesafe-regex.
- The
-
Sensitive Key Redaction in
CredentialRedactor:- The
SENSITIVE_KEY_PATTERNregex is case-insensitive but may miss certain variations of sensitive keys (e.g.,apiKeyvs.api_key). - Recommendation: Expand the regex to cover more variations and edge cases. Consider using a curated list of sensitive key patterns.
- The
-
Fail-Closed Behavior in
MCPGateway:- While the fail-closed behavior is mentioned, there is no explicit test coverage or guarantees for all failure scenarios (e.g., unexpected exceptions in
policyEvaluatororapprovalHandler). - Recommendation: Add comprehensive tests to ensure fail-closed behavior in all possible failure scenarios.
- While the fail-closed behavior is mentioned, there is no explicit test coverage or guarantees for all failure scenarios (e.g., unexpected exceptions in
🟡 WARNING: Potential Breaking Changes
-
Expanded Exports in
index.ts:- The addition of numerous new exports in
index.tscould lead to unintended consequences for downstream consumers who may not expect these new APIs. - Recommendation: Clearly document the new exports and mark them as experimental if they are not yet stable.
- The addition of numerous new exports in
-
Changes to
AgentIdentity.suspendandAgentIdentity.revoke:- The
_reasonparameter is now prefixed with an underscore, which could break existing code that relies on the previous parameter name. - Recommendation: Maintain backward compatibility by supporting both
reasonand_reasonfor a deprecation period.
- The
💡 Suggestions for Improvement
-
Thread Safety in
CredentialRedactor:- The
redactNodemethod uses aWeakMapfor tracking seen objects but does not explicitly guarantee thread safety. - Recommendation: Document whether
CredentialRedactoris thread-safe. If not, consider adding thread safety or warning users in the documentation.
- The
-
OWASP MCP Security Cheat Sheet Coverage:
- While the PR claims coverage of 11/12 sections, it would be helpful to explicitly list the covered sections and provide links to relevant tests or documentation.
- Recommendation: Add a summary table in the documentation showing OWASP MCP sections and their corresponding implementation/test coverage.
-
Rate Limiting in
MCPGateway:- The rate limiter implementation is abstracted but does not provide visibility into its configuration or behavior.
- Recommendation: Add logging or metrics to track rate limiter usage and effectiveness.
-
Credential Redaction Preview Truncation:
- The
truncatePreviewfunction is used to truncate matched text for redaction. Ensure that the truncation logic does not inadvertently expose sensitive information. - Recommendation: Add tests to verify that truncated previews do not leak sensitive data.
- The
-
Documentation for
CredentialRedactor:- The
CredentialRedactorclass is a critical security feature but lacks detailed documentation. - Recommendation: Provide examples and guidelines for using
CredentialRedactor, including how to define custom patterns and configure the redaction behavior.
- The
-
Testing Coverage:
- While the PR mentions that tests have been added, it is unclear whether all edge cases (e.g., regex validation, fail-closed behavior) are covered.
- Recommendation: Add tests for edge cases, such as invalid regex patterns, large payloads, and high-concurrency scenarios.
Summary
- This PR introduces critical security features for MCP governance but has several areas that require attention to ensure robustness and compliance with security best practices.
- Address the identified security issues and potential breaking changes before merging.
- Enhance documentation and testing to improve maintainability and confidence in the implementation.
Let me know if you need further clarification or assistance!
🤖 AI Agent: test-generator — `packages/agent-compliance/src/agent_compliance/integrity.py`🧪 Test Coverage Analysis
|
Squashed from jb/ts-mcp-owasp-parity: - Add MCP security primitives with OWASP coverage - Harden MCP regex patterns against ReDoS - Tighten MCP regex patterns for CodeQL - Validate MCP regex inputs and log fail-closed paths - Replace flagged MCP regex scans with string checks - Remove regex execution from MCP validator - Use string-constructed regex to avoid CodeQL ReDoS false positive - Move import to top and remove unused ALLOWED_MODULE_PREFIXES
38c4150 to
3b4e64d
Compare
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review: feat(typescript): add MCP protocol governance with full OWASP coverage
This PR introduces a significant addition to the TypeScript Agent Mesh SDK, implementing MCP (Model Context Protocol) security primitives. Below is a detailed review of the changes, focusing on the specified areas of concern.
🔴 CRITICAL: Security Issues
-
Replay Protection in
MCPMessageSigner- The
MCPMessageSignerimplementation relies on a nonce replay cache for replay protection. However, the implementation details are not visible in the provided diff. Ensure that:- The nonce cache has a bounded size to prevent memory exhaustion.
- Nonces are securely generated using a cryptographically secure random number generator.
- Nonces are stored securely and are not predictable.
- Nonces are validated against the cache before processing the message.
- If any of these conditions are not met, it could lead to replay attacks or denial-of-service vulnerabilities.
- The
-
Regex Denial of Service (ReDoS) in
CredentialRedactorandMCPGateway- The
CredentialRedactorandMCPGatewayclasses use regular expressions for pattern matching. While there is avalidateRegexfunction and a time-budget mechanism (createRegexScanBudget), the implementation details of these mechanisms are not provided. Ensure that:- The
validateRegexfunction checks for catastrophic backtracking patterns in the regular expressions. - The time-budget mechanism is robust and prevents excessive resource consumption.
- The
- Without these safeguards, the use of untrusted input in regular expressions could lead to ReDoS vulnerabilities.
- The
-
Shell Expansion Detection in
MCPGateway- The
hasShellExpansionfunction checks for shell expansion patterns (e.g.,$()). However, this check is rudimentary and may not cover all cases. Consider using a more comprehensive approach to detect and mitigate shell injection vulnerabilities.
- The
-
Credential Redaction
- The
CredentialRedactorclass attempts to redact sensitive information from logs. However:- Ensure that the
BUILTIN_PATTERNSlist is comprehensive and includes patterns for all sensitive data types (e.g., JWTs, OAuth tokens, etc.). - The
truncatePreviewfunction is not visible in the diff. Verify that it does not inadvertently expose sensitive information. - Consider adding a mechanism to log when sensitive data is redacted to help identify potential leaks.
- Ensure that the
- The
-
Approval Handler in
MCPGateway- The
approvalHandleris optional, and its absence defaults theapprovalStatustoPending. This could lead to a denial of service if approvals are not processed in a timely manner. Consider adding a configurable timeout or fallback mechanism for approvals.
- The
-
Rate Limiting in
MCPGateway- The
rateLimiterimplementation is not visible in the diff. Ensure that:- The rate limiter is resistant to bypass techniques, such as IP spoofing or user-agent spoofing.
- The rate limiter is not vulnerable to timing attacks.
- The
🟡 WARNING: Potential Breaking Changes
-
Public API Changes
- The
index.tsfile now exports several new classes and types, which could potentially introduce breaking changes if existing consumers of the SDK are not updated. Ensure that:- These changes are documented in the release notes.
- A migration guide is provided if necessary.
- The
-
Policy Engine Changes
- The
PolicyDecisiontype has been modified to removeLegacyPolicyDecision. This could break existing integrations that rely on the old type. Consider providing a deprecation period or a compatibility layer.
- The
💡 Suggestions for Improvement
-
Thread Safety
- The
CredentialRedactorandMCPGatewayclasses use shared state (e.g.,this.auditEntriesandthis.redactor). Ensure that these shared resources are accessed in a thread-safe manner, especially if the SDK is used in a multi-threaded environment.
- The
-
Test Coverage
- While the PR mentions that tests have been added, ensure that:
- All new functionality is covered by unit tests, including edge cases.
- Security-critical components (e.g.,
MCPMessageSigner,MCPGateway) are tested against known attack vectors. - Performance tests are included for regex-based operations to detect potential bottlenecks.
- While the PR mentions that tests have been added, ensure that:
-
Backward Compatibility
- Consider marking deprecated types and methods with comments or annotations to guide developers during migration.
-
Documentation
- The new features introduced in this PR are complex and security-critical. Ensure that the documentation includes:
- Detailed usage examples for each new class and method.
- Security best practices for using the SDK.
- A clear explanation of the fail-closed behavior in case of errors.
- The new features introduced in this PR are complex and security-critical. Ensure that the documentation includes:
-
OWASP MCP Security Cheat Sheet Compliance
- While the PR claims compliance with 11 out of 12 sections of the OWASP MCP Security Cheat Sheet, consider adding a compliance matrix to the documentation to explicitly map features to the cheat sheet sections.
Summary
This PR introduces robust security primitives for MCP governance, addressing many critical areas of concern. However, there are potential security vulnerabilities (e.g., replay protection, ReDoS) and breaking changes that need to be addressed. Additionally, improvements in thread safety, test coverage, and documentation would enhance the overall quality of the implementation.
Action Items:
- Address the critical security issues flagged above.
- Ensure backward compatibility or provide a migration guide.
- Improve test coverage and documentation.
Let me know if you need further clarification or assistance!
|
Review: ESCALATED — Major Cross-Cutting Feature 🚨 This PR is part of a series of 18 PRs by @jackbatzner adding MCP protocol governance packages across 5 languages (TypeScript, .NET, Python, Go, Rust) plus documentation, OWASP mappings, and framework integrations. Per repo policy, this triggers multiple escalation rules:
Recommendation: These PRs should be reviewed as a cohesive set with a defined merge order. Maintainer design review of the overall MCP governance architecture is needed before merging individual PRs. Related PRs in this series: #775, #791, #824, #825, #826, #827, #828, #829, #830, #832, #833, #834, #835, #836, #839, #843, #844 |
|
Thank you for this work, @jackbatzner — the MCP governance implementation across multiple languages is impressive and clearly well-thought-out. After reviewing the full series, we've decided to take a hybrid approach (Decision C): keep MCP core logic in agent-os/agent-mesh and provide thin standalone re-export packages for enterprise repackaging — similar to what we shipped in PR #910 for Python. We're closing this PR because we'll implement the TypeScript MCP governance (3,349 lines) in-house following this architecture. Your work directly informed our approach — the OWASP mapping methodology, the gateway/rate-limiter/session-auth pattern, and the trust proxy design all carry forward. We're keeping your documentation PRs open for review as they add independent value. Thank you for the sustained contribution effort across the entire MCP governance surface. |
Description
Adds MCP (Model Context Protocol) security primitives to the TypeScript Agent Mesh SDK with full OWASP MCP Security Cheat Sheet coverage (11/12 sections — §11 Consent UI is out of scope for server-side SDKs).
Key additions:
McpMessageSigner/McpMessageValidator— HMAC-SHA256 signing with bounded nonce replay cache and concurrent replay protectionMcpSessionManager— rate-limited session lifecycle with serialized issuance and inactive bucket evictionMcpToolRegistry— schema-validated tool registration with thread-safe operationsMcpInputSanitizer— regex-based input validation with time-budget fail-closed behaviorCredentialRedactor— full PEM block + secret pattern redaction for audit-safe loggingSignerNonceStore,SessionStore), clock injection, fail-closed enforcementType of Change
Package(s) Affected
Checklist
Related Issues
Part 1 of 3 (split from original PR for easier review). Followed by #827 and #825.