feat: ScopeBlind protect-mcp integration — Cedar policy enforcement + verifiable receipts#667
Conversation
…nd verifiable decision receipts Adds `packages/agentmesh-integrations/scopeblind-protect-mcp/` with four components: - CedarPolicyBridge: maps Cedar allow/deny decisions into AGT evaluate() — Cedar deny is authoritative and cannot be overridden by trust scores - ReceiptVerifier: validates Ed25519-signed decision receipt structure, converts to AGT-compatible context - SpendingGate: enforces issuer-blind spending authority with trust-score gating and utilization band checks - scopeblind_context(): builds AGT-compatible context from protect-mcp artifacts Key architectural difference from mcp-trust-proxy: mcp-trust-proxy gates on trust scores (soft signals). protect-mcp gates on Cedar policies (formal, deterministic, auditable). Decision receipts provide cryptographic proof via IETF Internet-Draft draft-farley-acta-signed-receipts. 36 tests covering: Cedar decision parsing, policy bridge authorization, receipt validation, spending gate limits/categories/utilization bands, and AGT context shape compatibility. protect-mcp: https://www.npmjs.com/package/protect-mcp (v0.4.6, MIT) Docs: https://scopeblind.com/docs/protect-mcp Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Welcome to the Agent Governance Toolkit! Thanks for your first pull request. |
🤖 AI Agent: contributor-guide — Welcome! 🎉Welcome! 🎉Hi @first-time-contributor! 👋 Welcome to the microsoft/agent-governance-toolkit community, and thank you for taking the time to contribute. We’re thrilled to have you here and really appreciate your effort in submitting this pull request. Your contribution is a fantastic addition to the project, and we’re excited to review it with you! What You Did Well 🌟
Suggestions for Improvement 🛠️While your contribution is excellent, there are a few areas where we can align it better with the project’s conventions and ensure long-term maintainability:
Next Steps 🚀
Once you’ve made these updates, push your changes to this branch, and we’ll take another look. If you have any questions or need help with anything, don’t hesitate to ask — we’re here to help! Thank you again for contributing to the project. We’re excited to collaborate with you! 😊 |
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Review Summary
This PR introduces a new integration package, scopeblind-protect-mcp, which integrates the protect-mcp library into the Agent Governance Toolkit (AGT). The integration provides runtime Cedar policy enforcement and cryptographically verifiable decision receipts, enhancing the security and auditability of the AGT framework. The PR includes new components such as CedarPolicyBridge, ReceiptVerifier, SpendingGate, and scopeblind_context().
The implementation is well-documented, and the provided tests indicate a good level of coverage. However, there are several areas that require attention to ensure the robustness, security, and maintainability of the code.
🔴 CRITICAL
-
Receipt Verification Delegation
- The
ReceiptVerifierclass delegates cryptographic verification of Ed25519 signatures to external libraries (@veritasacta/verifyorprotect-mcpruntime). While this is acceptable, the absence of direct cryptographic verification in this library introduces a potential security risk if the external library has vulnerabilities or is compromised. - Action: Add a fallback mechanism to verify Ed25519 signatures directly within this library using a trusted Python cryptography library (e.g.,
pynacl). This ensures that the library can independently verify receipts if the external library is unavailable or untrusted.
- The
-
Trust Score Manipulation
- The
CedarPolicyBridgeadjusts the trust score based on Cedar decisions (trust_bonus_per_allowanddeny_penalty). This could lead to unintended consequences, such as trust scores being manipulated by malicious actors to bypass other security checks. - Action: Clearly document the rationale for modifying trust scores and consider adding safeguards to prevent abuse. For example, ensure that trust score adjustments are bounded and cannot be exploited by repeatedly triggering Cedar allow decisions.
- The
-
Receipt Hashing
- The receipt hash is calculated using
hashlib.sha256and truncated to 16 characters. This truncation significantly reduces the entropy of the hash, making it susceptible to collisions. - Action: Use the full hash value or a cryptographically secure truncation method (e.g., HMAC with a secret key) to prevent potential collision attacks.
- The receipt hash is calculated using
-
Receipt Validation
- The
validate_structuremethod inReceiptVerifieronly validates the structure of the receipt and does not perform cryptographic verification. This could lead to a false sense of security if developers assume the receipt is fully validated. - Action: Rename the method to
validate_structure_onlyor similar to make it clear that cryptographic validation is not performed. Additionally, provide explicit documentation about the need for external cryptographic verification.
- The
🟡 WARNING
-
Backward Compatibility
- The introduction of
scopeblind-protect-mcpdoes not appear to modify existing functionality in AGT. However, the integration of Cedar policies as "hard constraints" may impact existing workflows if users are not aware of the implications. - Action: Clearly document the impact of Cedar policy enforcement on existing AGT workflows. Provide migration guidance for users who may need to adapt their configurations to accommodate the new integration.
- The introduction of
-
Dependency Management
- The
protect-mcplibrary is a Node.js package, which introduces a cross-language dependency. This could complicate deployment and increase the risk of dependency-related issues. - Action: Ensure that the integration package includes clear instructions for installing and managing the
protect-mcpdependency. Consider providing a Docker container or other pre-configured environment to simplify deployment.
- The
💡 SUGGESTIONS
-
Type Annotations
- While the code includes some type annotations, they are not comprehensive. For example, the
evaluate_spendmethod inSpendingGatehas parameters without type annotations. - Action: Add type annotations to all methods and parameters to improve code clarity and enable static type checking.
- While the code includes some type annotations, they are not comprehensive. For example, the
-
Thread Safety
- The
CedarPolicyBridge,ReceiptVerifier, andSpendingGateclasses maintain internal state (e.g.,_history,_verified,_decisions) without any thread-safety mechanisms. This could lead to race conditions in concurrent environments. - Action: Use thread-safe data structures (e.g.,
queue.Queue) or add locks to ensure thread safety.
- The
-
Error Handling
- The code does not handle exceptions that may arise from external dependencies (e.g., JSON parsing, receipt validation). This could lead to unhandled exceptions in production.
- Action: Add error handling for external dependencies and provide meaningful error messages to help diagnose issues.
-
Test Coverage
- While the PR mentions 36 tests, it is unclear if they cover edge cases, such as malformed receipts, invalid signatures, or extreme trust score values.
- Action: Add tests for edge cases, including:
- Receipts with missing or invalid fields.
- Trust scores at the boundaries of
trust_floorandtrust_bonus. - Concurrent evaluations to test thread safety.
-
Documentation
- The documentation is comprehensive but could benefit from additional examples and diagrams to illustrate the integration between AGT and
protect-mcp. - Action: Add diagrams or flowcharts to the README to visually explain how
scopeblind-protect-mcpintegrates with AGT.
- The documentation is comprehensive but could benefit from additional examples and diagrams to illustrate the integration between AGT and
Final Assessment
This PR introduces a valuable integration that enhances the security and auditability of AGT. However, the identified critical issues must be addressed to ensure the robustness and security of the implementation. Additionally, addressing the warnings and suggestions will improve the maintainability and usability of the code.
🤖 AI Agent: security-scanner — Security Review of ScopeBlind protect-mcp IntegrationSecurity Review of ScopeBlind protect-mcp IntegrationThe proposed integration introduces runtime Cedar policy enforcement and cryptographically verifiable decision receipts into AgentMesh. While this is a significant enhancement to the security posture of the toolkit, it also introduces potential attack vectors. Below is a detailed security review based on the specified criteria. 1. Prompt Injection Defense BypassRating: 🔵 LOW The integration does not directly handle user input or natural language prompts, as it operates at the policy enforcement layer. However, the Recommendation: Ensure that all inputs to the 2. Policy Engine CircumventionRating: 🟠 HIGH The Attack Vector: An attacker could exploit a misconfigured Recommendation:
3. Trust Chain WeaknessesRating: 🔴 CRITICAL The integration relies on Ed25519-signed receipts for cryptographic proof, but the Attack Vector: If the external verifier is compromised or bypassed, invalid receipts could be accepted as valid, undermining the trust chain. Recommendation:
4. Credential ExposureRating: 🔵 LOW The integration does not handle sensitive credentials directly. Receipt verification and key management are delegated to the Recommendation: Ensure that debug logs and error messages do not inadvertently expose sensitive information, such as receipt contents or cryptographic keys. 5. Sandbox EscapeRating: 🔵 LOW The integration does not execute untrusted code or rely on sandboxing mechanisms. The Cedar policy evaluation is performed in a controlled WASM runtime, which is inherently sandboxed. Recommendation: Periodically review the WASM runtime for vulnerabilities and ensure it is updated to the latest secure version. 6. Deserialization AttacksRating: 🟡 MEDIUM The Attack Vector: A maliciously crafted receipt could exploit deserialization weaknesses to inject unexpected data or cause crashes. Recommendation:
7. Race ConditionsRating: 🟡 MEDIUM The Attack Vector: An attacker could exploit race conditions to manipulate evaluation history or verification logs, potentially bypassing policy enforcement. Recommendation:
8. Supply ChainRating: 🔴 CRITICAL The integration introduces a new dependency on Attack Vector: An attacker could compromise the Recommendation:
Additional Observations
Summary of Findings
Final RecommendationThis integration provides significant security benefits, but the critical issues related to trust chain weaknesses and supply chain risks must be addressed before merging. Additionally, safeguards against policy circumvention and deserialization attacks should be implemented to ensure robust security. |
|
@microsoft-github-policy-service agree company="ScopeBlind Pty Ltd" |
|
Thanks for the thorough review. Addressing each point: 🔴 CRITICAL responses:
🟡 WARNING responses:
💡 SUGGESTIONS: Will address type annotations, thread safety (adding Updated IETF draft ( |
…ty, edge case tests, full hash Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Follow-up commit addressing all code review items:
56 tests passing (36 original + 20 edge cases). |
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Code Review Feedback for feat: ScopeBlind protect-mcp integration
🔴 CRITICAL: Security Issues
-
Receipt Validation Delegation
- The
ReceiptVerifierclass delegates cryptographic signature verification to external tools (@veritasacta/verifyorprotect-mcp runtime). While this is acceptable for modularity, the absence of in-library cryptographic verification introduces a risk of bypass if the external verifier is misconfigured or compromised. - Recommendation: Add an optional fallback mechanism to perform Ed25519 signature verification directly within the library using a Python cryptography library (e.g.,
pynacl).
- The
-
Thread Safety in ReceiptVerifier
- The
_verifiedlist inReceiptVerifieris accessed and modified using a threading lock. However, the lock does not guarantee atomicity for complex operations like appending and reading. This could lead to race conditions in highly concurrent environments. - Recommendation: Use thread-safe data structures like
queue.Queueorcollections.dequewithmaxlenfor managing the_verifiedlog.
- The
-
SpendingGate Utilization Band Validation
- The
evaluate_spendmethod inSpendingGatedoes not validate theutilization_bandinput against theUTILIZATION_BANDSset. This could allow invalid or malicious inputs to bypass checks. - Recommendation: Add explicit validation for
utilization_bandto ensure it is one of the allowed values (low,medium,high,exceeded).
- The
-
CedarPolicyBridge Trust Adjustment
- The
CedarPolicyBridgeclass adjusts trust scores (trust_bonusanddeny_penalty) without bounds checking. This could lead to unintended behavior if the trust score exceeds the maximum (1000) or drops below zero. - Recommendation: Enforce bounds on
adjusted_trustto ensure it remains within[0, 1000].
- The
🟡 WARNING: Potential Breaking Changes
-
Hard Dependency on
protect-mcp- The integration assumes that
protect-mcpis always available and functioning correctly. Ifprotect-mcpintroduces breaking changes or is unavailable, this integration will fail. - Recommendation: Add version pinning for
protect-mcpin the documentation and provide fallback mechanisms or error handling for cases whereprotect-mcpis unavailable.
- The integration assumes that
-
Cedar Deny as Authoritative
- The design enforces that a Cedar
denydecision is final and cannot be overridden by trust scores. While this is a security feature, it could break workflows that rely on trust scores to override policy decisions. - Recommendation: Clearly document this behavior in the release notes and provide a configuration option to allow overrides if needed.
- The design enforces that a Cedar
💡 Suggestions for Improvement
-
Type Annotations
- While the code includes type hints, some areas lack full type coverage. For example, the
receiptparameter inReceiptVerifier.validate_structure_onlyis typed asDict[str, Any], but its structure is well-defined. - Recommendation: Use
TypedDictorPydanticmodels to define the expected structure of receipts for better type safety and validation.
- While the code includes type hints, some areas lack full type coverage. For example, the
-
Pydantic Model Validation
- The
CedarDecisionand other data structures could benefit from Pydantic models for validation and serialization. This would ensure stricter type safety and reduce the risk of malformed data. - Recommendation: Replace
dataclasswithPydanticmodels where applicable.
- The
-
Logging and Observability
- The library currently lacks logging for critical operations like receipt validation, Cedar policy evaluation, and spending gate decisions. This makes debugging and monitoring difficult.
- Recommendation: Add structured logging (e.g., using
structlog) for key operations to improve observability.
-
Unit Test Coverage
- While the PR mentions 36 tests, it is unclear if edge cases (e.g., malformed receipts, invalid utilization bands, extreme trust scores) are covered.
- Recommendation: Add tests for edge cases and failure scenarios to ensure robustness.
-
Backward Compatibility
- The integration introduces new components but does not modify existing ones. However, the reliance on
protect-mcpand the authoritative nature of Cedardenydecisions could indirectly affect existing workflows. - Recommendation: Provide a migration guide for users to adopt this integration without disrupting existing setups.
- The integration introduces new components but does not modify existing ones. However, the reliance on
-
Documentation
- The documentation is comprehensive but could benefit from additional examples, such as how to handle errors when
protect-mcpfails or how to configure theCedarPolicyBridgefor different trust models. - Recommendation: Expand the README with advanced usage examples and troubleshooting tips.
- The documentation is comprehensive but could benefit from additional examples, such as how to handle errors when
Summary of Feedback
| Category | Severity | Action |
|---|---|---|
| Security | 🔴 CRITICAL | Add in-library Ed25519 verification, thread-safe structures, and input validation. |
| Breaking Changes | 🟡 WARNING | Document Cedar deny behavior and dependency on protect-mcp. |
| Type Safety & Validation | 💡 SUGGESTION | Use Pydantic models and improve type annotations. |
| Observability | 💡 SUGGESTION | Add structured logging for critical operations. |
| Testing | 💡 SUGGESTION | Add edge case tests for malformed inputs and extreme scenarios. |
| Documentation | 💡 SUGGESTION | Expand README with advanced examples and troubleshooting. |
By addressing these issues, the integration will be more robust, secure, and user-friendly. Let me know if you need further clarification on any of the points!
|
@imran-siddique — all items from both code reviews are addressed in commit 9a3be8a. Quick summary:
The second code review re-flagged items that were fixed in the follow-up commit. 56 tests passing. Ready for human review when convenient. Happy to address any additional feedback. |
ScopeBlind protect-mcp Integration
Adds runtime Cedar policy enforcement and cryptographically verifiable decision receipts to AgentMesh, via protect-mcp (v0.4.6, MIT, 821KB).
What this PR adds
packages/agentmesh-integrations/scopeblind-protect-mcp/— a new integration package with:CedarPolicyBridgeevaluate()— Cedar deny is authoritativeReceiptVerifierSpendingGatescopeblind_context()Architecture — complementary to mcp-trust-proxy
AGT's
mcp-trust-proxygates on trust scores (soft signals). protect-mcp gates on Cedar policies (formal, deterministic, auditable). They compose:Cedar deny is a hard constraint — it cannot be overridden by a high trust score. Trust scoring is a soft signal layered on top of Cedar allow decisions.
Key differentiator: issuer-blind verification
protect-mcp receipts use VOPRF (RFC 9497) so the verifier can confirm a receipt is valid without learning which organization issued it. This prevents supply-chain surveillance — you can prove compliance without revealing your org structure.
AGT policy rule example
Tests
36 tests covering: Cedar decision parsing, policy bridge authorization (deny authoritative, trust layering, receipt requirements, trust cap), receipt validation (structure, types, spending authority, AGT context), spending gate (amount limits, categories, utilization bands, trust floors, receipt requirements), and context shape compatibility.
Protocol
Decision receipts follow the Veritas Acta signed receipt format, an IETF Internet-Draft for portable, verifiable decision artifacts.
protect-mcp: npm | GitHub | Docs | Cedar policies