Skip to content

fix(deps): adopt v0.6.8 digest-verification backport for runtime downloads - #54

Closed
ya-luotao wants to merge 3 commits into
mainfrom
core-digest-backport
Closed

fix(deps): adopt v0.6.8 digest-verification backport for runtime downloads#54
ya-luotao wants to merge 3 commits into
mainfrom
core-digest-backport

Conversation

@ya-luotao

@ya-luotao ya-luotao commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

The pinned v0.6.8 core downloads release binaries with no integrity check on any of the gem's three download paths — the prebuilt build-time installer for the msb bundle (sdk build.rs), the first-use runtime installer behind ensure_runtime!, and the prebuilt agentd guest-agent download embedded by the filesystem crate's build script. Upstream superradcompany/microsandbox#1300 adds fail-closed SHA-256 verification for the first two, but it is unmerged and based past v0.6.8 (8+ commits of unrelated API drift), and does not cover the agentd path at all.

This PR therefore moves the microsandbox / microsandbox-network git deps to the ya-luotao/microsandbox fork's v0.6.8-digest-backport branch (rev 32b8b98e) — exactly v0.6.8 plus the two digest-verification commits from #1300 cherry-picked (byte-identical diff, zero conflicts), plus two commits extending the same fail-closed verification to the agentd prebuilt download — including re-hashing cached OUT_DIR bytes against the published digest before reuse, and failing on a non-UTF-8 MSB_AGENTD_SHA256 pin (the release's checksums.sha256 publishes agentd-<arch> entries; an externally supplied local build/agentd can be pinned with MSB_AGENTD_SHA256). Temporary pin: switch back to the official upstream tag once equivalent verification ships in a release.

  • ext/microsandbox/Cargo.toml — rev-pin both git deps to the fork; features unchanged; TEMPORARY comment documents the v0.6.8 base and exit condition.
  • spec/unit/version_spec.rb — the RUNTIME_VERSION guard parses both dependency declarations exactly and accepts only two shapes: both deps tag-pinned to the official repo at RUNTIME_VERSION, or both rev-pinned to the approved fork URL + approved rev recorded in the spec. Mixed pin kinds/sources fail.
  • lib/microsandbox/version.rb — RUNTIME_VERSION doc comment describes the actual rev-pin and guard semantics.
  • CHANGELOG.md — Unreleased entry.
  • Cargo.lock — rebuilt from main's lock with only the microsandbox git sources rewritten plus the filesystem crate's new hex/sha2 build-deps; no unrelated resolution churn.

No Ruby API change. Microsandbox::RUNTIME_VERSION stays "v0.6.8".

Verification

  • bundle exec rspec spec/unit: 370 examples, 0 failures.
  • cargo clippy --manifest-path ext/microsandbox/Cargo.toml -- -D warnings, cargo fmt --check, bundle exec standardrb, cargo metadata --locked: all clean.
  • bundle exec rake compile with a fresh MSB_HOME: build.rs download + digest verification exercised for real — msb 0.6.8 + libkrunfw installed after verification against the release's checksums.sha256.
  • agentd path exercised both ways: clean-cache download + verify succeeds; a wrong MSB_AGENTD_SHA256 digest fails the build (fail-closed observed live, as do transient checksums-fetch failures).

Unpin checklist (when equivalent verification lands in a release tag)

  1. ext/microsandbox/Cargo.toml: back to tag = "vX.Y.Z" on superradcompany/microsandbox; drop the TEMPORARY comment.
  2. spec/unit/version_spec.rb: drop approved_backport and the rev branch of the guard.
  3. lib/microsandbox/version.rb: restore the tag-pin wording of the RUNTIME_VERSION comment.
  4. CHANGELOG.md: fold the Unreleased entry into the release notes.
  5. Only then may the fork's v0.6.8-digest-backport branch be deleted — the rev must stay reachable until every consumer is off it.

🤖 Generated with Claude Code

https://claude.ai/code/session_0191N1iCiTVVFsUpmHGKZBH1

…loads

