Repository navigation
Install and self-update on Macs without Xcode or the Command Line Tools - #1325
Closed
tolgaergin wants to merge 5 commits into
Closed
tolgaergin wants to merge 5 commits into
tolgaergin wants to merge 5 commits into
Conversation
lpm self-update ran /usr/bin/stapler and install.sh ran `xcrun stapler`. Both are xcrun shims: stapler needs Xcode, so self-update refused every update on a Mac with only the Command Line Tools, and both failed on a Mac with neither. GitHub's macOS runners have Xcode, so no test saw it. Both now confirm the notarization ticket the way `stapler validate` does, with tools every Mac ships with: they look up Apple's ticket record for the app's SHA-256 code-directory hash over HTTPS and require it to equal the stapled ticket byte for byte. A missing, revoked or different ticket fails at once; an unanswered lookup is retried for about two minutes as before. The code-signature check now also requires LPM's Developer ID identity and `notarized`, which verifies the stapled ticket's Apple signature offline on a Mac that hasn't seen this code. Gatekeeper's assessment is unchanged. The provisioning profile is decoded in process (self-update) or with openssl (install.sh) instead of `security cms -D`, which needs a default keychain. Self-update runs its validation tools with only the system PATH, so variables such as DEVELOPER_DIR can't change what they do. Tests: - macOS validation may run only programs that ship with macOS; a test fails for any xcrun shim, and install.sh's harness checks its tools the same way - the ticket lookup's answers, retries and refusals, in Rust and install.sh - real signed releases, including swapped and garbage tickets - a new CI job removes Xcode, or Xcode and the Command Line Tools, from a macOS runner, then installs and upgrades through install.sh, checks an affected v0.85.0 install, and self-updates this build to the latest signed stable and nightly releases; it also runs daily - the release candidate's installer smoke runs without developer tools Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ates From the council's first review round: - install.sh's lookup no longer lets ~/.curlrc decide: it refuses redirects and reads the status from the response headers, so `location` or `fail` there can't change the outcome, while its proxy settings still apply. It reads at most 64 KiB, extracts each field on its own so a JSON null elsewhere in the answer can't hide the ticket, requires every field to have its JSON type, caps an echoed error code at 40 characters, and retries HTTP 408. Character classes are spelled out, so locales that collate a-f with A-E can't widen them. Self-update now also retries 408, takes a null `deleted` as absent and reads the body through lpm_http::read_body_capped. - Test endpoints must be the exact loopback host with an all-digit port; a user-info `@` let a lookalike URL reach another host. - The fake codesign accepts only the pinned requirement, and parity tests hold the requirement, transient errors and size limit to install.sh's. New tests cover an extra record, an empty or undecodable ticket, nulls, an oversized answer, malformed fields and code-directory hashes, and an oversized or corrupt provisioning profile. A real-network test confirms Apple's record matches a release's own ticket and no other. - The developer-tools-free job moves to its own workflow, so only it runs daily. Its v0.85.0 configuration step no longer starts a background update check that held the update lock; expected versions come from where install.sh and lpm self-update look; the restore step reselects the developer directory selected before; the Command Line Tools check requires the stapler shim's own refusal. - The macOS CI build checks now run the installer harness, so its macOS cases, the no-shim check among them, gate every pull request. - Comments no longer claim `notarized` proves the stapled ticket offline: the system may answer it from its cache or Apple's service. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the council's second review round: - Every field's type is checked on the root element of its extracted value, so a string or boolean wrapped in an array or object no longer passes, and all fields are checked before any decides, as self-update's parser does. `records` must be an array holding exactly one object: plutil can't tell a missing second element from a null one, so the serialized array is compared with its first record. A ticket must be standard padded base64, which base64 -D alone doesn't enforce. - A 200 whose transfer failed is retried as "an incomplete answer" instead of being parsed, a status line without a reason phrase or with a CR is read correctly, and an interim 1xx status is retried. - Tests: container-typed, numeric and non-JSON fields, a null or object `records`, undecodable base64, a truncated answer, and a client that must hang up on an endless answer, so dropping the 64 KiB cap fails. The requirement parity test reads install.sh's bundle and team values. - The workflow runs the live ticket-database test and fails unless all four signed-release tests ran, retries a fresh install that GitHub's shared unauthenticated limit refused, reads the expected versions after each update, and has its own cache key. The developer-tools helper keeps cache directories with spaces intact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tolgaergin
marked this pull request as ready for review
November 25, 2026 01:11
From the council's third review round, and the new workflow's first runs: - plutil on macOS 15 can't write JSON holding a null, so the round-2 check that compared the serialized `records` with its first record failed there for any null in the answer, and a genuine answer with one would have failed every install. install.sh now extracts single values only, as XML, which a null elsewhere doesn't touch on any version; a second record or an empty `records` still means another record. Shapes only a non-Apple server could send, such as `[record, null]`, are read by their record, the same on every version; the exact ticket still decides. - `fields` and `signedTicket` must be objects when present, a present `signedTicket` must hold a string value, and a string across lines is judged as a string. - Tests pin each guard: base64 outside the standard padded alphabet, a malformed field beside NOT_FOUND, an answer of exactly 65,536 and of 65,537 bytes, an interim-only 100, a status line without a reason phrase, a confirmed ticket with a ~/.curlrc (whose CURL_HOME the harness pins), and a Rust oversized answer that would otherwise be a valid ticket, with each retry's detail asserted. - The workflow names the fresh install's version, since the shared unauthenticated GitHub limit refused all three tries on a runner, and accepts v0.85.0's quoted release-age value. Each updater check compares the version the updater reports choosing with the dist-tag before or after the update. The developer-tools helper skips an empty per-user temporary directory instead of stopping under set -e. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ler does `stapler validate` does not compare the stapled ticket with Apple's record byte for byte: LPM Vault.app's record was replaced by a second notarization 58 s after the first, its stapled ticket differs from the record in 245 of 1884 bytes, and stapler accepts it. Requiring equality would have made a release whose code Apple ticketed again uninstallable and un-updatable for good, since immutable releases can't take a new staple. Both install.sh and self-update now accept the stapled ticket when it is Apple's current one for the code, or a ticket that carries Apple's `s8ch` magic and lists the same code-directory hash. Apple's record must still exist and not be deleted. A stapled ticket for other code, or a file without the magic, fails at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Superseded by #1329. This PR checked notarization tickets against Apple's ticket service. The updater would have depended on an undocumented Apple web API for good, and its shell parser already answered differently on macOS 15 and macOS 27. #1329 checks releases only with tools that ship with macOS and calls no Apple service. Checking for revoked notarizations moves to the release side. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a Mac with only the Command Line Tools,
lpm self-updaterefused every macOS standalone update:/usr/bin/stapler. That is anxcrunshim that refuses to run without Xcode, even when the Command Line Tools ship their ownstapler.install.shrunsxcrun stapler. That works with recent Command Line Tools, but fails on a Mac with no developer tools at all.stapler, and the installer tests used a fakexcrun.What
stapler validatechecked, and what replaces itstapler validatelooks up Apple's ticket record for the app's SHA-256 code-directory hash,2/2/<cdhash>in Apple's public ticket database on CloudKit. It accepts the stapled ticket while that record stands, as long as the stapled ticket is a ticket for the same code. It need not be byte-identical: LPM Vault.app's record was replaced by a second notarization 58 s after the first, its stapled ticket differs from the record in 245 bytes, and stapler accepts it. The council compared every built-in alternative on the real v0.88.0 bundle and on tampered copies:stapler validate(Xcode)codesign -R=notarized,--check-notarization,spctl,syspolicy_checksyspolicy_check)No built-in assessor proves which bytes are stapled, because syspolicyd answers from its cache or online. So both the installer and self-update now do what
staplerdoes, with tools that ship with macOS. The HTTPS lookup runs in-process in Rust, and withcurl,plutil,PlistBuddy,base64,cmpandodininstall.sh.Apple's record for the code must exist and not be deleted. The stapled ticket must then be Apple's current ticket, or another ticket that carries Apple's
s8chmagic and lists the same code-directory hash. The latter covers the case where Apple notarized the same code again.Requiring a byte-for-byte match would have been stricter than
stapler. A release whose code Apple ticketed again would then be permanently uninstallable, since immutable releases can't take a new staple.The gap versus
stapler, accepted when this PR was reviewed: a stapled ticket that differs from the record isn't signature-checked by our code. Its bytes come from the Sigstore-verified archive, and Gatekeeper's online assessment and thenotarizedrequirement still run.THROTTLEDand similar record errors, an unreadable answer, and a dropped connection.Added on top of that:
codesign --verify --strictnow requires a Developer ID Application signature by823S8YKMRWoverdev.lpm.cli, andnotarized, so Apple's own code-signing machinery confirms the identity and that Apple notarized this code. syspolicyd may answernotarizedfrom the stapled ticket, its cache or Apple's service, so this does not prove the stapled bytes; the record comparison does.security cms -Dfailed for accounts without a default keychain. The provisioning profile is now decoded with Security.framework'sCMSDecoderin self-update and withopenssl smimeininstall.sh. The profile is a sealed resource, so decoding it is enough.PATH, soDEVELOPER_DIRand other variables can't change their behavior.Gatekeeper (
spctl --assess) and every other check are unchanged. The policy is the same as before, and stricter where noted. The only new exposure is that the CloudKit lookup endpoint is undocumented, thoughstaplerand Gatekeeper's own online check use it. If Apple changes it, the check fails closed, and the new daily job reports it.install.sh's lookup follows the same rules as self-update's:~/.curlrccan't change the outcome. Redirects are refused and the status is read from the response headers, solocationorfailthere make no difference, while its proxy settings still apply.nullelsewhere can't hide the ticket, and every field must have its JSON type.a-ftogether withA-Ecan't widen them.@used to let a lookalike URL reach another host.Regression gates
MacOSToolenum, and a test fails if any of them is anxcrunshim, i.e. a hard link of/usr/bin/gitor/usr/bin/xcodebuild.tests/install-sh/run.shapplies it to every toolinstall.shruns, by absolute path or onPATH. It also fails ifinstall.shmentionsxcrun,staplerorxcode-select.tests/install-sh/run.sh. Its macOS cases include the shim check and the ticket-lookup cases.macos-without-developer-tools.yml, jobmacOS with developer tools {none, command-line-tools}. It runs on PRs that touch these paths, daily at 09:41 UTC and on dispatch. It removes Xcode (and the Command Line Tools fornone) from amacos-15runner, verifies they're gone, then runs against real signed releases:install.sh;npm/release/upgrade-recovery.md, which goes into every release's notes, now covers these releases. Users of 0.76.0–0.88.0 without Xcode rerun the installer once.Verification so far
Bug-first tests: before the fix, the shim test failed on
/usr/bin/stapler. The real-archive test failed with the user's exact message underDEVELOPER_DIR=/Library/Developer/CommandLineTools. After the fix, both pass, under that setting and with an empty developer directory.Fixed
install.shagainst the real GitHub v0.88.0 release: installed with a temporary HOME (no keychain), an emptyDEVELOPER_DIRand the stockPATH.Fixed build (debug, stamped 0.0.1) on this Mac, in a throwaway account home: self-updated to the real v0.88.0 and to
v0.89.0-nightly.20261124.284.bc3608e. Each installed app satisfied the Developer ID +notarizedrequirement.Local checks:
cargo test -p lpm-cli --bin lpm-rs self_update: 242 passed.cargo clippy -p lpm-cli --all-targets -D warnings: clean.cargo fmt --check: clean.sh tests/install-sh/run.sh: 41 passed.node --test npm/release/tests/*.test.mjs: 213 passed.scripts/ci/test-macos-developer-tools.sh: passed on macOS and on Debian.CI, run 45517569258 on the first commit, both legs: the developer tools were removed and verified gone. This build's real-release tests and a fresh
install.shinstall of the real latest release passed. The affected-install step then failed on a test bug: v0.85.0'slpm configstarted a background update check that held the update lock. Fixed in round 1.Linux (OrbStack, Debian 12 arm64, non-root):
Council round 1 (Fable 5.2, Opus 5.5, Astra 6.2, Sol 6.2, Gemini 4 Neon): all findings fixed in the second commit, test-first. Round 2 reviews that commit.
Linux, this branch's build: in OrbStack, stamped 0.0.1, it self-updated to the real signed v0.88.0 and the latest nightly.
Council rounds 2 and 3: all findings fixed test-first. Each guard is mutation-tested: removing it fails the harness or the Rust tests. The first CI runs of the new workflow caught two problems, both now fixed: the shared unauthenticated GitHub API limit, and macOS 15's plutil, which can't write JSON holding a null. So the installer now extracts single values only, which behaves the same on every version.
Still open: CI on the final head, Windows (Parallels VM) checks, and the full workspace gate (left to CI: locally it would take the disk below the 20 GB floor).
Recovery for users
The installer fix takes effect when this merges, because
https://cli.lpm.dev/installredirects tomain. Updaters in 0.76.0–0.88.0 can't be changed, so their users without Xcode rerun the installer once after the next release. From that release on,lpm self-updateworks without developer tools.🤖 Generated with Claude Code