From 263ed41e7a7d330130a8e9b9e5abb94496d321b1 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Thu, 24 Sep 2026 10:45:36 +0800 Subject: [PATCH] fix(appimage): verify the patched AppRun is the one shipped Reset the split buffer by its first byte rather than zeroing all of it per argument, check the AppRun source tarball's sha256, pin the build image by digest, and fail the job if appimage-builder deployed anything other than the binary built here. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/flutter-build.yml | 1 + appimage/apprun-split-arguments.patch | 2 +- appimage/build-apprun.sh | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/flutter-build.yml b/.github/workflows/flutter-build.yml index 8c71645bf..1c4520522 100644 --- a/.github/workflows/flutter-build.yml +++ b/.github/workflows/flutter-build.yml @@ -2446,6 +2446,7 @@ jobs: pushd appimage ./build-apprun.sh ${{ matrix.job.arch }} sudo appimage-builder --skip-tests --recipe ./AppImageBuilder-${{ matrix.job.arch }}.yml + cmp AppDir/AppRun appimage-build/AppRun/v2.0.0/AppRun-Release-${{ matrix.job.arch }} - name: Publish appimage package if: env.UPLOAD_ARTIFACT == 'true' diff --git a/appimage/apprun-split-arguments.patch b/appimage/apprun-split-arguments.patch index b1855bbc2..e9e68959e 100644 --- a/appimage/apprun-split-arguments.patch +++ b/appimage/apprun-split-arguments.patch @@ -44,7 +44,7 @@ } - memset(buffer, 0, 1024); -+ memset(buffer, 0, buffer_size); ++ buffer[0] = '\0'; } begin = end; diff --git a/appimage/build-apprun.sh b/appimage/build-apprun.sh index e9c4d0e8e..16426f983 100755 --- a/appimage/build-apprun.sh +++ b/appimage/build-apprun.sh @@ -8,6 +8,8 @@ set -euo pipefail arch=$1 version=v2.0.0 commit=407700ccef58e1a64cc49856074aee4b1c75d599 +sha256=05729f2ae0a744369d2d19d0f37acfbdcb1ee064172955b7576883ccef5113b3 +image=ubuntu:16.04@sha256:1f1a2d56de1d604801a9671f301190704c25d604a416f59e03c04f5c6ffee0d6 here=$(cd "$(dirname "$0")" && pwd) case $arch in @@ -16,11 +18,15 @@ case $arch in *) echo "Unsupported arch: $arch" >&2; exit 1 ;; esac -src=$(mktemp -d) -curl -fsSL "https://github.com/AppImageCrafters/AppRun/archive/$commit.tar.gz" | tar -xz -C "$src" --strip-components=1 +tmp=$(mktemp -d) +src=$tmp/src +curl -fsSL -o "$tmp/apprun.tar.gz" "https://github.com/AppImageCrafters/AppRun/archive/$commit.tar.gz" +echo "$sha256 $tmp/apprun.tar.gz" | sha256sum -c - +mkdir "$src" +tar -xzf "$tmp/apprun.tar.gz" -C "$src" --strip-components=1 patch -d "$src" -p1 < "$here/apprun-split-arguments.patch" -docker run --rm -v "$src:/src" -w /src -e DEBIAN_FRONTEND=noninteractive ubuntu:16.04 bash -c " +docker run --rm -v "$src:/src" -w /src -e DEBIAN_FRONTEND=noninteractive "$image" bash -c " set -e apt-get update apt-get install -y --no-install-recommends $packages