Skip to content

fix(macos): sign with any valid certificate when no Apple-class identity is installed - #119008

Closed
harjothkhara wants to merge 1 commit into
openclaw:mainfrom
harjothkhara:claude/elated-pike-32879f
Closed

harjothkhara wants to merge 1 commit into
openclaw:mainfrom
harjothkhara:claude/elated-pike-32879f

Conversation

@harjothkhara

@harjothkhara harjothkhara commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Related: #118989, #119019

What Problem This Solves

OpenClaw documents a four-tier macOS signing selection order: Developer ID Application, Apple Distribution, Apple Development, then the first other valid codesigning identity. The fallback parser never selected the fourth tier, and restart-mac.sh independently used an Apple-class-only predicate.

The historical PR also accepted any quoted security find-identity row. That is unsafe because macOS can quote an identity while marking it unusable, for example (CSSMERR_TP_NOT_TRUSTED).

Current-Main Change

Rebuilt as one commit on current main.

  • The existing shared owner, scripts/lib/mac-signing-identity.sh, now parses the complete security find-identity -p codesigning -v output once.
  • It preserves the documented ranking:
    1. Developer ID Application
    2. Apple Distribution
    3. Apple Development
    4. first other valid identity
  • Rows carrying a Keychain status suffix after the quoted identity are rejected.
  • Usable output is retained even if security exits nonzero.
  • restart-mac.sh now delegates signing-key detection to that same selector, eliminating policy drift.

Evidence

Current exact-head focused checks:

  • tooling tests: 45 passed, 61 platform-skipped
  • signer regression rejects CSSMERR_TP_NOT_TRUSTED rows
  • restart auto-detection rejects the same invalid row
  • valid non-Apple fallback is accepted by both paths
  • ranked Apple-class preference is preserved
  • usable output with a nonzero security status is preserved
  • direct exact-file oxlint: passed
  • oxfmt --check: passed
  • bash -n: passed for the shared owner and both entry points
  • git diff --check: passed
  • exact GitHub tree matched the tested local tree before publication

The repository's type-aware lint wrapper exceeded this 3.7 GiB host's compiled-boundary budget before producing a source diagnostic; GitHub Actions is the authoritative full integration/type-aware run.

Remaining External Decision / Proof

This patch does not decide the product policy. Maintainers still need to choose whether auto-selection should accept every identity macOS reports as valid, or only Apple-class identities.

If the documented fourth tier is retained, final native proof requires a macOS machine with an already-trusted non-Apple codesigning identity. This Linux VPS cannot fabricate that Keychain trust result. The committed synthetic regressions cover the parser and both entry points without treating invalid rows as valid.

AI-assisted; implementation and evidence reviewed before publication.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S labels Aug 3, 2026
@harjothkhara
harjothkhara marked this pull request as ready for review August 3, 2026 23:44
@harjothkhara

Copy link
Copy Markdown
Contributor Author

CI is red on macos-swift and openclaw/ci-gate. Both look unrelated to this change.

openclaw/ci-gate is not an independent failure — it is the aggregate gate, and it fails only because a required job did not succeed. That leaves macos-swift as the single root failure.

macos-swift has the shape of a slow-runner timing flake rather than a regression:

  • The clearest signature is BoundedProcessTests.swift:32 — Expectation failed: (ContinuousClock.now - startedAt → 3.014584083 seconds) < (.seconds(2) → 2.0 seconds). That is a wall-clock budget missed by roughly 50%.
  • The failing suite set differs across all three swift test retry attempts within the same job. BoundedProcessTests records 2 issues on one attempt and 3 on another, and BoundedCommandTests, DashboardWindowSmokeTests, RemoteGatewayProbeTests, MacNodeModeCoordinatorTests, PortGuardianRecordStoreTests, and RemotePortTunnelTests drift in and out between attempts. The final attempt reports 1611 tests across 178 suites with 6 issues.

Nondeterminism across retries points at the runner rather than the diff. Every failing suite is macOS app runtime behavior — process bounding, window smoke, gateway probing, port tunnels — and none of them touch code signing.

This PR changes only scripts/codesign-mac-app.sh and test/scripts/codesign-mac-app.test.ts. There are no Swift sources in the diff and nothing that feeds swift test; codesign-mac-app.sh runs at packaging time, after the Swift build, and the Swift test job never invokes it.

Every other check is green, including Real behavior proof — 75 pass, 24 skipped.

