Skip to content

helper: recompute the handoff binding digest before admitting a package - #212

Draft
RyanTheTide wants to merge 4 commits into
mainfrom
sec/helper-binding
Draft

RyanTheTide wants to merge 4 commits into
mainfrom
sec/helper-binding

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem. When the helper imported a handoff package, it checked that manifest.json, request.json and identity.json agree with each other. For a job, it also compared the package's binding digest string with the ticket's. It never computed the binding digest itself, so that comparison did not cover the fields the digest stands for. Direct submit (Stage 1 update, retry) had no value from outside the package to compare with.

Change.

  • The binding-digest field list now lives in one function, CandidateBoundPlanIdentity.makeBindingDigest. The app uses it when it approves a plan, and the importer uses it when it imports a package, so the two cannot drift.
  • The importer recomputes the digest from the imported request and identity fields and refuses a mismatch (bindingMismatch). This covers new imports, reopened retained packages and the native stages' plan rebuild.
  • Direct submit now carries the approved binding digest next to the package directory, and the helper refuses a package that carries another one. App and helper ship in one bundle, so the XPC method changes on both sides together.

The digest definition is unchanged, so packages written by the current app, and retained ones, still validate.

Testing.

  • The importer fixtures now compute the binding digest by hand from their fields; before, they used a placeholder.
  • New tests cover:
    • a package that is consistent in all three files but carries the digest of other fields (payload, extent);
    • a changed catalog sequence, trust root or catalog digest;
    • a retained package in that state;
    • importer and app-side digests agreeing for one plan;
    • a direct submission without the approved digest.
  • macOS/test/all passes on Linux (portable checks only).

Still to run. The Swift build and XCTest in debug and release, plus swift-format lint, on macOS CI: the Swift was not compiled locally. Then an install row on a lab Mac.

Fields and format

Field order and the domain string are unchanged from InstallerIdentity.swift. plan_digest is bare hex; the other digests are sha256: strings; sequence, offset and length are decimal. The binding does not cover operation (tied to candidate_kind, which is covered) or the restore-image and recovery-template records, which the helper code-signature-checks before use.

The helper checked that manifest.json, request.json and identity.json of
a handoff package agree with each other, and compared the binding digest
in identity.json with the one in the job ticket. It never computed the
binding digest itself, so the comparison covered the digest string but
not the fields the digest stands for. A directly submitted package
(a Stage 1 update, or any submission without a job) had no value from
outside the package to compare with at all.

Compute the binding digest in the importer from the imported request
and identity fields and refuse the package with bindingMismatch when it
differs from the digest the package carries. This runs for new
packages, for retained packages that are reopened, and when the native
stages rebuild their plan from the retained control files. Packages the
app wrote keep working: the digest definition is unchanged.

The field list now lives in one function,
CandidateBoundPlanIdentity.makeBindingDigest, used by the app when it
approves a plan and by the helper when it imports one, so the two sides
cannot drift.

Direct submission now carries the approved binding digest as well:
PreparedEngineHandoff records it, the XPC submit call sends it next to
the package directory, and the helper refuses an imported package that
carries another digest before anything runs. The app and its helper
ship together, so the XPC method changes on both sides at once.

Tests: the package fixtures compute the binding digest from their
fields instead of using a placeholder. New tests cover a package that
is consistent in all three control files but carries the binding digest
of other fields (changed payload, changed extent), a changed catalog
sequence, trust root or catalog digest in identity.json, a retained
package in the same state, agreement between the importer and the
app-side identity for the same plan, and a direct submission whose
package does not carry the approved digest.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 769ef18.

Read at 769ef18. The recomputation is right: field order and domain string match the app (InstallerIdentity.swift:113-131), the app writes request.json/identity.json from the same plan and catalog identity it hashes (ClosedEngineHandoffProcess.swift:418-432,464-472), operation, engine_version and required_human_steps are fixed through candidate_kind and plan_digest, control files are read once by fd and never re-read from the caller's directory, and every mismatch fails closed and removes the import. The digest is not a secret, so plain == is fine. Not approving yet because of 1.

  1. Proof owed at this head: the Swift has not been compiled (body says so) and all three checks are still pending. Before merge: macOS checks green (debug + release XCTest), then on a lab Mac a fresh install (job path), a Stage 1 update (direct submit), and a Recovery retry of a package retained by the previous build, since reopenRetained and the native stages' boundPlan now refuse where they did not before (EngineHandoffPackageImporter.swift:131,306).
  2. Coverage: restore_image and recovery_template stay outside the binding (EngineHandoffPackageImporter.swift:241-254, nothing in :757-779). The signature check that covers them accepts any build with the right identifier and team (RestoreImageHelper.swift:72-84; cdhash only for ad hoc), so whoever can replace the package directory between the app writing it and the helper reading it can still hand root an older signed decoder or Recovery template. The app already has both digests in memory (ClosedEngineHandoffProcess.swift:147-158); sending them next to bindingDigest would close this without changing the digest definition.
  3. Scope of the direct-submit check: digest and package arrive from the same caller in one call (ClosedEngineHelperServer.swift:938-970), and the helper only format-checks trust_root_fingerprint / catalog_sequence (EngineHandoffPackageImporter.swift:707-709). So it stops an on-disk swap, not a client replaying an older package with its own digest. Please say that in the doc comment at ClosedEngineHelperServer.swift:466; a catalog-sequence floor in the helper would be the real fix and can be a follow-up.
  4. Nit: the direct-submit comparison runs after prepare has cloned/copied and hashed every artifact (ClosedEngineHelperServer.swift:531-548). Passing the expected digest into prepare lets it refuse right after the control files are read (EngineHandoffPackageImporter.swift:187).

