feat(examples): physical-attestation-governed — cold chain sensor receipts#1168
Conversation
…eipts Adds a governed example for physical-world sensor events, extending the receipt format from microsoft#667 and microsoft#1159 (software agent tool calls) to hardware attestation from a cold chain sensor device. Developed as part of an active hardware R&D program (Australian ETCF grant application, TRL 4→6) for a dedicated cold chain attestation sensor. The device specification predates this contribution — sharing here because the physical AI governance gap identified in microsoft#787 is exactly the problem we're solving at the hardware level. 8 scenarios: 1. Cold Chain Journey (Barossa Valley → Tokyo, 12 readings) 2. Temperature Excursion Blocks Release (22.4°C → deny) 3. Shock Event Creates Alert (8.7g → alert) 4. Receipt Tamper Detection (field edit → signature invalid) 5. Chain Integrity Verification (hash links intact) 6. Multi-Sensor Correlation (compound temp+shock+lux event) 7. Offline Verification (all receipts verified, no network) 8. Device Identity Attestation (boot receipt with firmware hash) The receipt envelope format is identical to software agent receipts from microsoft#1159. Same verifier (npx @veritasacta/verify), same chain structure, same JCS canonicalization. One proof layer for both software agents and physical devices. Hardware spec: SHT40 + LIS2DH12 + L76K + VEML7700 + ATECC608B. BOM target: $14.50 at volume. Related: microsoft#787 (physical AI OWASP gap), microsoft#667 (protect-mcp integration), Signed-off-by: tommylauren <tfarley@utexas.edu> microsoft#1159 (software governed example).
|
Welcome to the Agent Governance Toolkit! Thanks for your first pull request. |
🤖 AI Agent: security-scanner — Security Review of PR: feat(examples): physical-attestation-governed — cold chain sensor receiptsSecurity Review of PR: feat(examples): physical-attestation-governed — cold chain sensor receiptsThis PR introduces physical-world hardware attestation for cold chain sensors, extending the governance framework to physical sensor readings. Below is a detailed security analysis based on the critical areas outlined: 1. Prompt Injection Defense BypassRating: 🔵 LOW Recommendation: 2. Policy Engine CircumventionRating: 🟠 HIGH
Attack Vector: Recommendation:
3. Trust Chain WeaknessesRating: 🔴 CRITICAL
Attack Vector: Recommendation:
4. Credential ExposureRating: 🟠 HIGH Attack Vector: Recommendation:
5. Sandbox EscapeRating: 🔵 LOW Recommendation: 6. Deserialization AttacksRating: 🟡 MEDIUM Attack Vector: Recommendation:
7. Race ConditionsRating: 🔵 LOW Recommendation: 8. Supply ChainRating: 🟡 MEDIUM Attack Vector: Recommendation:
Summary of Findings
Recommendations for Fixes
Final NotesThis PR introduces valuable functionality for physical-world AI governance but contains critical security weaknesses that must be addressed before deployment. |
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Pull Request Review for feat(examples): physical-attestation-governed — cold chain sensor receipts
🔴 CRITICAL: Security Issues
-
Insecure Signature Algorithm for Demonstration
- The use of
SHA-256 HMACfor signing receipts in the demonstration is insecure and could lead to a false sense of security. While the PR mentions that production devices will useEd25519from the ATECC608B secure element, the demonstration code should also use a secure algorithm (e.g., Ed25519) to prevent misuse or misinterpretation of the example code. - Recommendation: Replace the HMAC-based signing with a secure Ed25519 implementation, even for demonstration purposes. If this is not feasible, include prominent warnings in the documentation and code comments to clarify that this is for demonstration only and should not be used in production.
- The use of
-
Tamper Detection Vulnerability
- The
SensorReceipt.verify()method relies onhmac.compare_digestto validate the signature. However, thepayloadfield is mutable, and there is no mechanism to ensure the integrity of thepayloadfield itself. An attacker could modify thepayloadand re-sign it with the same key, effectively bypassing the tamper detection. - Recommendation: Use a cryptographic signature scheme like Ed25519 that binds the signature to the payload. This ensures that any modification to the payload invalidates the signature, even if the attacker has access to the signing key.
- The
-
Lack of Secure Key Management
- The
DEMO_KEYis hardcoded in the example ("a" * 64), which is insecure and could lead to accidental misuse in production. - Recommendation: Use a secure key management solution or environment variables to handle keys, even in demonstration code. At a minimum, include a warning in the code and documentation about the risks of hardcoding keys.
- The
-
No Replay Protection
- The receipt format does not include a mechanism to prevent replay attacks. An attacker could reuse a valid receipt to falsely claim compliance.
- Recommendation: Include a nonce or timestamp in the receipt payload and ensure that the verifier checks for uniqueness or freshness of the receipt.
-
Policy Evaluation Logic
- The policy evaluation logic is implemented in Python, but the production system is expected to use Cedar policies. This discrepancy could lead to inconsistencies between the demonstration and production environments.
- Recommendation: Use a Cedar policy engine (e.g.,
py-cedar) in the demonstration code to ensure consistency with the production environment.
🟡 WARNING: Potential Breaking Changes
- Backward Compatibility of Receipt Format
- The receipt format introduced here (
draft-farley-acta-signed-receipts-01) must be backward-compatible with the existing software agent receipt format from PRs #667 and #1159. Any changes to the format could break existing verifiers. - Recommendation: Add explicit tests to ensure that the receipt format remains compatible with the software agent receipts. Include tests for both software and hardware receipts in the same test suite.
- The receipt format introduced here (
💡 Suggestions for Improvement
-
Thread Safety
- The
SensorReceiptChainclass uses a mutable list (self.receipts) and a mutable counter (self._sequence) without any thread-safety mechanisms. If this class is used in a multi-threaded environment, it could lead to race conditions. - Recommendation: Use thread-safe constructs like
threading.Lockorconcurrent.futuresto ensure thread safety when accessing or modifying shared state.
- The
-
Type Safety
- While the code uses type hints, there are no runtime checks to validate the structure of
SensorReadingorSensorReceiptobjects. - Recommendation: Use
Pydanticmodels to enforce type safety and validate the structure of these objects at runtime.
- While the code uses type hints, there are no runtime checks to validate the structure of
-
Policy Evaluation Logging
- The
evaluate_policyfunction does not log the evaluation process, which could make debugging difficult in production. - Recommendation: Add structured logging to capture policy evaluation decisions, including the input parameters and the resulting decision.
- The
-
Error Handling
- The code lacks robust error handling. For example, if the
evaluate_policyfunction encounters an unexpected input, it may raise an unhandled exception. - Recommendation: Add error handling and validation for inputs to ensure the system fails gracefully.
- The code lacks robust error handling. For example, if the
-
Documentation
- While the PR includes a detailed README, it would benefit from a more explicit warning about the use of insecure signing in the demonstration code.
- Recommendation: Add a bold, highlighted warning at the top of the README and in the code comments to emphasize that the HMAC-based signing is for demonstration purposes only and should not be used in production.
-
Test Coverage
- The PR includes 8 scenarios, but there is no mention of automated tests for these scenarios.
- Recommendation: Integrate these scenarios into the
pytesttest suite to ensure they are automatically tested in the CI/CD pipeline.
-
Use of Constants
- The
COLD_CHAIN_POLICYis hardcoded in the script, which makes it difficult to modify or extend. - Recommendation: Load the policy from an external YAML or JSON file (e.g.,
cold-chain-policy.yaml) to make it easier to update and manage.
- The
-
Code Organization
- The
getting_started.pyscript is quite long (576 lines) and combines multiple concerns (e.g., signing, simulation, policy evaluation, and scenarios). - Recommendation: Refactor the script into smaller, reusable modules. For example:
signing.pyfor signing and verification logic.policy.pyfor policy evaluation logic.simulator.pyfor the sensor simulation.scenarios.pyfor the scenario definitions.
- The
-
Future Considerations: SPIFFE/SVID
- The PR does not mention the use of SPIFFE/SVID for device identity attestation, which could be a valuable addition for secure device authentication.
- Recommendation: Consider integrating SPIFFE/SVID for device identity attestation in future iterations.
-
Testing Edge Cases
- The scenarios do not appear to test edge cases, such as boundary values for temperature, shock, and light.
- Recommendation: Add tests for edge cases (e.g., temperature exactly at 18.0°C, shock exactly at 5.0g) to ensure the policy engine behaves as expected.
Summary
- Strengths: The PR provides a well-documented and comprehensive example of extending the receipt format to physical-world hardware attestation. The scenarios are realistic and align with the project's goals of addressing physical AI governance gaps.
- Critical Issues: Insecure signing algorithm, lack of replay protection, and mutable payloads that could allow tampering.
- Warnings: Potential backward compatibility issues with the receipt format.
- Suggestions: Improve thread safety, type safety, error handling, and code organization. Add automated tests for scenarios and edge cases. Consider future integration with SPIFFE/SVID for device identity attestation.
Action Items
- 🔴 Replace HMAC with Ed25519 for signing, or add prominent warnings about the demonstration-only nature of the current implementation.
- 🔴 Implement a mechanism to ensure the integrity of the
payloadfield inSensorReceipt. - 🔴 Add replay protection to the receipt format.
- 🟡 Ensure backward compatibility with existing receipt formats.
- 💡 Refactor the code for better modularity and maintainability.
- 💡 Add automated tests for all scenarios and edge cases.
- 💡 Use Pydantic models for type safety and validation.
- 💡 Add structured logging to the policy evaluation process.
Let me know if you need further clarification or assistance!
Teaches the decision-receipt layer that sits between internal audit logs (Tutorial 04) and artifact signing (Tutorial 26): per tool-call Ed25519 signatures over JCS-canonical payloads, hash-chained across the session, verifiable offline by any party with the public key. Mirrors the existing `examples/protect-mcp-governed/` (PR microsoft#1159) and `examples/physical-attestation-governed/` (PR microsoft#1168) reference code, uses their exact APIs, and cross-references Tutorials 01, 04, 07, 08, 12, 26, and 27. Adds two entries to docs/tutorials/README.md: - Supply Chain Security section (alongside 25, 26, 27) - "Enterprise compliance" learning path step 6 Standards covered: RFC 8032 (Ed25519), RFC 8785 (JCS), Cedar (AWS), IETF draft-farley-acta-signed-receipts.
* docs: add Tutorial 33 — Offline-Verifiable Decision Receipts Teaches the decision-receipt layer that sits between internal audit logs (Tutorial 04) and artifact signing (Tutorial 26): per tool-call Ed25519 signatures over JCS-canonical payloads, hash-chained across the session, verifiable offline by any party with the public key. Mirrors the existing `examples/protect-mcp-governed/` (PR #1159) and `examples/physical-attestation-governed/` (PR #1168) reference code, uses their exact APIs, and cross-references Tutorials 01, 04, 07, 08, 12, 26, and 27. Adds two entries to docs/tutorials/README.md: - Supply Chain Security section (alongside 25, 26, 27) - "Enterprise compliance" learning path step 6 Standards covered: RFC 8032 (Ed25519), RFC 8785 (JCS), Cedar (AWS), IETF draft-farley-acta-signed-receipts. * docs: strengthen Tutorial 33 with SLSA integration and anchoring primitives Four additions landing after the initial PR: 1. Receipt Lifecycle ASCII diagram in "The Receipt Format" section. Visualizes mint → JCS canonical → Ed25519 sign → store → verify so readers can see why the determinism invariant holds. 2. A real Cedar policy block in §4 (Composing with Cedar Policies). Previously the section described the CedarDecision API shape without showing what a policy producing one actually looks like. Now shows a 10-line permit/forbid policy and links out to cedar-for-agents for the full schema generator. 3. Neutral anchoring primitives subsection in §6 (Cross-Implementation). Names Sigstore Rekor and in-toto attestations as the cross-org verification fabric beyond the four implementations. References sigstore/rekor#2798 and in-toto/attestation#549. 4. New §7 "Emitting Receipts as SLSA Provenance". When an AI agent is itself the builder, the receipt chain IS the per-step build log. Shows the exact byproducts JSON shape for carrying a receipt chain inside a SLSA provenance v1 attestation, referencing the draft agent-commit build type at refs.arewm.com/agent-commit/v0.1 and the active slsa-framework/slsa#1594 and #1606 discussions. No new dependencies. All APIs still verified against the merged examples/protect-mcp-governed/ and examples/physical-attestation-governed/ reference code. * docs(tutorial-33): add sidebar on operator-signed vs authority-chain modes Per @aeoess review on #1197: the four implementations listed in the cross-implementation section make different identity-binding choices that matter for deployment selection. This sidebar names them explicitly so readers evaluating receipts for their environment can pick the right mode. - Operator-signed mode (protect-mcp, protect-mcp-adk, sb-runtime): sufficient for internal audit, single-regulator evidence, single- tenant compliance. The signer is the operator's supervisor hook. - Authority-chain-referenced mode (asqav / APS governance hook): additionally required for cross-org agent commerce, multi-tenant regulated environments, and use cases where principal authority is itself auditable. Receipts reference a delegation-chain root. Both modes verify against @veritasacta/verify and use the same outer receipt structure; the distinction is the presence of an optional delegation_chain_root field in the payload. Cross-references arewm/refs.arewm.com#1 for the parallel authority- chain attestation proposal as a SLSA byproduct. --------- Co-authored-by: tommylauren <tfarley@utexas.edu>
Adds docs/integrations/sb-runtime.md mirroring the openshell.md structure. Positions sb-runtime as a Veritas Acta-conformant runtime backend that combines Cedar policy evaluation, Landlock + seccomp sandboxing, and Ed25519-signed decision receipts in a single binary. Covers: - When sb-runtime is the right pick (build-vs-buy tradeoffs vs OpenShell, nono) - Architecture with request flow - Both in-process Python shim and standalone binary setup paths - Ring 2 vs Ring 3 semantics against the same binary - Cedar policy example - Policy layering example with allow/deny receipt flow - Field mapping from AGT primitives to sb-runtime equivalents - Veritas Acta receipt format reference (cross-links Tutorial 33) - Monitoring metrics compatible with AGT's OpenTelemetry patterns - FAQ covering OpenShell/nono relationships, multi-OS story, offline verification, open-source status, key rotation - Related links including IETF draft, reference verifier, integration profile repo No code changes, no new API surface; anchors on the already-merged examples/protect-mcp-governed/ (PR microsoft#1159), examples/physical-attestation-governed/ (PR microsoft#1168), and Tutorial 33 (PR microsoft#1197). Part of the three-PR sequence proposed on microsoft#748: 1. This PR: integration doc 2. Provider shim in packages/agent-runtime/ 3. Worked example in examples/sb-runtime-governed/
…lementation) (#1202) * docs: Integration guide for sb-runtime (Ring 2/3 backend) Adds docs/integrations/sb-runtime.md mirroring the openshell.md structure. Positions sb-runtime as a Veritas Acta-conformant runtime backend that combines Cedar policy evaluation, Landlock + seccomp sandboxing, and Ed25519-signed decision receipts in a single binary. Covers: - When sb-runtime is the right pick (build-vs-buy tradeoffs vs OpenShell, nono) - Architecture with request flow - Both in-process Python shim and standalone binary setup paths - Ring 2 vs Ring 3 semantics against the same binary - Cedar policy example - Policy layering example with allow/deny receipt flow - Field mapping from AGT primitives to sb-runtime equivalents - Veritas Acta receipt format reference (cross-links Tutorial 33) - Monitoring metrics compatible with AGT's OpenTelemetry patterns - FAQ covering OpenShell/nono relationships, multi-OS story, offline verification, open-source status, key rotation - Related links including IETF draft, reference verifier, integration profile repo No code changes, no new API surface; anchors on the already-merged examples/protect-mcp-governed/ (PR #1159), examples/physical-attestation-governed/ (PR #1168), and Tutorial 33 (PR #1197). Part of the three-PR sequence proposed on #748: 1. This PR: integration doc 2. Provider shim in packages/agent-runtime/ 3. Worked example in examples/sb-runtime-governed/ * docs: Reframe sb-runtime as a Veritas Acta receipt format implementation Positions the Veritas Acta receipt format as the interoperable artifact and sb-runtime as one of several AGT-compatible signers. Adds explicit guidance for operators who want nono as the Linux sandbox primitive: run sb-runtime in --ring 2 mode inside a nono capability set and let nono own the sandbox layer. Changes: - Title and intro lead with "Veritas Acta receipt format implementation" rather than "Ring 2/3 governance backend". The longer-lived object is the receipt format, not the specific signer. - New section 'sb-runtime's role in the Veritas Acta receipt model' enumerates sb-runtime / nono / OpenShell as peer paths, with routing guidance for each. - New section 'Composing sb-runtime with nono' documents the recommended Linux composition: nono for sandbox, sb-runtime --ring 2 for Cedar + receipts. Includes the architecture diagram and operator steps. - FAQ 'What about nono?' rewritten to position nono as the recommended Linux sandbox primitive for Veritas Acta deployments, not a competitor. - Policy Layering Example updated to name nono explicitly. No changes to the signed receipt format, the receipt store, or the verification path. @veritasacta/verify accepts Ring 2 receipts produced under any sandbox layer; the sandbox choice is not part of the receipt's trust boundary. --------- Co-authored-by: tommylauren <tfarley@utexas.edu>
Summary
Extends the receipt format from #667 and #1159 to physical-world hardware attestation. Demonstrates Ed25519-signed receipts from a cold chain sensor device — every temperature, shock, GPS, and light reading is policy-evaluated and signed using the same receipt envelope format as software agent tool calls.
This work comes from an active hardware R&D program (Australian ETCF grant application, TRL 4→6) for a dedicated cold chain attestation sensor. The device specification predates this contribution — we're sharing it here because the physical AI governance gap identified in #787 is exactly the problem we're solving at the hardware level.
Connection to #787
@pshkv's SINT Protocol enforces `maxVelocityMps` and `maxForceNewtons` inline for robotic actuators. Our sensor enforces `temperature_c < 18.0` and `shock_g < 5.0` inline for supply chain shipments. Both produce signed receipts verifiable with the same offline CLI. Same governance pattern, different physical domain.
@imran-siddique noted on #787: "contributions welcome — especially from teams working at the intersection of robotics and agentic AI." Cold chain attestation is a simpler, lower-risk entry point to the same class of physical AI governance primitives.
What's included
```
examples/physical-attestation-governed/
├── README.md
├── getting_started.py # 8 scenarios, 722 lines
└── policies/
└── cold-chain-policy.yaml # Cedar-equivalent rules
```
8 scenarios
Hardware spec (simulated)
BOM target: $14.50 at volume (10K units).
Key property: receipt format is identical
The same receipt envelope works for both software agents and physical sensors:
```
Software: protect-mcp signs tool call → { payload, signature } → @veritasacta/verify
Hardware: ATECC608B signs sensor reading → { payload, signature } → @veritasacta/verify
```
Same JCS canonicalization (RFC 8785). Same chain structure (`previousReceiptHash`). Same verifier. Same exit codes. One proof layer for both domains.
Testing
```bash
python examples/physical-attestation-governed/getting_started.py
8 scenarios completed
12 journey receipts signed and chain-linked
All verified, all tamper attempts detected
```
Zero dependencies beyond Python 3.10+.
Relationship to existing work
Design decisions
Happy to iterate. This is meant to show that the receipt format from #667/#1159 scales to physical devices without any protocol changes.