Harden release signing: isolated signing job, attested + pinned builder image
What changed, and why it matters
This commit is a security hardening improvement, not a vulnerability fix. It separates the Android app signing step from the build step, pins and verifies the builder image and its tools, and forces reproducible dependency resolution. There is no indication it patches an active security flaw.
No security response needed. Review the new signing job for correct secret handling and verify the SHA-256 values match upstream published hashes before relying on them.
Security signals we found
Isolation of signing keys from build process
Pinned and checksum-verified build tool downloads
Use of '--locked' for reproducible Rust dependency resolution
Addition of GitHub Actions environment protection for builder image
Evidence from the diff
The change refactors the release pipeline: (1) moves Android signing out of the build container into an isolated signing pass so signing keys no longer share a process with the build; (2) pins rustup-init and Android command-line tools by version and SHA-256; (3) adds a GitHub environment to the builder image workflow; (4) forces cargokit builds to use ‘–locked’ so dependencies are resolved from committed Cargo.lock files. The diff shows only defensive improvements; no bug, weakness, or exploit path is corrected.
Changed components
.github/workflows/release.yml.github/workflows/build-builder-image.ymlDockerfile.builderscripts/pin-rust-toolchain.shInspect captured patch +61 / −16
### .github/workflows/build-builder-image.yml
@@ -19,6 +19,7 @@ jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
+ environment: Builder
permissions:
contents: read
packages: write
### .github/workflows/release.yml
@@ -157,21 +157,12 @@ jobs:
exit 1
fi
- - name: Set up Android signing
- run: |
- echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > ./android/keystore.jks
- cat > android/key.properties << EOF
- storePassword=${{ secrets.ANDROID_STORE_PASSWORD }}
- keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}
- keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}
- storeFile=/tmp/skylight/android/keystore.jks
- EOF
-
- - name: Build APKs and AAB
+ - name: Build unsigned APKs and AAB
run: |
VERSION='${{ needs.version.outputs.version }}'
# Deterministic timestamp for reproducible builds
export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)
+ # No key.properties: gradle debug-signs; the real key is applied in the signing pass.
# Fixed build path for reproducibility
docker run --rm \
-v "$PWD:/tmp/skylight" \
@@ -186,6 +177,40 @@ jobs:
cp -v build/app/outputs/flutter-apk/app-x86_64-release.apk "dist/skylight-wallet-${VERSION}-x86_64.apk"
cp -v build/app/outputs/bundle/release/app-release.aab "dist/skylight-wallet-${VERSION}.aab"
+ - name: Sign APKs and AAB
+ env:
+ KS_PASS: ${{ secrets.ANDROID_STORE_PASSWORD }}
+ KEY_PASS: ${{ secrets.ANDROID_KEY_PASSWORD }}
+ KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
+ run: |
+ set -euo pipefail
+ echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > "$RUNNER_TEMP/keystore.jks"
+ # Network-free signing pass: key never shares a process with the build.
+ # APKs get the app key; the AAB the Play upload key (debug JAR sig stripped first).
+ docker run --rm \
+ -v "$PWD/dist:/work" \
+ -v "$RUNNER_TEMP/keystore.jks:/keystore.jks:ro" \
+ -w /work \
+ -e KS_PASS -e KEY_PASS -e KEY_ALIAS \
+ "$BUILDER_IMAGE" \
+ bash -c '
+ set -euo pipefail
+ apksigner=$(ls -d "$ANDROID_HOME"/build-tools/*/apksigner | sort -V | tail -n1)
+ zipalign=$(ls -d "$ANDROID_HOME"/build-tools/*/zipalign | sort -V | tail -n1)
+ for apk in *.apk; do
+ "$zipalign" -p -f 4 "$apk" "$apk.aligned"
+ mv "$apk.aligned" "$apk"
+ "$apksigner" sign --ks /keystore.jks --ks-pass env:KS_PASS --key-pass env:KEY_PASS --ks-key-alias "$KEY_ALIAS" "$apk"
+ "$apksigner" verify --verbose "$apk"
+ done
+ for aab in *.aab; do
+ zip -d "$aab" "META-INF/*.RSA" "META-INF/*.SF" "META-INF/*.DSA" "META-INF/*.EC" >/dev/null 2>&1 || true
+ jarsigner -keystore /keystore.jks -storepass "$KS_PASS" -keypass "$KEY_PASS" -sigalg SHA256withRSA -digestalg SHA-256 "$aab" "$KEY_ALIAS"
+ jarsigner -keystore /keystore.jks -storepass "$KS_PASS" -verify "$aab"
+ done
+ '
+ rm -f "$RUNNER_TEMP/keystore.jks"
+
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
### Dockerfile.builder
@@ -4,7 +4,11 @@ ARG FLUTTER_VERSION
# Passed by build-builder-image.yml from rust-toolchain.toml (single source of truth).
ARG RUST_VERSION
+# Installer/SDK tool pins (version + checksum). Bump version and hash together.
+ARG RUSTUP_VERSION=1.28.2
+ARG RUSTUP_INIT_SHA256=20a06e644b0d9bd2fbdbfd52d42540bdde820ea7df86e92e533c073da0cdd43c
ARG ANDROID_CMDLINE_TOOLS_VERSION=11076708
+ARG ANDROID_CMDLINE_TOOLS_SHA256=2d2d50857e4eb553af5a6dc3ad507a17adf43d115264b1afc116f95c92e5e258
ARG ANDROID_BUILD_TOOLS_VERSION=36.0.0
ARG ANDROID_PLATFORM_VERSION=36
ARG ANDROID_NDK_VERSION=28.1.13356709
@@ -46,15 +50,23 @@ ENV RUSTUP_HOME=/opt/rustup
ENV PATH="/flutter/bin:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${CARGO_HOME}/bin:${PATH}"
ENV FLUTTER_ROOT="/flutter"
-# Install Rust with pinned version
-RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${RUST_VERSION} --profile minimal && \
+# Install Rust via a pinned, checksum-verified rustup-init (not curl|sh of a
+# live installer script). The toolchain itself is pinned by RUST_VERSION and
+# verified by rustup on download.
+RUN curl --proto '=https' --tlsv1.2 -sSfL -o /tmp/rustup-init \
+ "https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/x86_64-unknown-linux-gnu/rustup-init" && \
+ echo "${RUSTUP_INIT_SHA256} /tmp/rustup-init" | sha256sum -c - && \
+ chmod +x /tmp/rustup-init && \
+ /tmp/rustup-init -y --default-toolchain ${RUST_VERSION} --profile minimal && \
+ rm /tmp/rustup-init && \
. ${CARGO_HOME}/env && \
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
-# Install Android SDK command-line tools with pinned version
+# Install Android SDK command-line tools with pinned version + checksum
RUN mkdir -p ${ANDROID_HOME}/cmdline-tools && \
cd ${ANDROID_HOME}/cmdline-tools && \
- curl -o cmdtools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_CMDLINE_TOOLS_VERSION}_latest.zip && \
+ curl -fsSL -o cmdtools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_CMDLINE_TOOLS_VERSION}_latest.zip && \
+ echo "${ANDROID_CMDLINE_TOOLS_SHA256} cmdtools.zip" | sha256sum -c - && \
unzip cmdtools.zip && \
mv cmdline-tools latest && \
rm cmdtools.zip
### scripts/pin-rust-toolchain.sh
@@ -24,12 +24,19 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
TOOLCHAIN="${1:-$(sed -n 's/^[[:space:]]*channel[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' "$ROOT/rust-toolchain.toml" | head -1)}"
n=0
+locked=0
while IFS= read -r f; do
if grep -q "?? 'stable'" "$f"; then
sed -i "s/?? 'stable'/?? '$TOOLCHAIN'/" "$f"
n=$((n + 1))
fi
+ # Force cargo to honor each plugin's committed Cargo.lock — fail rather than
+ # resolve new dependency versions at build time. Idempotent.
+ if grep -q '\.\.\.extraArgs,' "$f" && ! grep -q "'--locked'" "$f"; then
+ sed -i "s/\.\.\.extraArgs,/...extraArgs, '--locked',/" "$f"
+ locked=$((locked + 1))
+ fi
done < <(find "$CACHE" "$ROOT/plugins" -path '*/cargokit/build_tool/lib/src/builder.dart' 2>/dev/null | sort -u)
-echo "pin-rust-toolchain: set cargokit toolchain to $TOOLCHAIN in $n file(s) (PUB_CACHE=$CACHE, repo=$ROOT)"
+echo "pin-rust-toolchain: set cargokit toolchain to $TOOLCHAIN in $n file(s), added --locked in $locked file(s) (PUB_CACHE=$CACHE, repo=$ROOT)"
[ "$n" -gt 0 ] || echo " (warning: no cargokit builder.dart found/patched — verify PUB_CACHE + that the string still exists)"Why this scored 14/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.