…d test

ClosedEngineHelperServer.submit takes the binding digest since the
previous commit; the rejected-password test refuses before any package
is read, so any well-formed digest serves.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 5947401.

This adds the new bindingDigest: argument to the rejected-password test, so the test compiles against the new submit signature. It still pins the order that matters: the catch asserts .invalidMachineOwnerCredentials, not a digest error, and executor.calls == 0. So an all-zero digest can't let the test pass for the wrong reason. If someone later moved the digest check ahead of credential validation, this test would fail.

Point 1 from 769ef18 still stands: all three checks are pending at this head, and the lab rows (fresh install, Stage 1 update via submit, Recovery return) are owed. Code verdict unchanged: approve once macOS checks are green and the rows are in.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Formal §1–§6 pre-PR checklist review at 5947401462db23b008abac660a23515e2625281a:

Consolidating the binding digest into CandidateBoundPlanIdentity.makeBindingDigest and recomputing it inside EngineHandoffPackageImporter.validateBindings (covering prepare, reopenRetained, and boundPlan) cleanly binds the approved digest to every covered request/identity field without changing the on-disk digest definition. Commit 5947401462 also fixes the NativeStage1UpdateTests.swift:461 compile failure that broke macOS checks at 769ef18ee3.

Checklist summary:

  • §1 No model gating: Pass.
  • §2 Production-ready, no hacks: Pass.
  • §3 Safety: Core recomputation is sound (see non-blocking hardening suggestions below).
  • §4 Clean-room & attribution: Pass (both commits carry human author/committer Ryan Murray <ryan@aurorasilicon.org>, human Signed-off-by: only, zero AI trailers in commits; PR body includes Assisted-by: disclosure).
  • §5 Evidence: Incomplete (see Blockers #1 and #2 below).
  • §6 Naming: Pass.

CI verification at 5947401462:

  • Portable checks: QUEUED
  • macOS checks: QUEUED (failed compilation at previous head 769ef18ee3 on NativeStage1UpdateTests.swift:461; awaiting green debug + release XCTest on 5947401462)
  • Conformance matrix: QUEUED (note: repo-wide aura branch-pin drift tracked in #196; at 769ef18ee3 job 137434922132 failed solely on that pin drift)

Blockers before merge

  1. CI not yet green on 5947401462: Portable checks and macOS checks (debug + release XCTest + swift-format lint) are still QUEUED after the compile fix and must pass SUCCESS.
  2. §5 hardware evidence open on a non-draft PR (Still to run): No lab-Mac run has been recorded yet covering:
    • a fresh install (startJob ticket admission),
    • a Stage 1 update (direct submit with bindingDigest), and
    • a Recovery retry of a package retained by a previous build (reopenRetained and boundPlan now reject mismatched recomputed digests).
      Per the pre-PR checklist, either complete and record these rows or convert the PR to draft until they are run.

Non-blocking hardening notes

  • Fail before artifact cloning/hashing on direct submit (ClosedEngineHelperServer.swift:523-544): Currently importer.prepare(...) clones/copies and SHA-256-hashes multi-GB payload artifacts before case .bindingDigest(let approved) checks package.bindingDigest == approved. Passing an optional expectedBindingDigest: String? = nil into importer.prepare(...) allows immediate rejection right after control-file validation (EngineHandoffPackageImporter.swift:187).
  • Document direct-submit trust boundary (ClosedEngineHelperServer.swift:466): Because packageDirectory and bindingDigest arrive from the same XPC caller and the helper only format-checks trust_root_fingerprint / catalog_sequence, direct submit prevents an on-disk swap after approval rather than a replaying client supplying a self-consistent older package + digest. Note that scope in the doc comment (and consider a helper-side catalog-sequence floor as a follow-up).
  • restore_image and recovery_template digest pinning: Both remain outside makeBindingDigest, and for non-ad-hoc signed builds their code-signature checks accept any build matching identifier + team. Passing their expected digests alongside bindingDigest (without changing the digest format) would close swap-to-older-signed-binary attacks as well.

Assisted-by: LLM (Gemini 4 Neon)

A direct submission's approved binding digest is now passed to the
importer, which compares it with the package's right after reading the
control files, so a package carrying another digest is refused before
any artifact is cloned and hashed. The comparison after the import stays
for the job path, whose digest is in the ticket.

Document what the direct-submit check covers: digest and package come
from the same caller, so it fixes the package to what that caller
approved and stops the directory from changing afterwards; it does not
stop that caller from submitting an older self-consistent package with
its own digest.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Since 5947401:

  • macOS checks are green at 5947401 (debug and release XCTest).
  • New commit: a direct submission's approved digest is checked inside prepare right after the control files are read, so a mismatched package is refused before any artifact is cloned or hashed. There is a new importer test for the refusal (nothing imported) and the matching case.
  • The doc comment on submit now says what the check covers: the caller and digest arrive together, so it stops on-disk changes after approval, not a caller replaying an older self-consistent package with its own digest. A helper-side catalog-sequence floor would be the follow-up for that.
  • restore_image/recovery_template digests stay outside the binding (code-signature checked; team-wide for signed builds). Closing that needs the app to send their digests with the call, so I'm leaving it as a follow-up rather than growing this PR.

This PR is now a draft until the lab rows are in: fresh install (job path), Stage 1 update (direct submit), and a Recovery retry of a package retained by the previous build.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 4667fee.

Earlier points:

  1. Proof: still open. The PR is now a draft, which is the right state. macOS checks were green at 5947401, but all checks are pending again at 4667fee. Still owed, by Ryan: a fresh install on a lab Mac (job path), a Stage 1 update (direct submit), and a Recovery retry of a package retained by the previous build.
  2. restore_image/recovery_template outside the binding: deferred to a follow-up, as stated. That's fine, but please open the follow-up issue so it isn't lost.
  3. Direct-submit scope: fixed. The doc comment at ClosedEngineHelperServer.swift:466-472 now says the check stops on-disk changes, not a caller replaying an older self-consistent package. The catalog-sequence floor is left as a follow-up, same request as in 2.
  4. Early refusal: fixed. prepare(..., expectedBindingDigest:) compares the digest right after validateBindings (EngineHandoffPackageImporter.swift:196). By then identity.bindingDigest has been checked against the recomputed value, and no artifact has been cloned yet. The new test asserts .bindingMismatch with an empty destination, plus the matching case.

New code: the post-import comparison at ClosedEngineHelperServer.swift:560 is now redundant for .bindingDigest. It's harmless defense in depth. The job path still pays for the full import before jobs.admitted rejects a mismatch. It could pass the ticket's digest early too, but that's a nit for later. The let ... = switch expression needs Swift 5.9. CI at 5947401 already builds that toolchain, so I expect no issue, but the macOS checks at this head will confirm it.

Verdict: APPROVE on code. Merge waits on green checks at 4667fee and the three lab rows above (Ryan). It also needs to come out of draft.

…TS.md

Aurora agent policy: remove assistant instruction files that are not
policy copies, and sync AGENTS.md, CLAUDE.md, GEMINI.md and
.github/copilot-instructions.md to .github/aurora/AGENTS.md on main.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge at 0cbf2e77fe9f: only the lab Mac runs are left, then mark it ready for review.

Blockers: none.

Rows before merging: On a lab Mac at the final head: a fresh install (job path), a Stage 1 update (direct submit with the binding digest), and a Recovery retry of a package retained by the previous build. The retry is needed because reopenRetained and boundPlan now refuse packages they used to accept.

Checked: The helper recomputes the binding digest from the package's own fields in validateBindings (EngineHandoffPackageImporter.swift:764-793). That check covers prepare, reopenRetained and boundPlan. A direct submit with another digest is now refused before any artifact is copied (EngineHandoffPackageImporter.swift:196-198, ClosedEngineHelperServer.swift:536-544). The doc comment says what the check does not cover (ClosedEngineHelperServer.swift:465-471). macOS checks and Portable checks passed at 4667fee4. Conformance failed there only on the Aura branch pin and the synthetic profiles, the same failure main had then; main passes now. The only commit after it removes macOS/AGENTS.md, which main has already removed.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 26, 2026 11:57

Superseded by the review at 0cbf2e7

This branch has not been deployed

No deployments
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.

2 participants