Skip to content
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
- name: Validate release asset guard
run: node scripts/release_asset_guard.test.js

- name: Validate universal macOS app verifier
run: ./tests/test_verify_universal_macos_app.sh

- name: Validate current GhosttyKit checksum pin
run: ./tests/test_ci_ghosttykit_checksum_present.sh

Expand Down Expand Up @@ -653,6 +656,12 @@ jobs:
ONLY_ACTIVE_ARCH=NO \
CODE_SIGNING_ALLOWED=NO ASSETCATALOG_COMPILER_APPICON_NAME=AppIcon-Nightly build

- name: Verify universal app binary architectures
run: |
./scripts/verify-universal-macos-app.sh \
"build-universal/Build/Products/Release/cmux.app" \
--label "CI Release app"

ui-regressions:
runs-on: warp-macos-15-arm64-6x
timeout-minutes: 25
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,9 @@ jobs:
- name: Verify nightly binary architectures
if: needs.decide.outputs.should_publish != 'true' || steps.current_head_prebuild.outputs.still_current == 'true'
run: |
set -euo pipefail
APP_BINARY="build-universal/Build/Products/Release/cmux.app/Contents/MacOS/cmux"
CLI_BINARY="build-universal/Build/Products/Release/cmux.app/Contents/Resources/bin/cmux"
HELPER_BINARY="build-universal/Build/Products/Release/cmux.app/Contents/Resources/bin/ghostty"
APP_ARCHS="$(lipo -archs "$APP_BINARY")"
CLI_ARCHS="$(lipo -archs "$CLI_BINARY")"
HELPER_ARCHS="$(lipo -archs "$HELPER_BINARY")"
echo "App binary architectures: $APP_ARCHS"
echo "CLI binary architectures: $CLI_ARCHS"
echo "Ghostty helper architectures: $HELPER_ARCHS"
[[ "$APP_ARCHS" == *arm64* && "$APP_ARCHS" == *x86_64* ]]
[[ "$CLI_ARCHS" == *arm64* && "$CLI_ARCHS" == *x86_64* ]]
[[ "$HELPER_ARCHS" == *arm64* && "$HELPER_ARCHS" == *x86_64* ]]
./scripts/verify-universal-macos-app.sh \
"build-universal/Build/Products/Release/cmux.app" \
--label "Nightly app"

- name: Run CLI version memory guard regression
if: needs.decide.outputs.should_publish != 'true' || steps.current_head_prebuild.outputs.still_current == 'true'
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,9 @@ jobs:
- name: Verify binary architectures
if: steps.guard_release_assets.outputs.skip_all != 'true'
run: |
set -euo pipefail
APP_BINARY="build-universal/Build/Products/Release/cmux.app/Contents/MacOS/cmux"
CLI_BINARY="build-universal/Build/Products/Release/cmux.app/Contents/Resources/bin/cmux"
HELPER_BINARY="build-universal/Build/Products/Release/cmux.app/Contents/Resources/bin/ghostty"
APP_ARCHS="$(lipo -archs "$APP_BINARY")"
CLI_ARCHS="$(lipo -archs "$CLI_BINARY")"
HELPER_ARCHS="$(lipo -archs "$HELPER_BINARY")"
echo "App binary architectures: $APP_ARCHS"
echo "CLI binary architectures: $CLI_ARCHS"
echo "Ghostty helper architectures: $HELPER_ARCHS"
[[ "$APP_ARCHS" == *arm64* && "$APP_ARCHS" == *x86_64* ]]
[[ "$CLI_ARCHS" == *arm64* && "$CLI_ARCHS" == *x86_64* ]]
[[ "$HELPER_ARCHS" == *arm64* && "$HELPER_ARCHS" == *x86_64* ]]
./scripts/verify-universal-macos-app.sh \
"build-universal/Build/Products/Release/cmux.app" \
--label "Release app"