I cannot re-run these jobs from a fork PR. A maintainer re-run would confirm the flake reading; happy to rebase onto a newer main instead if that is easier.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 27, 2026, 7:38 PM ET / 23:38 UTC (Revision 9).

ClawSweeper review

What this changes

The PR changes macOS app packaging and restart to share a certificate selector that ranks Apple identities, accepts other valid Keychain identities, and rejects rows marked unusable.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 7 items remain

Current main still has the nonworking fourth signing tier, so this PR remains useful. The new commit fixes the prior invalid-Keychain-row finding, but its broader automatic selection can turn a previously successful ad-hoc restart into a signing failure. The signing policy needs a maintainer decision and native proof.

Priority: P1
Reviewed head: 6fb6962a5663148118e46b795a46f9685c4c0f27
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused parser repair has useful coverage, but the default-path regression and absent native signing proof prevent merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The changed shared selector feeds real Mac packaging and restart, but the submitted after-fix checks use a fake security listing and do not show a trusted non-Apple certificate completing native codesign and the Team ID audit. A redacted native terminal trace or recording should show that path; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The changed shared selector feeds real Mac packaging and restart, but the submitted after-fix checks use a fake security listing and do not show a trusted non-Apple certificate completing native codesign and the Team ID audit. A redacted native terminal trace or recording should show that path; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Introduced selection change: The pinned PR delta replaces the dead fallback with a ranked parser and makes restart use that selector.
Prior finding addressed: The new parser excludes a quoted identity when text such as CSSMERR_TP_NOT_TRUSTED follows its closing quote.
Restart behavior: A selected identity sends automatic restart down the signed path; no selected identity sends it down the ad-hoc path.
Findings 1 actionable finding [P1] Preserve restart behavior for non-Apple keychains
Security Needs attention Implicit use of an unrelated signing certificate: A valid non-Apple Keychain identity can now be selected without an explicit SIGN_IDENTITY, changing which certificate signs the resulting app bundle.

How this fits together

Mac packaging reads Keychain identities to choose a certificate before signing and auditing an app bundle. The restart script uses that choice to decide whether to package a signed app or use ad-hoc signing.

flowchart LR
  A[Keychain identities] --> B[Shared identity selector]
  B --> C{Identity selected?}
  C -->|Yes| D[Mac app signer]
  C -->|No| E[Ad-hoc restart path]
  D --> F[Signature and Team ID audit]
  F --> G[Packaged app]
Loading

Decision needed

Question Recommendation
Should macOS packaging and restart automatically select a non-Apple Keychain identity, or require operators to name it with SIGN_IDENTITY? Require explicit non-Apple selection: Keep Apple-class automatic selection, preserve explicit non-Apple signing, and correct the signing documentation.

Why: The documented fourth tier never worked on current main, while enabling it changes the default certificate and can make existing ad-hoc restart setups fail.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The changed shared selector feeds real Mac packaging and restart, but the submitted after-fix checks use a fake security listing and do not show a trusted non-Apple certificate completing native codesign and the Team ID audit. A redacted native terminal trace or recording should show that path; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve restart behavior for non-Apple keychains (P1) - With only a valid non-Apple certificate, this now returns success, so default restart enters the signed path instead of the previously working ad-hoc path. A certificate without a TeamIdentifier then fails the downstream audit. Keep that certificate explicit unless native proof establishes a safe automatic path.
  • Resolve security concern: Implicit use of an unrelated signing certificate - A valid non-Apple Keychain identity can now be selected without an explicit SIGN_IDENTITY, changing which certificate signs the resulting app bundle.
  • Resolve merge risk (P1) - On a keychain containing only a valid non-Apple certificate without a Team ID, automatic restart now chooses signing instead of its previous ad-hoc path, and the downstream audit can fail the rebuild.
  • Resolve merge risk (P1) - Automatic selection can use a valid certificate the operator did not intend; maintainers have not settled whether non-Apple identities should require explicit selection.
  • Complete next step (P2) - Resolve the non-Apple automatic-selection policy, repair the restart compatibility regression, and provide redacted native signing proof before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Preserve restart behavior for non-Apple keychains — scripts/restart-mac.sh:96
  • [medium] Implicit use of an unrelated signing certificate — scripts/lib/mac-signing-identity.sh:14
Agent review details

Security

Needs attention: The patch broadens implicit certificate selection for app signing before maintainers have accepted that default.

PR surface

