Skip to content

Commit e7d9326

Browse files
fix: isolate notarization temp files
Security hardening for the release notarization path. Keeps notarization API key material and upload ZIPs inside a per-run private temporary directory, sets restrictive permissions, and cleans it up on exit. Final release artifact paths remain unchanged. Proof: - bash -n Scripts/sign-and-notarize.sh - static grep for removed predictable /tmp paths - stubbed release harness covering 0700 temp dir, 0600 API key, private notarization ZIP, cleanup, unchanged final artifacts - make check - autoreview clean - CI green
1 parent c566197 commit e7d9326

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

Scripts/sign-and-notarize.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,18 @@ if [[ -z "${APP_STORE_CONNECT_API_KEY_P8:-}" || -z "${APP_STORE_CONNECT_KEY_ID:-
1717
echo "Missing APP_STORE_CONNECT_* env vars (API key, key id, issuer id)." >&2
1818
exit 1
1919
fi
20-
echo "$APP_STORE_CONNECT_API_KEY_P8" | sed 's/\\n/\n/g' > /tmp/codexbar-api-key.p8
21-
trap 'rm -f /tmp/codexbar-api-key.p8 /tmp/${APP_NAME}Notarize.zip' EXIT
20+
21+
NOTARIZATION_TEMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/codexbar-notarize.XXXXXX")
22+
chmod 700 "$NOTARIZATION_TEMP_DIR"
23+
API_KEY_PATH="$NOTARIZATION_TEMP_DIR/codexbar-api-key.p8"
24+
NOTARIZATION_ZIP="$NOTARIZATION_TEMP_DIR/${APP_NAME}Notarize.zip"
25+
trap 'rm -rf "$NOTARIZATION_TEMP_DIR"' EXIT
26+
27+
(
28+
umask 077
29+
printf '%s' "$APP_STORE_CONNECT_API_KEY_P8" | sed 's/\\n/\n/g' > "$API_KEY_PATH"
30+
)
31+
chmod 600 "$API_KEY_PATH"
2232

2333
ARCH_LIST=( ${ARCHES_VALUE} )
2434
for ARCH in "${ARCH_LIST[@]}"; do
@@ -52,11 +62,11 @@ codesign --force --timestamp --options runtime --sign "$APP_IDENTITY" \
5262
"$APP_BUNDLE"
5363

5464
DITTO_BIN=${DITTO_BIN:-/usr/bin/ditto}
55-
"$DITTO_BIN" --norsrc -c -k --keepParent "$APP_BUNDLE" "/tmp/${APP_NAME}Notarize.zip"
65+
"$DITTO_BIN" --norsrc -c -k --keepParent "$APP_BUNDLE" "$NOTARIZATION_ZIP"
5666

5767
echo "Submitting for notarization"
58-
xcrun notarytool submit "/tmp/${APP_NAME}Notarize.zip" \
59-
--key /tmp/codexbar-api-key.p8 \
68+
xcrun notarytool submit "$NOTARIZATION_ZIP" \
69+
--key "$API_KEY_PATH" \
6070
--key-id "$APP_STORE_CONNECT_KEY_ID" \
6171
--issuer "$APP_STORE_CONNECT_ISSUER_ID" \
6272
--wait

0 commit comments

Comments
 (0)