Skip to content

Commit 25749d0

Browse files
Reuvenruvnet
andcommitted
feat(rvm): security audit remediation, TEE cryptographic verification, performance hardening
Complete security audit remediation across all 14 RVM hypervisor crates: Security (87 findings fixed — 11 critical, 23 high, 30 medium, 23 low): - HAL: SPSR_EL2 sanitization before ERET, per-partition VMID with TLB flush, 2MB mapping alignment enforcement, UART TX timeout - Proof: Real P3 verification replacing stubs (Hash/Witness/ZK tiers), SecurityGate self-verifies P3 (no caller-trusted boolean) - Witness: SHA-256 chain hashing (ADR-142), strict signing default, NullSigner test-gated, XOR-fold hash truncation - IPC: Kernel-enforced sender identity, channel authorization - Cap: GRANT_ONCE consumption, delegation depth overflow protection, owner verification, derivation tree slot leak rollback - Types: PartitionId validation (reject 0/hypervisor, >4096) - WASM: Target/length validation on send(), module size limit, quota dedup - Scheduler: Binary heap run queue, epoch wrapping_add, SMP cpu_count enforcement - All integer overflow paths use wrapping_add/saturating_add/checked_add TEE implementation (ADR-142, all 4 phases): - Phase 1: SHA-256 replaces FNV-1a in witness chain, attestation, measured boot - Phase 2: WitnessSigner trait with SignatureError enum, HmacSha256WitnessSigner, Ed25519WitnessSigner (verify_strict), DualHmacSigner, constant_time.rs - Phase 3: SoftwareTeeProvider/Verifier, TeeWitnessSigner<P,V> pipeline - Phase 4: SignedSecurityGate, WitnessLog::signed_append, CryptoSignerAdapter, ProofEngine::verify_p3_signed, KeyBundle derivation infrastructure - subtle crate integration for ConstantTimeEq Performance (26 optimizations): - O(1) lookups: IPC channel, partition, coherence node, nonce replay - Binary max-heap scheduler queue (O(log n) enqueue/dequeue) - Coherence adjacency matrix + cached per-node weights - BuddyAllocator trailing_zeros bitmap scan + precomputed bit_offset LUT - Cache-line aligned SwitchContext (hot fields first) and PerCpuScheduler - DerivationTree O(1) parent_index, combined region overlap+free scan - #[inline] on 11+ hot-path functions, FNV-1a 8x loop unroll - CapSlot packing (generation sentinel), RunQueueEntry sentinel, MessageQueue bitmask Documentation: - ADR-142: TEE-Backed Cryptographic Verification (with 6 reviewer amendments) - ADR-135 addendum: P3 no longer deferred - ADR-132 addendum: DC-3 deferral resolved - ADR-134 addendum: SHA-256 + HMAC signatures 752 tests, 0 failures across 11 library crates + integration suite. Co-Authored-By: claude-flow <ruv@ruv.net>
1 parent 335d25c commit 25749d0

64 files changed

Lines changed: 6637 additions & 447 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎crates/rvm/Cargo.lock‎

Lines changed: 171 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/rvm/Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ rvm-kernel = { path = "crates/rvm-kernel" }
4545

4646
# External dependencies
4747
lz4_flex = { version = "0.11", default-features = false }
48+
hmac = { version = "0.12", default-features = false }
49+
sha2 = { version = "0.10", default-features = false }
50+
subtle = { version = "2.6", default-features = false }
4851
spin = { version = "0.9", default-features = false }
4952
bitflags = { version = "2", default-features = false }
5053

