Repository Public
1#!/usr/bin/env bash2# Author: Simon-Pierre Boucher — contact@spboucher.ai3# File: Scripts/verify-release.sh4# Description: Checks the signed SP Wallet application: signature, hardened runtime, sandbox and entitlements, embedded profile, no web engine, no debug entitlement, no development code or test server, no secret in the bundle, production endpoint only.5#6# Usage: Scripts/verify-release.sh [path/to/SP Wallet.app] (exit code ≠ 0 when a check fails)7set -uo pipefail8cd "$(dirname "$0")/.."9APP="${1:-dist/SP Wallet.app}"; BIN="$APP/Contents/MacOS/SP Wallet"; FAIL=010ok() { echo " ✓ $1"; }; ko() { echo " ✗ $1"; FAIL=1; }11[[ -d "$APP" ]] || { echo "ERROR: $APP not found" >&2; exit 1; }12echo "== Signature"13codesign --verify --deep --strict "$APP" 2>/dev/null && ok "codesign --verify --deep --strict" || ko "signature invalid"14INFO="$(codesign -dvv "$APP" 2>&1)"15grep -q "Authority=Developer ID Application" <<<"$INFO" && ok "$(grep -m1 '^Authority=' <<<"$INFO")" || ko "not signed with Developer ID Application"16grep -Eq "flags=.*runtime" <<<"$INFO" && ok "hardened runtime enabled" || ko "hardened runtime missing"17grep -q "^Timestamp=" <<<"$INFO" && ok "secure timestamp present" || ko "no secure timestamp"18grep -q "^Identifier=ai.spboucher.spwallet$" <<<"$INFO" && ok "Identifier=ai.spboucher.spwallet" || ko "unexpected identifier: $(grep -m1 '^Identifier=' <<<"$INFO")"19grep -q "^TeamIdentifier=3YM54G49SN$" <<<"$INFO" && ok "TeamIdentifier=3YM54G49SN" || ko "unexpected team"20echo "== Entitlements"21ENT="$(codesign -d --entitlements :- "$APP" 2>/dev/null)"22grep -A1 "com.apple.security.app-sandbox" <<<"$ENT" | grep -q "<true/>" && ok "App Sandbox on" || ko "App Sandbox off"23grep -A1 "com.apple.security.network.client" <<<"$ENT" | grep -q "<true/>" && ok "outgoing network only" || ko "network client entitlement missing"24grep -q "webcredentials:wallet.spboucher.ai" <<<"$ENT" && ok "associated domain webcredentials:wallet.spboucher.ai (passkeys)" || ko "associated domain missing (passkeys would fail)"25[[ "$(grep -c "webcredentials:" <<<"$ENT")" == 1 ]] && ok "no other associated domain" || ko "unexpected associated domains"26grep -q "get-task-allow" <<<"$ENT" && ko "get-task-allow present (debug entitlement)" || ok "no get-task-allow"27for bad in com.apple.security.cs.disable-library-validation com.apple.security.cs.allow-unsigned-executable-memory com.apple.security.cs.allow-jit com.apple.security.cs.allow-dyld-environment-variables com.apple.security.network.server com.apple.security.device.camera com.apple.security.device.audio-input com.apple.security.files.all com.apple.security.files.downloads.read-write com.apple.security.automation.apple-events com.apple.security.temporary-exception; do28 grep -q "$bad" <<<"$ENT" && ko "unexpected entitlement $bad"; done; ok "no runtime exception, no server socket, no device, no broad file access, no Apple events"29[[ -f "$APP/Contents/embedded.provisionprofile" ]] && ok "provisioning profile embedded" || ko "embedded.provisionprofile missing"30echo "== Native only"31LIBS="$(for a in $(lipo -archs "$BIN"); do otool -arch "$a" -L "$BIN"; done; find "$APP/Contents" -name '*.dylib' -o -name '*.framework')"32grep -Eiq "WebKit|JavaScriptCore|Electron|Chromium|libnode" <<<"$LIBS" && ko "a web engine is linked" || ok "no WebKit / JavaScriptCore / Chromium linked"33nm -u "$BIN" 2>/dev/null | grep -Eq "WKWebView|WebView" && ko "a web view symbol is referenced" || ok "no web view symbol referenced"34find "$APP" \( -name '*.html' -o -name '*.js' -o -name '*.css' \) | grep -q . && ko "web resources in the bundle" || ok "no HTML / JS / CSS resources"35echo "== Release, not development"36STR="$(strings -a "$BIN")"37grep -Eq "spwDevPort|spwAutoSetup|spwSelfTest|spwDevSetupToken|dev-passkey|DevPasskey|SoftwareAuthenticator|localhost:87|spwallet\.dev" <<<"$STR" && ko "development switch, software passkey or test server in the binary" || ok "no development switch, no software passkey, no test server, no .dev identifier"38grep -q "https://wallet.spboucher.ai" <<<"$STR" && ok "production endpoint https://wallet.spboucher.ai" || ko "production endpoint not found"39grep -Eo "http://[a-zA-Z0-9.-]+" <<<"$STR" | grep -Ev "www\.apple\.com|www\.w3\.org|ns\.adobe\.com|purl\.org|schemas\.|xmlsoap" | sort -u | grep -q . && ko "plain-http URL in the binary: $(grep -Eo "http://[a-zA-Z0-9.-]+" <<<"$STR" | sort -u | head -3 | tr '\n' ' ')" || ok "no plain-http endpoint"40grep -q "NSAllowsLocalNetworking\|NSAllowsArbitraryLoads" "$APP/Contents/Info.plist" && ko "App Transport Security exception present" || ok "no App Transport Security exception"41echo "== Secrets"42if grep -rlaE "(sk-ant-|sk-proj-|BEGIN (EC |RSA |OPENSSH )?PRIVATE KEY|Bearer [A-Za-z0-9_-]{40}|spw_live_[A-Za-z0-9]{20})" "$APP" >/dev/null 2>&1; then ko "something that looks like a secret is in the bundle"; else ok "no API key, private key or session token in the bundle"; fi43grep -Eiq "mnemonic|seed phrase|export-recovery|privateKey\b" <<<"$STR" && echo " · note: recovery-related words appear in UI strings (review: $(grep -Eio "mnemonic|seed phrase|export-recovery" <<<"$STR" | sort -u | tr '\n' ' '))" || ok "no seed / private-key handling string"44echo "== Bundle"45echo " version $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Contents/Info.plist")) · archs $(lipo -archs "$BIN") · min macOS $(/usr/libexec/PlistBuddy -c 'Print :LSMinimumSystemVersion' "$APP/Contents/Info.plist") · $(du -sh "$APP" | cut -f1)"46[[ -f "$APP/Contents/Resources/AppIcon.icns" || -f "$APP/Contents/Resources/Assets.car" ]] && ok "icon assets present" || ko "icon missing"47exit $FAIL48