Tests +108, Other -11. Total +97 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 109 1 +108
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 28 39 -11
Total 4 137 40 +97

Review metrics

Metric Value Why it matters
Automatic signing eligibility 3 Apple classes → any valid listed identity This changes the default signing path for existing non-Apple keychains.
Production and test delta production -11 lines, tests +108 lines The added coverage exercises selection with a fake Keychain listing, leaving native signing behavior unproved.

Merge-risk options

Maintainer options:

  1. Preserve the existing restart default (recommended)
    Limit automatic restart selection to Apple-class identities and leave other certificates available through explicit SIGN_IDENTITY.
  2. Accept broader automatic signing
    Choose the broader policy only with a native before-and-after signing capture that shows the completed app and audit outcome.

Technical review

Best possible solution:

Keep automatic restart on the proven Apple identity classes and let operators explicitly select a non-Apple certificate; align the signing guide with that policy and validate any broader default through native signing and Team ID audit.

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

Yes at the source-path level: current main's malformed fallback cannot select a non-Apple identity, and the proposed restart branch can be traced to the Team ID audit. There is no native before-and-after signing run for this head.

Is this the best way to solve the issue?

No. Sharing the selector fixes policy drift and rejects marked-invalid rows, but broadening the automatic default before resolving Team ID behavior is not yet a safe end-to-end repair.

Full review comments:

  • [P1] Preserve restart behavior for non-Apple keychains — scripts/restart-mac.sh:96
    With only a valid non-Apple certificate, this now returns success, so default restart enters the signed path instead of the previously working ad-hoc path. A certificate without a TeamIdentifier then fails the downstream audit. Keep that certificate explicit unless native proof establishes a safe automatic path.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b90999ac8dbd.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: An existing macOS restart workflow can fail after this default signing-path change.
  • merge-risk: 🚨 compatibility: A non-Apple keychain changes from ad-hoc restart to automatic signing without an operator setting.
  • merge-risk: 🚨 security-boundary: Automatic signing may choose a valid certificate the operator did not intend to use.
  • merge-risk: 🚨 availability: A selected non-Apple certificate without a Team ID can make packaging fail its signature audit.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed shared selector feeds real Mac packaging and restart, but the submitted after-fix checks use a fake security listing and do not show a trusted non-Apple certificate completing native codesign and the Team ID audit. A redacted native terminal trace or recording should show that path; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Implicit use of an unrelated signing certificate — scripts/lib/mac-signing-identity.sh:14
    A valid non-Apple Keychain identity can now be selected without an explicit SIGN_IDENTITY, changing which certificate signs the resulting app bundle.
    Confidence: 0.88

What I checked:

Likely related people:

  • Dallin Romney: Raw commit 6b799dc adds scripts/lib/mac-signing-identity.sh:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6b799dc6ad7f; files: scripts/lib/mac-signing-identity.sh)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Resolve the automatic non-Apple signing policy and preserve a working restart path for existing keychains.
  • Provide redacted native signing output for the chosen path, including the final signature and Team ID audit result.

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 (8 earlier review cycles)
  • reviewed 2026-08-04T03:17:48.498Z sha 1271bfbd00a3faebd2288e89fd1f18ee264bf78f :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-06T11:37:22.994Z sha 1271bfbd00a3faebd2288e89fd1f18ee264bf78f :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T07:42:14.223Z sha 1271bfbd00a3faebd2288e89fd1f18ee264bf78f :: needs real behavior proof before merge. :: [P1] Align automatic signing with the restart path
  • reviewed 2026-08-13T21:15:04.914Z sha 3b15f51777a872e2e114c168f3c21c8ff7e5aaf2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T05:32:26.877Z sha 0f5f32e01e8ae77807b7e27b10b9d4ac6783bdfa :: needs real behavior proof before merge. :: [P1] Keep automatic identity policy aligned across Mac signing
  • reviewed 2026-08-15T06:32:02.410Z sha 58830841123f9c059cb5494d092ce1218e54b4bd :: needs real behavior proof before merge. :: [P1] Unify automatic signing eligibility across Mac entry points
  • reviewed 2026-08-21T17:19:23.501Z sha 13c78c55582f885ea83422ce0db3093aabb5059a :: needs real behavior proof before merge. :: [P1] Unify automatic signing eligibility across Mac entry points
  • reviewed 2026-08-27T22:30:48.826Z sha e332b0d08561b8c0aa44c29177a066cc567e1fe4 :: needs real behavior proof before merge. :: [P1] Reject invalid Keychain rows before auto-selection