The pinned v0.6.8 core downloads the msb + libkrunfw release bundle
with no integrity check on either unverified path — the `prebuilt`
build-time installer in the sdk build.rs and the first-use runtime
installer behind ensure_runtime!. Upstream #1300 adds fail-closed
SHA-256 verification against the release's checksums.sha256 asset but
is unmerged and based past v0.6.8, so the git deps move to the
ya-luotao fork's `v0.6.8-digest-backport` rev — v0.6.8 plus the two
digest-verification commits cherry-picked — until #1300 ships in an
upstream release tag. The version_spec runtime-pin guard learns the
temporary rev-pin shape (both deps share one rev, the Cargo.toml
comment records the v0.6.8 base) so the tag guard can't silently rot.
No Ruby API change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0191N1iCiTVVFsUpmHGKZBH1

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ef4451793

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread spec/unit/version_spec.rb Outdated
tags = cargo.scan(/^microsandbox(?:-network)?\s*=\s*\{[^}]*\btag\s*=\s*"([^"]+)"/).flatten
expect(tags).not_to be_empty
expect(tags.uniq).to eq([Microsandbox::RUNTIME_VERSION])
if tags.empty?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject mixed tag/revision dependency pins

When only one dependency is switched back to an official tag while the other remains on the fork revision, tags.empty? is false, so this branch validates the single tag and completely ignores the remaining rev. The test therefore passes even though microsandbox and microsandbox-network come from different sources, defeating the stated guard during the documented unpin workflow; require exactly two tags and no revisions in this branch.

Useful? React with 👍 / 👎.

ya-luotao and others added 2 commits August 13, 2026 02:14
Review of the backport adoption surfaced four gaps. The fork branch
gains a commit closing the remaining unverified download — the prebuilt
build script for the embedded agentd guest binary — so the pin moves
13c422fd -> 3b9995e7 (appended, no history rewrite; the release's
checksums.sha256 does publish agentd-<arch> entries). The version_spec
pin guard now parses both dependency declarations exactly and accepts
only two shapes — official repo + tag equal to RUNTIME_VERSION, or the
approved fork URL + approved rev recorded in the spec — rejecting the
mixed pin kinds and sources it previously let through. The Cargo.lock
is rebuilt from main's with only the microsandbox git sources rewritten
(plus the filesystem crate's new hex/sha2 build-deps), dropping the
eleven unrelated windows-sys edge upgrades the earlier cargo update
dragged in. RUNTIME_VERSION's doc comment now describes the actual
rev-pin and guard semantics instead of the pre-backport tag pin.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0191N1iCiTVVFsUpmHGKZBH1
… version

Re-review round two. The fork branch gains a commit hardening the
agentd verification edge cases (cached OUT_DIR bytes re-hashed against
the published digest before reuse, local artifact read once and the
verified buffer embedded, non-UTF-8 MSB_AGENTD_SHA256 fails instead of
silently skipping verification), so the pin moves 3b9995e7 -> 32b8b98e
(appended, no history rewrite). The version_spec pin guard previously
never tied the approved rev to RUNTIME_VERSION — bumping the constant
alone passed all specs; the approved-backport record now carries the
base release it vouches for and the rev branch asserts it equals
RUNTIME_VERSION.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0191N1iCiTVVFsUpmHGKZBH1
@ya-luotao

Copy link
Copy Markdown
Owner Author

Closing as superseded. Status as of main @ 0.15.0 (runtime v0.6.14):

  • This PR's fork-pin is based on v0.6.8 and now conflicts with main, which has since moved through v0.6.9 → v0.6.14 on official upstream tags. Re-doing the backport per upstream tag (5 tags in one week) is not sustainable.
  • The primary exposure is now mitigated downstream: the 0.14.0 two-gem split ships msb + libkrunfw + agentd via microsandbox-rb-binaries, vendored fail-closed against the checksums committed in binaries/checksums/<tag>.sha256 — nothing unverified is ever packaged, and users with the binaries gem installed never hit the runtime auto-download.
  • Upstream fix(sdk): verify runtime bundle digest on download by default superradcompany/microsandbox#1300 (default digest verification) remains open. Verified at v0.6.14: sdk/rust/build.rs (build-time prebuilt bundle) and crates/filesystem/build.rs (agentd) still download with no hash check; setup/download.rs gained expected_bundle_sha256 but only the CLI self upgrade/downgrade supplies a digest — the SDK install path passes None.

Residual gaps (tracked, not addressed here): the compile-from-source build.rs download when MSB_HOME is empty, and first-use auto-install for users without the binaries gem. Both resolve properly once #1300 (or equivalent) lands in an upstream release.

The fork branch ya-luotao/microsandbox@v0.6.8-digest-backport is no longer referenced by any consumer and may be deleted.

@ya-luotao ya-luotao closed this Aug 24, 2026
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