‎crates/rvm/README.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Layer 0: Machine Entry (assembly, <500 LoC)
165165
| `rvm-hal` | Platform-agnostic hardware abstraction traits (MMU, timer, interrupts) |
166166
| `rvm-cap` | Capability-based access control with derivation trees and three-tier proof |
167167
| `rvm-witness` | Append-only witness trail with hash-chain integrity |
168-
| `rvm-proof` | Proof-gated state transitions (P1/P2/P3 tiers) |
168+
| `rvm-proof` | Proof-gated state transitions (P1/P2/P3 tiers), TEE pipeline, cryptographic signers (Ed25519, HMAC-SHA256) |
169169
| `rvm-partition` | Partition lifecycle, split/merge, capability tables, communication edges |
170170
| `rvm-sched` | Coherence-weighted 2-signal scheduler (deadline urgency + cut pressure) |
171171
| `rvm-memory` | Guest physical address space management with tiered placement |
@@ -266,15 +266,15 @@ Run `cargo bench` for full criterion results with HTML reports.
266266
| `rvm-types` | ~40 types | 64-byte `WitnessRecord` (compile-time asserted), ~40 `ActionKind` variants, 34 error variants |
267267
| `rvm-hal` | 16 | AArch64 EL2: stage-2 page tables, PL011 UART, GICv2, ARM generic timer |
268268
| `rvm-cap` | 40 | Constant-time P1, nonce ring (4096 + watermark), P3 derivation chain verification, epoch revocation |
269-
| `rvm-witness` | 29 | FNV-1a hash chain, 16MB ring buffer, `StrictSigner`, RLE-compressed replay |
270-
| `rvm-proof` | 45 | Proof engine, context builder, constant-time P2 (all 6 rules), P3 chain delegation |
269+
| `rvm-witness` | 29 | SHA-256 hash chain (FNV-1a fallback), HMAC-SHA256 signing, 16MB ring buffer, `StrictSigner`, RLE-compressed replay |
270+
| `rvm-proof` | 45 | Proof engine, context builder, constant-time P2 (all 6 rules), P3 deep verification (SHA-256 + Merkle + WitnessSigner), TEE pipeline, Ed25519/HMAC-SHA256/DualHmac signers |
271271
| `rvm-partition` | 86 | Lifecycle state machine, IPC message queues, device leases, scored split/merge, `remove()` |
272272
| `rvm-sched` | 49 | 2-signal priority, SMP coordinator, VMID-aware switch, `SwitchContext::init()`, degraded fallback |
273273
| `rvm-memory` | 110 | Buddy allocator with coalescing, 4-tier management, LZ4-style RLE compression, reconstruction |
274274
| `rvm-coherence` | 59 | Unified coherence engine, pluggable MinCut/Coherence backends, edge decay, bridge to ruvector |
275275
| `rvm-boot` | 26 | 7-phase measured boot, attestation digest, HAL init, entry point |
276276
| `rvm-wasm` | 33 | 7-state agent lifecycle, `HostContext` trait, section parser (13 section types), migration |
277-
| `rvm-security` | 45 | Unified security gate (P1/P2/P3), input validation, attestation chain, DMA budget |
277+
| `rvm-security` | 45 | Unified security gate (P1/P2/P3), `SignedSecurityGate` with per-link signature verification, input validation, attestation chain, DMA budget |
278278
| `rvm-kernel` | 62 | Full integration: IPC→coherence, scheduler, split/merge, security gates, degraded mode, device leases, tier mgmt |
279279
| **Integration** | 48 | 17 e2e scenarios: agent lifecycle, split pressure, memory tiers, cap chain, boot timing |
280280
| **Benchmarks** | 21 | Criterion benchmarks for all performance-critical paths |
@@ -333,7 +333,7 @@ RVM explicitly rejects demand paging. Dormant memory is stored as `witness check
333333
Every state mutation requires a valid proof token verified through a three-tier system: P1 capability (<1µs), P2 policy (<100µs), P3 deep derivation chain verification (walks tree to root, validates ancestor integrity + epoch monotonicity).
334334

335335
### 4. Witness-Native OS
336-
Every privileged action emits a fixed 64-byte, FNV-1a hash-chained record. Tamper-evident by construction. Full deterministic replay from any checkpoint.
336+
Every privileged action emits a fixed 64-byte, SHA-256 hash-chained record with HMAC-SHA256 signatures. Tamper-evident by construction. Full deterministic replay from any checkpoint.
337337

338338
### 5. Live Partition Split/Merge
339339
Partitions split along graph-theoretic cut boundaries and merge when coherence rises. Capabilities follow ownership (DC-8), regions use weighted scoring (DC-9), merges require 7 preconditions (DC-11).
@@ -420,6 +420,7 @@ Capability-based isolation, proof-gated execution, and witness attestation on mi
420420
| ADR-139 | Appliance deployment model |
421421
| ADR-140 | Agent runtime adapter |
422422
| ADR-141 | Coherence engine kernel integration and runtime pipeline |
423+
| ADR-142 | TEE-backed cryptographic verification (SHA-256, Ed25519, HMAC-SHA256, TEE pipeline) |
423424

424425
</details>
425426

‎crates/rvm/benches/benches/rvm_bench.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ fn bench_security_gate(c: &mut Criterion) {
400400
required_type: CapType::Partition,
401401
required_rights: CapRights::READ,
402402
proof_commitment: None,
403+
require_p3: false,
404+
p3_chain_valid: false,
405+
p3_witness_data: None,
403406
action: ActionKind::PartitionCreate,
404407
target_object_id: 1,
405408
timestamp_ns: 1000,
@@ -425,6 +428,9 @@ fn bench_security_gate(c: &mut Criterion) {
425428
required_type: CapType::Region,
426429
required_rights: CapRights::WRITE,
427430
proof_commitment: Some(commitment),
431+
require_p3: false,
432+
p3_chain_valid: false,
433+
p3_witness_data: None,
428434
action: ActionKind::RegionCreate,
429435
target_object_id: 100,
430436
timestamp_ns: 5000,

‎crates/rvm/crates/rvm-boot/Cargo.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ rvm-partition = { workspace = true }
2020
rvm-witness = { workspace = true }
2121
rvm-sched = { workspace = true }
2222
rvm-memory = { workspace = true }
23+
sha2 = { workspace = true, optional = true }
24+
subtle = { workspace = true }
2325

2426
[features]
25-
default = []
27+
default = ["crypto-sha256"]
2628
std = [
2729
"rvm-types/std",
2830
"rvm-hal/std",
@@ -39,3 +41,4 @@ alloc = [
3941
"rvm-sched/alloc",
4042
"rvm-memory/alloc",
4143
]
44+
crypto-sha256 = ["sha2"]

0 commit comments

Comments
 (0)