@harjothkhara

Copy link
Copy Markdown
Contributor Author

@steipete — this needs a product decision before I revise the branch, per the ClawSweeper review above. Tagging you as the author of the signing-identity requirement (f23b16d); happy to redirect if someone else owns this.

The question: should automatic Mac signing select any keychain-valid codesigning identity, or only Apple-class ones, with other certificates requiring an explicit SIGN_IDENTITY?

Right now the two entry points disagree, and the docs side with neither consistently:

One fact worth weighing: because the fourth tier never worked in any released build, no operator has ever relied on it. So this is not repair-versus-regression — nobody loses behavior either way. It is a forward-looking choice about the default.

The cost of Apple-only is that a developer holding a valid enterprise or internal-CA certificate is routed to ad-hoc signing, and the script's own warning notes ad-hoc builds do not persist TCC permissions across rebuilds. The cost of the broader policy is that automatic selection can pick a certificate the operator did not intend.

Either outcome is fine by me, and I will do the work:

  1. Apple-only — I will delete the dead fourth tier rather than leave it, correct the docs, and align restart-mac.sh. That also moots the needs proof block, since there is no new signing behavior to prove.
  2. Broader policy — I will keep this repair, extend it to restart-mac.sh so both paths share one definition, and supply real-signing proof.

On proof: I cannot capture a real Apple-issued signing session on this machine. For option 2 I can produce a genuine capture using a locally created self-signed codesigning certificate — a real non-Apple-class identity through the real codesign path, including --verify --deep --strict and the Team-ID audit — if that is acceptable evidence. Please say if you would rather see something else.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 8, 2026
@harjothkhara
harjothkhara force-pushed the claude/elated-pike-32879f branch 2 times, most recently from 3b15f51 to 0f5f32e Compare August 15, 2026 05:22
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 15, 2026
@harjothkhara
harjothkhara force-pushed the claude/elated-pike-32879f branch 2 times, most recently from 5883084 to 13c78c5 Compare August 21, 2026 17:13
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 21, 2026
@harjothkhara

Copy link
Copy Markdown
Contributor Author

@vincentkoc could you make a call on this one?

The defect is still on current main (75b736c): the tier 4 fallback in select_identity uses sed -n 's/.*\"\\(.*\\)\"/\\1/p', an over-escaped pattern that declares no capture group and requires a literal backslash, so it can never match. A keychain with only non Apple class certs still fails with "No signing identity found".

ClawSweeper gates this on real behavior proof from a real setup. That needs a macOS keychain with signing identities, which an outside contributor cannot supply, while a maintainer with certs installed can verify in one run. If this is not worth that verification, say so and I will close it to free the slot.

@harjothkhara
harjothkhara force-pushed the claude/elated-pike-32879f branch from 13c78c5 to e332b0d Compare August 27, 2026 22:22
@clawsweeper clawsweeper Bot removed P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 27, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 27, 2026
@harjothkhara
harjothkhara force-pushed the claude/elated-pike-32879f branch from e332b0d to 6fb6962 Compare September 27, 2026 23:31
@harjothkhara

Copy link
Copy Markdown
Contributor Author

Could a maintainer confirm whether non-Apple signing certificates should require explicit SIGN_IDENTITY rather than automatic selection, so I can preserve the existing ad-hoc restart behavior and revise this patch accordingly?

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @harjothkhara for investigating this and clarifying the policy choice. On current main (b924498923df), the default restart-mac.sh path already exports SIGN_IDENTITY="-" and ALLOW_ADHOC_SIGNING=1 when no Apple-class identity is found, including a Keychain containing only a non-Apple certificate. It prints the fallback reason, and the signer prints Using signing identity: - plus the TCC persistence warning. This behavior was introduced in cb213b55f6e3 and survives the shared-selector extraction in #157861.

I verified 11 focused checks using current-main signing blocks and the real codesign script's identity-selection entry point with isolated stubs; no native signing or contributor code was executed. Direct packaging intentionally requires ALLOW_ADHOC_SIGNING=1 or SIGN_IDENTITY="-" when no recognized identity exists.

Closing because the local development fallback is already available and reported. We'll keep ad-hoc as that default and leave release/notarization behavior unchanged. Rejecting unusable Keychain rows is useful separate hardening. Thanks again for the investigation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants