Skip to content

feat: spot-check integrity verification for extension images#13

Merged
mobileoverlord merged 5 commits intomainfrom
rel/0.8.0
Mar 29, 2026
Merged

feat: spot-check integrity verification for extension images#13
mobileoverlord merged 5 commits intomainfrom
rel/0.8.0

Conversation

@mobileoverlord
Copy link
Copy Markdown
Contributor

Summary

  • Add fast head+tail spot-check hashing for extension images at merge time, catching on-disk corruption without a full SHA256
  • Spot check size is configurable via spot_check_bytes in avocadoctl.conf (default 4096)
  • Pre-flight integrity verification runs before activate/unmerge, preventing the system from tearing down working extensions when the target runtime's images are corrupt
  • When no spot hash cache exists, falls back to full SHA256 validation and generates the cache for future checks

Test plan

  • cargo fmt -- --check passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • All 243 tests pass
  • Manual test on qemux86-64: corrupt extension image, verify activate is rejected before unmerge, system stays healthy

Add integrity verification for extension images during runtime
staging and installation. Previously only file existence was checked,
allowing corrupted or partial images to pass validation silently.

- Add sha256 field to ManifestExtension (optional, backward-compatible)
- Add shared hash module with streaming SHA256 file hashing
- validate_manifest_images() now verifies hashes when present
- install_images_from_staging() verifies hashes after copy and for
  existing images
- OS bundle hash is now also verified during manifest validation
- Update varlink interface and service types to expose sha256 field
Display a short SHA256 prefix (12 chars) in the extension table and
full hashes in verbose mode, making it easy to verify that a runtime
includes hash-validated extensions.
Add a fast head+tail hash check that runs before merging extensions,
catching on-disk corruption without the cost of a full SHA256. The spot
hash covers file_size + first N bytes + last N bytes (configurable via
spot_check_bytes in avocadoctl.conf, default 4096). Spot hashes are
computed and cached in spot_hashes.json alongside the manifest during
staging, then verified at merge time.
Move the spot-check verification to run before switching the active
symlink and before unmerging extensions. This prevents tearing down a
working system (including sshd) only to discover the target runtime's
images are corrupt.

Also fall back to full SHA256 validation when no spot_hashes.json
exists, then generate and save the spot cache so future checks are
fast. This covers runtimes provisioned before the spot-check feature.
@mobileoverlord mobileoverlord merged commit f295c4d into main Mar 29, 2026
2 checks passed
@mobileoverlord mobileoverlord deleted the rel/0.8.0 branch March 29, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant