Skip to content

improve(mac): guard elevation signing identity against drift - #123764

Merged
steipete merged 1 commit into
mainfrom
steipete/mac-elevation-host-immutable-write
Aug 14, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/mac-elevation-host-immutable-write

Conversation

@steipete

@steipete steipete commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Related: #123675

What Problem This Solves

The elevation host asserts the same signing identity in two places, and nothing keeps them in sync.

scripts/mac-elevation-host.sh ships as the portable installer that #123675 added to the artifact set, so it is deliberately self-contained and cannot source shared constants. That forces it to carry its own copies of the Developer ID team identifier and authority string, duplicating ELEVATION_TEAM_ID / ELEVATION_IDENTITY in scripts/codesign-mac-app.sh. If one side is ever rotated without the other, packaging still succeeds and the divergence only surfaces on a target Mac, as an install-time rejection of an artifact that was signed correctly.

The same neighborhood has a second trap. verify_elevation_signature() (sign time) and verify_elevation_app() (post-notarization and install time) assert overlapping invariants, and the overlap reads like redundancy. It is not: the second requires an already notarized and stapled bundle, so it cannot run at sign time. Deleting the first as "duplicate" would silently defer every elevation identity failure until after an Apple notarization submission has been spent.

Why This Change Was Made

A test now reads both scripts and asserts the team identifier and full authority string agree, with a failure message naming the portable-installer reason so the next reader understands why the duplication is intentional rather than deleting one copy. Each of the two verification functions gets a short comment stating which boundary it owns and what breaks if it is removed.

Deduplicating the constants themselves was considered and rejected: sourcing a shared file would break the self-contained contract that makes the installer portable, which is the whole point of #123675. Guarding the duplication is the cheaper correct answer.

A write_immutable_output helper collapsing the repeated tmp / chmod 444 / mv idiom in package_host() was also built and then dropped. It did not pay rent — it cost more production lines than it saved — and the natural pipe form regressed failure handling: because cat succeeds on EOF, a failing jq would still have been chmod'd and mv'd into place, leaving an empty but real-looking receipt at the canonical path and tripping the immutable elevation output already exists guard on every later run. The existing explicit form is fail-closed and stays.

User Impact

No user-visible or operator-visible behavior change. No artifact bytes, filenames, modes, receipt fields, signing, notarization, or install behavior are touched. Maintainers get a build-time failure instead of a target-Mac failure if the two signing-identity copies ever drift.

Evidence

Production diff is six comment lines; the rest is test coverage.

$ git diff --numstat
3	0	scripts/codesign-mac-app.sh
3	0	scripts/mac-elevation-host.sh
19	0	test/scripts/mac-elevation-host.test.ts

The guard fails on drift. Flipping EXPECTED_TEAM_ID to DRIFTEDTEAM in the portable installer:

× keeps portable signing identity aligned with the signer
AssertionError: mac-elevation-host.sh is a self-contained portable installer, so its
duplicated signing constants must match codesign-mac-app.sh
- Expected
+ Received
[
-   "DRIFTEDTEAM",
+   "FWJYW4S8P8",
    "Developer ID Application: OpenClaw Foundation (FWJYW4S8P8)",
]
Test Files  1 failed (1)

Restored, both suites pass:

$ node scripts/run-vitest.mjs test/scripts/mac-elevation-host.test.ts test/scripts/codesign-mac-app.test.ts
 Test Files  2 passed (2)
      Tests  22 passed (22)
[test] passed 1 Vitest shard in 4.91s

git diff --check clean. The rejected pipe refactor was verified as a real regression before dropping it, rather than assumed:

--- NEW (pipe into helper) ---   script exit=17
  -r--r--r--  receipt.json              <- canonical path created, empty
--- OLD (direct redirect) ---   script exit=17
  -rw-r--r--  receipt.json.tmp.24718    <- canonical path never created

CI history

