Skip to content

R-5: Verify SHA-256 checksums on downloaded model files#146

Merged
TCVinNYC merged 2 commits into
mainfrom
feat/r5-model-checksums
Jul 3, 2026
Merged

R-5: Verify SHA-256 checksums on downloaded model files#146
TCVinNYC merged 2 commits into
mainfrom
feat/r5-model-checksums

Conversation

@TCVinNYC

@TCVinNYC TCVinNYC commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Model downloads had no integrity verification (security-audit finding); the updater already had the verified-secure pattern. Now every network-downloaded model verifies against a SHA256SUMS manifest published next to the assets:

  • Match → proceed. Mismatch → the file is deleted + ERROR through the existing detector-failure path.
  • Missing manifest or entry → WARNING ("legacy release without checksums") and proceed — hard-fail is deliberately deferred (R-10) until all published releases carry manifests.
  • Locally generated files (INT8 quantization, ultralytics exports) are structurally exempt; cached models never re-hash at launch (verification is inside _download_prebuilt only).
  • One shared helper: tools/fetch_models.py drives ModelManager, so both paths verify by construction; engine does not import updater code.

Test plan

  • 5 new RED-first tests (good sum kept / bad sum deleted+error / missing manifest warns / unlisted file warns / fetch_models path); manifest parser exercised against sha256sum text+binary formats, CRLF, comments, case.
  • Full suite green; ruff + mypy + selftest green. Review: Approved, no Critical/Important findings.

Release-process follow-up (not in this PR)

Publish SHA256SUMS next to the models-v1 assets at the next release cut — until then all releases take the legacy-warning path.

🤖 Generated with Claude Code

TCVinNYC and others added 2 commits July 3, 2026 14:24
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mirror the updater's checksum pattern for prebuilt model downloads:
fetch a SHA256SUMS manifest next to the model asset, verify the
digest before the temp file replaces the cached ONNX. A mismatch
deletes the download and logs an error (existing fallback to
ultralytics export applies); a missing manifest or missing entry
logs a warning and proceeds (legacy releases without checksums still
work; hard-fail is deferred). tools/fetch_models.py shares the same
ModelManager._download_prebuilt path, so no separate wiring needed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@TCVinNYC TCVinNYC merged commit bf9f32e into main Jul 3, 2026
3 checks passed
@TCVinNYC TCVinNYC deleted the feat/r5-model-checksums branch July 3, 2026 19:44
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