- name: Build remote daemon release assets and inject manifest
if: steps.guard_release_assets.outputs.skip_all != 'true'
Expand Down
7 changes: 6 additions & 1 deletion scripts/build-sign-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,19 @@ cp -R ghostty/macos/GhosttyKit.xcframework GhosttyKit.xcframework
# --- Build app (Release, unsigned) ---
echo "Building app..."
rm -rf build/
xcodebuild -scheme cmux -configuration Release -derivedDataPath build CODE_SIGNING_ALLOWED=NO build 2>&1 | tail -5
xcodebuild -project cmux.xcodeproj -scheme cmux -configuration Release -derivedDataPath build \
-destination 'generic/platform=macOS' \
ARCHS="arm64 x86_64" \
ONLY_ACTIVE_ARCH=NO \
CODE_SIGNING_ALLOWED=NO build 2>&1 | tail -5
echo "Build succeeded"

HELPER_PATH="$APP_PATH/Contents/Resources/bin/ghostty"
if [ ! -x "$HELPER_PATH" ]; then
echo "Ghostty theme picker helper not found at $HELPER_PATH" >&2
exit 1
fi
./scripts/verify-universal-macos-app.sh "$APP_PATH" --label "Release app"

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.

P1 The manual release path calls the verifier without --require-sdk-prefix "26.", which means an app accidentally built against macOS 15 (or any non-26 SDK) would pass this gate and continue through signing, notarization, and upload. Every other release path — release.yml, nightly.yml, and CI release-build — all pass --require-sdk-prefix "26.". The PR explicitly lists this script as one of the hardened paths.

Suggested change
./scripts/verify-universal-macos-app.sh "$APP_PATH" --label "Release app"
./scripts/verify-universal-macos-app.sh "$APP_PATH" --label "Release app" --require-sdk-prefix "26."


# --- Inject Sparkle keys ---
echo "Injecting Sparkle keys..."
Expand Down
106 changes: 106 additions & 0 deletions scripts/verify-universal-macos-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env bash
set -euo pipefail

usage() {
cat <<'EOF'
Usage: ./scripts/verify-universal-macos-app.sh <app-path> [--label <name>]

Verifies that the app executable, bundled cmux CLI, and bundled Ghostty helper
all contain both arm64 and x86_64 Mach-O slices.
EOF
}

APP_PATH=""
LABEL="macOS app"
while [[ $# -gt 0 ]]; do
case "$1" in
--label)
LABEL="${2:-}"
shift 2
;;
Comment thread
austinywang marked this conversation as resolved.
Resolved
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
-h|--help)
usage
exit 0
;;
-*)
echo "Unknown option: $1" >&2
usage >&2
exit 1
;;
*)
if [[ -n "$APP_PATH" ]]; then
echo "Unexpected argument: $1" >&2
usage >&2
exit 1
fi
APP_PATH="$1"
shift
;;
esac
done

if [[ -z "$APP_PATH" ]]; then
usage >&2
exit 1
fi

if [[ -z "$LABEL" ]]; then
echo "Missing value for --label" >&2
exit 1
fi

if [[ ! -d "$APP_PATH" ]]; then
echo "error: app bundle not found at $APP_PATH" >&2
exit 1
fi

LIPO_BIN="${CMUX_LIPO:-lipo}"
if ! command -v "$LIPO_BIN" >/dev/null 2>&1; then
echo "error: lipo is required to verify universal macOS binaries" >&2
exit 1
fi

INFO_PLIST="$APP_PATH/Contents/Info.plist"
EXECUTABLE_NAME=""
if [[ -f "$INFO_PLIST" && -x /usr/libexec/PlistBuddy ]]; then
EXECUTABLE_NAME="$(/usr/libexec/PlistBuddy -c "Print :CFBundleExecutable" "$INFO_PLIST" 2>/dev/null || true)"
fi
if [[ -z "$EXECUTABLE_NAME" ]]; then
EXECUTABLE_NAME="$(basename "$APP_PATH" .app)"
fi

APP_BINARY="$APP_PATH/Contents/MacOS/$EXECUTABLE_NAME"
CLI_BINARY="$APP_PATH/Contents/Resources/bin/cmux"
HELPER_BINARY="$APP_PATH/Contents/Resources/bin/ghostty"