Two earlier runs went red on breakage this branch did not cause and does not touch: a dead CLI wrapper in src/cli/skills-cli.ts failing check-prod-types and check-lint-core, and src/gateway/server-maintenance.test.ts crossing the 1000 counted-line test cap. Both were repaired on main by #123794 (3289e08c3005515fb8e49379fd18951ef2530507), and this branch is rebased onto that fix. This PR touches zero files under src/.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 14, 2026 17:20
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 3:15 PM ET / 19:15 UTC.

ClawSweeper review

What this changes

Adds comments clarifying sign-time versus post-notarization elevation checks and a test that keeps the portable installer’s signing identity constants aligned with the macOS signer.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main has the portable installer but not this drift guard; the exact-head patch is focused and correct, with no actionable findings. Merge remains for maintainer judgment after queued exact-head checks finish.

Priority: P3
Reviewed head: 7afd78da7b68a7d1965dc693e63035b850c7d7ce
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-backed preventive patch with clear validation evidence and no correctness findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored preventive test/comment PR is exempt from the external-contributor real-behavior-proof gate; its body includes focused terminal evidence for the guard.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored preventive test/comment PR is exempt from the external-contributor real-behavior-proof gate; its body includes focused terminal evidence for the guard.
Evidence reviewed 5 items Current-main gap: The base revision has matching duplicated signing constants but no cross-script alignment test or rationale comments; the PR adds the guard rather than duplicating an existing main behavior.
Owner-boundary trace: The signer invokes its sign-time check after signing, while the installer verifies the bundled app’s identity, notarization, stapling, and assessment after packaging or archive extraction; keeping both checks is supported by the current call paths.
Installer verification boundary: The portable installer defines its own expected identity and uses it in post-notarization verification before install/recovery proceeds.
Findings None None.
Security None None.

How this fits together

macOS packaging signs a privileged elevation app, then ships a self-contained installer which re-verifies the notarized app on the target Mac. The test prevents the two intentionally duplicated signing identities from diverging silently.

flowchart LR
A[Signing identity] --> B[macOS signing script]
B --> C[Signed elevation app]
C --> D[Portable installer]
D --> E[Notarized app verification]
F[Identity-drift test] --> B
F --> D
Loading

Decision needed

Question Recommendation
Should this maintainer-owned preventive guard merge after the queued exact-head checks pass? Merge after exact-head checks: Accept the focused drift guard once the queued checks for commit 7afd78d are green.

Why: The PR carries the protected maintainer label and is authored by a repository member, so automated cleanup must not close or merge it.

Before merge

  • Resolve merge risk (P1) - Queued exact-head checks must complete successfully before merge; the supplied status is not yet a green exact-head gate.
Agent review details

Security

None.

PR surface

Tests +19, Other +6. Total +25 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 19 0 +19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 6 0 +6
Total 3 25 0 +25

Review metrics

Metric Value Why it matters
Production vs test delta production +6 comments, tests +19 The production changes only preserve rationale at two non-obvious verification boundaries; the executable safeguard is the focused test.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the focused cross-script invariant test and both verification boundaries, then merge once the exact-head checks confirm the rebased branch.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the focused cross-script invariant test and both verification boundaries, then merge once the exact-head checks confirm the rebased branch.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR prevents future identity drift rather than repairing a currently reproducible user failure; the PR body supplies a focused failing-on-drift test transcript.

Is this the best way to solve the issue?

Yes. A cross-script invariant test is the smallest maintainable guard because the installer must remain self-contained while both scripts intentionally own the same signing identity.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3289e08c3005.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P3: This is low-risk preventive packaging maintenance with no current user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored preventive test/comment PR is exempt from the external-contributor real-behavior-proof gate; its body includes focused terminal evidence for the guard.

Evidence

