feat: add ELF and MCUboot signing support with format abstraction (Phase 2)#55
Merged
feat: add ELF and MCUboot signing support with format abstraction (Phase 2)#55
Conversation
…ase 2) Introduce format-agnostic signing architecture and initial support for ELF binary and MCUboot firmware image signing. New modules: - format/mod.rs: FormatType enum, SignableArtifact trait, format detection with polyglot file validation (SC-15, AS-17) - format/elf.rs: ELF parser with section header consistency validation (SC-12), overlap detection (UCA-13), resource bounds (UCA-17), and full-file hashing (AS-14 defense) - format/mcuboot.rs: MCUboot parser with independent image size verification (SC-13, UCA-14, AS-15) CLI changes: - New --format flag on sign and verify subcommands (wasm|elf|mcuboot) - Format consistency validation (declared vs detected magic bytes) - ELF signing produces detached .sig file - MCUboot signing embeds signature in TLV trailer Architecture: - SignableArtifact trait: compute_hash, attach_signature, detach_signature, serialize, content_bytes — shared interface for all formats - Domain separation per format: "wasmsig", "elfsig", "mcubootsig" - Content type IDs: WASM=0x01, ELF=0x02, MCUboot=0x03 - Ed25519 signing core unchanged — format handlers only do parsing/hashing 26 new tests covering format detection, ELF parsing, MCUboot parsing, resource bounds, and section overlap validation. Implements: FEAT-2 Refs: SC-12, SC-13, SC-15, UCA-13, UCA-14, UCA-17, AS-14, AS-15, AS-17 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Complete the requirement → design → implementation → verification chain for ELF and MCUboot signing: Requirements: CR-12 (ELF section validation), CR-13 (MCUboot size verification), CR-14 (explicit format flag), CR-15 (resource bounds), CR-16 (domain-separated signing) Design: CD-13 (SignableArtifact trait), CD-14 (ELF module), CD-15 (MCUboot module), CD-16 (format detection) Implementation: CI-1 (format/mod.rs), CI-2 (format/elf.rs), CI-3 (format/mcuboot.rs) Verification: CV-12 (ELF tests), CV-13 (MCUboot tests), CV-14 (format detection tests), CV-15 (fuzz targets, draft) Total: 305 artifacts, 95.1% traceability coverage. Implements: FEAT-2 Refs: SC-12, SC-13, SC-15, CR-12, CR-13, CR-14, CR-15, CR-16 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t CLI Used rivet add/link/modify CLI commands to: - Create REQ-11 (ELF and MCUboot E2E test requirement) - Link REQ-3, REQ-4 to FEAT-2 (resolving orphan warnings) - Link REQ-11 to FEAT-2 Refs: FEAT-2, REQ-3, REQ-4, REQ-11 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Configure synth as a rivet external and add traces-to links from sigil's binary signing artifacts to synth's ELF backend and reproducibility requirements: sigil:SC-12 → synth:ARCH-003 (ELF section validation depends on ELF output) sigil:H-15 → synth:ARCH-003, synth:NFR-002 (transcoding hazard) sigil:L-7 → synth:L-6, synth:ARCH-003 (attestation chain continuity) sigil:SC-14 → synth:FR-002, synth:VER-001 (chain maintenance) sigil:DF-13 → synth:ARCH-003, synth:NFR-002 (attestation data flow) Reverse links added in synth repo: synth:ARCH-003 → sigil:CR-12, sigil:CD-14, sigil:FEAT-2 synth:NFR-002 → sigil:L-7, sigil:SC-14 Refs: FEAT-2, SC-12, SC-14, H-15, L-7, DF-13 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of the STPA-Sec implementation plan — extends sigil beyond WASM to sign ELF binaries and MCUboot firmware images.
New architecture
SignableArtifacttrait — format-agnostic interface:compute_hash,attach_signature,detach_signature,serializeFormatTypeenum —Wasm | Elf | Mcubootwith content type IDs, domain separation, and magic byte detectionELF signing (
format/elf.rs).sigfile) — proper ELF section embedding is future workMCUboot signing (
format/mcuboot.rs)ih_img_sizeheader (SC-13, UCA-14)CLI
Test plan
cargo test— 616 tests pass (26 new format tests)cargo build— clean compilation with#![forbid(unsafe_code)]🤖 Generated with Claude Code