verify_binary_archs() {
local name="$1"
local path="$2"
local archs

if [[ ! -x "$path" ]]; then
echo "error: $name is missing or not executable at $path" >&2
exit 1
fi

if ! archs="$("$LIPO_BIN" -archs "$path")"; then
echo "error: failed to inspect $name architectures at $path" >&2
exit 1
fi

echo "$LABEL $name architectures: $archs"
for expected_arch in arm64 x86_64; do
case " $archs " in
*" $expected_arch "*)
;;
*)
echo "error: $name at $path is missing $expected_arch slice" >&2
exit 1
;;
esac
done
}

verify_binary_archs "app binary" "$APP_BINARY"
verify_binary_archs "CLI binary" "$CLI_BINARY"
verify_binary_archs "Ghostty helper" "$HELPER_BINARY"
76 changes: 76 additions & 0 deletions tests/test_verify_universal_macos_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/cmux-universal-verify.XXXXXX")"
trap 'rm -rf "$TMP_DIR"' EXIT

APP_PATH="$TMP_DIR/cmux.app"
FAKE_LIPO="$TMP_DIR/lipo"

mkdir -p "$APP_PATH/Contents/MacOS" "$APP_PATH/Contents/Resources/bin"
cat > "$APP_PATH/Contents/Info.plist" <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>cmux</string>
</dict>
</plist>
EOF

touch "$APP_PATH/Contents/MacOS/cmux"
touch "$APP_PATH/Contents/Resources/bin/cmux"
touch "$APP_PATH/Contents/Resources/bin/ghostty"
chmod 755 \
"$APP_PATH/Contents/MacOS/cmux" \
"$APP_PATH/Contents/Resources/bin/cmux" \
"$APP_PATH/Contents/Resources/bin/ghostty"

cat > "$FAKE_LIPO" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
if [[ "${1:-}" != "-archs" || $# -ne 2 ]]; then
echo "unexpected lipo invocation" >&2
exit 2
fi
cat "$2.archs"
EOF
chmod +x "$FAKE_LIPO"

set_archs() {
printf '%s\n' "$2" > "$1.archs"
}

VERIFY_SCRIPT="$ROOT_DIR/scripts/verify-universal-macos-app.sh"
export CMUX_LIPO="$FAKE_LIPO"

set_archs "$APP_PATH/Contents/MacOS/cmux" "x86_64 arm64"
set_archs "$APP_PATH/Contents/Resources/bin/cmux" "arm64 x86_64"
set_archs "$APP_PATH/Contents/Resources/bin/ghostty" "arm64 x86_64"
"$VERIFY_SCRIPT" "$APP_PATH" --label "fixture app" >/dev/null

set_archs "$APP_PATH/Contents/Resources/bin/ghostty" "arm64"
if "$VERIFY_SCRIPT" "$APP_PATH" --label "fixture app" >"$TMP_DIR/missing-slice.out" 2>"$TMP_DIR/missing-slice.err"; then
echo "FAIL: verifier accepted a helper missing the x86_64 slice" >&2
exit 1
fi
if ! grep -Fq "missing x86_64 slice" "$TMP_DIR/missing-slice.err"; then
echo "FAIL: verifier did not explain the missing x86_64 slice" >&2
cat "$TMP_DIR/missing-slice.err" >&2
exit 1
fi
Comment thread
austinywang marked this conversation as resolved.
Resolved

rm "$APP_PATH/Contents/Resources/bin/cmux"
if "$VERIFY_SCRIPT" "$APP_PATH" --label "fixture app" >"$TMP_DIR/missing-cli.out" 2>"$TMP_DIR/missing-cli.err"; then
echo "FAIL: verifier accepted an app bundle missing the embedded CLI" >&2
exit 1
fi
if ! grep -Fq "CLI binary is missing or not executable" "$TMP_DIR/missing-cli.err"; then
echo "FAIL: verifier did not explain the missing CLI" >&2
cat "$TMP_DIR/missing-cli.err" >&2
exit 1
fi

echo "PASS: universal macOS app verifier enforces app, CLI, and helper slices"
Loading