What I checked:

  • Current-main gap: The base revision has matching duplicated signing constants but no cross-script alignment test or rationale comments; the PR adds the guard rather than duplicating an existing main behavior. (test/scripts/mac-elevation-host.test.ts:233, 7afd78da7b68)
  • Owner-boundary trace: The signer invokes its sign-time check after signing, while the installer verifies the bundled app’s identity, notarization, stapling, and assessment after packaging or archive extraction; keeping both checks is supported by the current call paths. (scripts/codesign-mac-app.sh:409, 7afd78da7b68)
  • Installer verification boundary: The portable installer defines its own expected identity and uses it in post-notarization verification before install/recovery proceeds. (scripts/mac-elevation-host.sh:183, 7afd78da7b68)
  • Feature provenance: The related merged portable-installer work dates to this commit; this PR is a distinct follow-up guard, not a replacement for it. (scripts/mac-elevation-host.sh:8, 493a3e46b3f2)
  • Exact-head scope: The exact head is directly based on the supplied main SHA and changes only six production comment lines plus nineteen test lines; the diff check is clean. (scripts/mac-elevation-host.sh:169, 7afd78da7b68)

Likely related people:

  • steipete: Authored the related merged portable-installer implementation and this focused follow-up on the same signing and installer boundary. (role: feature owner and recent area contributor; confidence: high; commits: 493a3e46b3f2, 7afd78da7b68; files: scripts/mac-elevation-host.sh, scripts/codesign-mac-app.sh, test/scripts/mac-elevation-host.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for queued exact-head checks before merging.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-08-14T17:27:16.887Z sha 9508b56 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T17:49:33.287Z sha 9508b56 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T18:20:56.963Z sha 9508b56 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T18:44:11.231Z sha 9b277eb4eeb3e463678d457c04eb17269bad5d08 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as draft August 14, 2026 17:43
@steipete
steipete marked this pull request as ready for review August 14, 2026 17:43
@steipete steipete closed this Aug 14, 2026
@steipete steipete reopened this Aug 14, 2026
@steipete
steipete force-pushed the steipete/mac-elevation-host-immutable-write branch from 9508b56 to 9b277eb Compare August 14, 2026 18:36
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 14, 2026
@steipete steipete self-assigned this Aug 14, 2026
scripts/mac-elevation-host.sh ships as the portable installer added in
#123675, so it is deliberately self-contained and cannot source shared
constants. That forces it to duplicate ELEVATION_TEAM_ID and
ELEVATION_IDENTITY from scripts/codesign-mac-app.sh, with nothing keeping
the two copies in sync. Add a test asserting they agree, so rotation drift
fails at build time instead of on a target Mac.

Also document why the sign-time and install-time elevation verification
functions both exist: verify_elevation_app requires a notarized and stapled
bundle, so it cannot replace the sign-time check, and deleting that check
would defer every identity failure until after a notarization submission is
already spent.

No behavior change: no artifact bytes, filenames, modes, receipt fields,
signing, notarization, or install paths are touched.
@steipete
steipete force-pushed the steipete/mac-elevation-host-immutable-write branch from 31c0084 to 7afd78d Compare August 14, 2026 19:10
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 14, 2026
@steipete
steipete merged commit 3744af3 into main Aug 14, 2026
160 of 162 checks passed
@steipete
steipete deleted the steipete/mac-elevation-host-immutable-write branch August 14, 2026 19:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
…w#123764)

scripts/mac-elevation-host.sh ships as the portable installer added in
openclaw#123675, so it is deliberately self-contained and cannot source shared
constants. That forces it to duplicate ELEVATION_TEAM_ID and
ELEVATION_IDENTITY from scripts/codesign-mac-app.sh, with nothing keeping
the two copies in sync. Add a test asserting they agree, so rotation drift
fails at build time instead of on a target Mac.

Also document why the sign-time and install-time elevation verification
functions both exist: verify_elevation_app requires a notarized and stapled
bundle, so it cannot replace the sign-time check, and deleting that check
would defer every identity failure until after a notarization submission is
already spent.

No behavior change: no artifact bytes, filenames, modes, receipt fields,
signing, notarization, or install paths are touched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant