[CI] Pin and verify external downloads in CI (#25206)

Pin external CI dependencies to SHA/digest and verify signatures.
Bazelisk update to 1.30, since 1.21.0 release has no sha published on
github.
Progress for https://github.com/iree-org/iree/pull/25180.


🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Tobias Fuchs <fuchs@roofline.ai>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml
index 050bc18..e5745e9 100644
--- a/.github/workflows/build_package.yml
+++ b/.github/workflows/build_package.yml
@@ -183,7 +183,7 @@
     env:
       # These are also set in: build_tools/python_deploy/build_linux_packages.sh
       MANYLINUX_X86_64_IMAGE: ghcr.io/iree-org/manylinux_x86_64@sha256:2e0246137819cf10ed84240a971f9dd75cc3eb62dc6907dfd2080ee966b3c9f4
-      MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64
+      MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64:2026.11.01-2@sha256:54b271d9562a3686298880df05367909e949ed317e7b1b79b59c696d75f78676
 
     steps:
       - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
diff --git a/.github/workflows/ci_linux_x64_bazel.yml b/.github/workflows/ci_linux_x64_bazel.yml
index 0b85dd2..4b3af82 100644
--- a/.github/workflows/ci_linux_x64_bazel.yml
+++ b/.github/workflows/ci_linux_x64_bazel.yml
@@ -33,7 +33,7 @@
         env:
           IREE_CUDA_DEPS_DIR: /usr/local/iree_cuda_deps
         run: |
-          ./build_tools/bazel/install_bazelisk.sh 1.21.0
+          ./build_tools/bazel/install_bazelisk.sh 1.30.0
           cp ./build_tools/scripts/fetch_cuda_deps.sh /usr/local/bin
           /usr/local/bin/fetch_cuda_deps.sh ${IREE_CUDA_DEPS_DIR}
           ./build_tools/bazel/build_test_all.sh
diff --git a/.github/workflows/clang_tidy.yml b/.github/workflows/clang_tidy.yml
index aae545f..1a4d3f1 100644
--- a/.github/workflows/clang_tidy.yml
+++ b/.github/workflows/clang_tidy.yml
@@ -68,12 +68,17 @@
           cat .iree-clang-tidy/llvm-project-revision.txt
           .iree-clang-tidy/clang-tidy --version
 
+      # Use uv instead of plain pip since cpp-linter uses it anyway.
+      - name: Install uv
+        uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
+        with:
+          version: "0.13.7"
+          # uv-x86_64-unknown-linux-gnu.tar.gz, as published in uv's release.
+          checksum: "c5221ff41b7892bfc223543883600125f6a47fe845093e0f5bdff4f359196d83"
+          enable-cache: false
+
       - name: Install Python requirements
         run: |
-          # Use uv instead of plain pip since cpp-linter uses it anyway.
-          curl -LsSf https://astral.sh/uv/install.sh | sh
-          echo "$HOME/.local/bin" >> "$GITHUB_PATH"
-          export PATH="$HOME/.local/bin:$PATH"
           uv pip install --system -r ./runtime/bindings/python/iree/runtime/build_requirements.txt
           uv pip install --system -r ./build_tools/github_actions/ci_requirements.txt
 
diff --git a/.github/workflows/pkgci_test_riscv64.yml b/.github/workflows/pkgci_test_riscv64.yml
index 2ae30df..85c90ea 100644
--- a/.github/workflows/pkgci_test_riscv64.yml
+++ b/.github/workflows/pkgci_test_riscv64.yml
@@ -74,15 +74,20 @@
       - name: Bootstrap
         env:
           IREE_ARTIFACT_URL: "https://sharkpublic.blob.core.windows.net/sharkpublic/GCP-Migration-Files"
+          # These are also set in: build_tools/riscv/riscv_bootstrap.sh
           RISCV_CLANG_TOOLCHAIN_FILE_NAME: "toolchain_iree_manylinux_2_28_20231012.tar.gz"
+          RISCV_CLANG_TOOLCHAIN_FILE_SHA: "3af56a58551ed5ae7441214822461a5368fee9403d7c883762fa902489bfbff0"
           QEMU_FILE_NAME: "qemu-riscv_8.1.2_manylinux_2.28_20231026.tar.gz"
+          QEMU_FILE_SHA: "dd77b39820d45b80bafab9155581578b4c625cb92fd6db9e9adbb9798fde3597"
         run: |
           mkdir -p ${{ env.BOOTSTRAP_WORK_DIR }}
           mkdir -p ${{ env.RISCV_TOOLCHAIN_ROOT }}
           mkdir -p ${{ env.QEMU_PATH_PREFIX }}
           wget --progress=bar:force:noscroll --directory-prefix="${BOOTSTRAP_WORK_DIR}" "${IREE_ARTIFACT_URL}/${RISCV_CLANG_TOOLCHAIN_FILE_NAME}"
+          echo "${RISCV_CLANG_TOOLCHAIN_FILE_SHA}  ${BOOTSTRAP_WORK_DIR}/${RISCV_CLANG_TOOLCHAIN_FILE_NAME}" | sha256sum -c -
           tar -C "${{ env.RISCV_TOOLCHAIN_ROOT }}" -xf "${BOOTSTRAP_WORK_DIR}/${RISCV_CLANG_TOOLCHAIN_FILE_NAME}" --no-same-owner --strip-components=1
           wget --progress=bar:force:noscroll --directory-prefix="${BOOTSTRAP_WORK_DIR}" "${IREE_ARTIFACT_URL}/${QEMU_FILE_NAME}"
+          echo "${QEMU_FILE_SHA}  ${BOOTSTRAP_WORK_DIR}/${QEMU_FILE_NAME}" | sha256sum -c -
           tar -C "${{ env.QEMU_PATH_PREFIX }}" -xf "${BOOTSTRAP_WORK_DIR}/${QEMU_FILE_NAME}" --no-same-owner --strip-components=1
       - name: Build riscv64
         env:
diff --git a/build_tools/bazel/install_bazelisk.sh b/build_tools/bazel/install_bazelisk.sh
index 68c8496..3206901 100755
--- a/build_tools/bazel/install_bazelisk.sh
+++ b/build_tools/bazel/install_bazelisk.sh
@@ -11,9 +11,20 @@
 
 ARCH="$(dpkg --print-architecture)"
 
+# SHA-256 of each supported binary, as published next to it in the release.
+case "${BAZELISK_VERSION}-${ARCH}" in
+  1.30.0-amd64) BAZELISK_SHA256="a248ae2b2b62b5baebb748f6fba7203bff1a27e5d01b55399a8406744cb539e8" ;;
+  1.30.0-arm64) BAZELISK_SHA256="b2bcc040c213b44586b121bda6d983c35df121b917c3a7a66fb16f2fa0df1a4f" ;;
+  *)
+    echo "No SHA-256 known for bazelisk ${BAZELISK_VERSION} on ${ARCH}; add it to $0."
+    exit 1
+    ;;
+esac
+
 curl --silent --fail --show-error --location \
     "https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VERSION}/bazelisk-linux-${ARCH}" \
     --output bazelisk
+echo "${BAZELISK_SHA256}  bazelisk" | sha256sum -c -
 
 cp ./bazelisk /usr/local/bin/bazel
 chmod +x /usr/local/bin/bazel
diff --git a/build_tools/python_deploy/build_linux_packages.sh b/build_tools/python_deploy/build_linux_packages.sh
index c01cab9..ec7b7d5 100755
--- a/build_tools/python_deploy/build_linux_packages.sh
+++ b/build_tools/python_deploy/build_linux_packages.sh
@@ -64,7 +64,7 @@
 this_dir="$(cd $(dirname $0) && pwd)"
 script_name="$(basename $0)"
 repo_root=$(cd "${this_dir}" && find_git_dir_parent)
-manylinux_docker_image="${manylinux_docker_image:-$(uname -m | awk '{print ($1 == "aarch64") ? "quay.io/pypa/manylinux_2_28_aarch64" : "ghcr.io/iree-org/manylinux_x86_64@sha256:2e0246137819cf10ed84240a971f9dd75cc3eb62dc6907dfd2080ee966b3c9f4" }')}"
+manylinux_docker_image="${manylinux_docker_image:-$(uname -m | awk '{print ($1 == "aarch64") ? "quay.io/pypa/manylinux_2_28_aarch64:2026.11.01-2@sha256:54b271d9562a3686298880df05367909e949ed317e7b1b79b59c696d75f78676" : "ghcr.io/iree-org/manylinux_x86_64@sha256:2e0246137819cf10ed84240a971f9dd75cc3eb62dc6907dfd2080ee966b3c9f4" }')}"
 # Python versions to build. cp312 is the abi3 build (produces a wheel
 # compatible with 3.12+). Per-version builds are used for <3.12 and 3.13t.
 python_versions="${override_python_versions:-cp310-cp310 cp311-cp311 cp312-cp312 cp313-cp313t}"
diff --git a/build_tools/python_deploy/install_macos_deps.sh b/build_tools/python_deploy/install_macos_deps.sh
index 4fffe9e..bed5437 100755
--- a/build_tools/python_deploy/install_macos_deps.sh
+++ b/build_tools/python_deploy/install_macos_deps.sh
@@ -19,16 +19,22 @@
 fi
 
 # These can be discovered at https://www.python.org/downloads/macos/
+# Each spec is <version>@<installer SHA-256>@<installer URL>.
 PYTHON_SPECS=(
-  3.13@https://www.python.org/ftp/python/3.13.1/python-3.13.1-macos11.pkg
-  3.12@https://www.python.org/ftp/python/3.12.8/python-3.12.8-macos11.pkg
-  3.11@https://www.python.org/ftp/python/3.11.9/python-3.11.9-macos11.pkg
+  3.13@67c6f0a3190851e0013214d5abd725a42ec398ff1b50eec47826820fd052d86b@https://www.python.org/ftp/python/3.13.1/python-3.13.1-macos11.pkg
+  3.12@c411b5372d563532f5e6b589af7eb16e95613d61bd5af7bfe78563467130bbff@https://www.python.org/ftp/python/3.12.8/python-3.12.8-macos11.pkg
+  3.11@b6cfdee2571ca56ee895043ca1e7110fb78a878cee3eb0c21accb2de34d24b55@https://www.python.org/ftp/python/3.11.9/python-3.11.9-macos11.pkg
   # 3.10@https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg
 )
 
+# The python.org installers are signed with this Apple Developer ID.
+PYTHON_SIGNER="Developer ID Installer: Python Software Foundation (BMM5U3QVKW)"
+
 for python_spec in "${PYTHON_SPECS[@]}"; do
   python_version="${python_spec%%@*}"
   url="${python_spec##*@}"
+  sha256="${python_spec#*@}"
+  sha256="${sha256%%@*}"
   echo "-- Installing Python $python_version from $url"
   python_path="/Library/Frameworks/Python.framework/Versions/$python_version"
   python_exe="$python_path/bin/python3"
@@ -40,6 +46,16 @@
     mkdir -p "$(dirname $download_path)"
     echo "Downloading $url -> $download_path"
     curl $url -o "$download_path"
+    echo "$sha256  $download_path" | shasum -a 256 -c -
+
+    echo "Verifying the signature of $download_path"
+    signature="$(pkgutil --check-signature "$download_path")"
+    echo "$signature"
+    if [[ "$signature" != *"signed by a developer certificate issued by Apple"* ||
+          "$signature" != *"$PYTHON_SIGNER"* ]]; then
+      echo "ERROR: $download_path is not signed by '$PYTHON_SIGNER'"
+      exit 1
+    fi
 
     echo "Installing $download_path"
     installer -pkg "$download_path" -target /
diff --git a/build_tools/python_deploy/install_windows_deps.ps1 b/build_tools/python_deploy/install_windows_deps.ps1
index 17deb00..319a271 100644
--- a/build_tools/python_deploy/install_windows_deps.ps1
+++ b/build_tools/python_deploy/install_windows_deps.ps1
@@ -28,6 +28,16 @@
   # "https://www.python.org/ftp/python/3.10.5/python-3.10.5-amd64.exe",
 )
 
+# SHA-256 of each installer in $PYTHON_INSTALLER_URLS.
+$PYTHON_INSTALLER_SHA256S = @(
+  "6b33fa9a439a86f553f9f60e538ccabc857d2f308bc77c477c04a46552ade81f" #,
+  "71bd44e6b0e91c17558963557e4cdb80b483de9b0a0a9717f06cf896f95ab598" #,
+  "5ee42c4eee1e6b4464bb23722f90b45303f79442df63083f05322f1785f5fdde" #,
+)
+
+# The python.org installers are Authenticode-signed by this subject.
+$PYTHON_SIGNER = "CN=Python Software Foundation, O=Python Software Foundation, *"
+
 # Multiple Python install locations are valid, so we use the `py` helper to
 # check for versions and call into them. Some valid install locations are:
 #   C:\Python39\python.exe
@@ -40,6 +50,7 @@
   $PYTHON_VERSION = $PYTHON_VERSIONS[$i]
   $PYTHON_VERSION_NO_DOT = $PYTHON_VERSIONS_NO_DOT[$i]
   $PYTHON_INSTALLER_URL = $PYTHON_INSTALLER_URLS[$i]
+  $PYTHON_INSTALLER_SHA256 = $PYTHON_INSTALLER_SHA256S[$i]
   Write-Host "-- Installing Python ${PYTHON_VERSION} from ${PYTHON_INSTALLER_URL}"
 
   if ("${INSTALLED_VERSIONS_OUTPUT}" -like "*${PYTHON_VERSION}*") {
@@ -55,6 +66,15 @@
     Write-Host "::  Downloading $PYTHON_INSTALLER_URL -> $DOWNLOAD_PATH"
     curl $PYTHON_INSTALLER_URL -o $DOWNLOAD_PATH
 
+    $DOWNLOAD_SHA256 = (Get-FileHash -Algorithm SHA256 $DOWNLOAD_PATH).Hash
+    if ($DOWNLOAD_SHA256 -ne $PYTHON_INSTALLER_SHA256) {
+      throw "SHA-256 of $DOWNLOAD_PATH is $DOWNLOAD_SHA256, expected $PYTHON_INSTALLER_SHA256"
+    }
+    $SIGNATURE = Get-AuthenticodeSignature $DOWNLOAD_PATH
+    if ($SIGNATURE.Status -ne "Valid" -or $SIGNATURE.SignerCertificate.Subject -notlike $PYTHON_SIGNER) {
+      throw "$DOWNLOAD_PATH is not signed by the Python Software Foundation: $($SIGNATURE.Status), $($SIGNATURE.SignerCertificate.Subject)"
+    }
+
     Write-Host "::  Running installer: $DOWNLOAD_PATH"
     # https://docs.python.org/3/using/windows.html#installing-without-ui
     & "$DOWNLOAD_PATH" /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
diff --git a/build_tools/scripts/fetch_cuda_deps.sh b/build_tools/scripts/fetch_cuda_deps.sh
index 1c786bf..c7085b9 100755
--- a/build_tools/scripts/fetch_cuda_deps.sh
+++ b/build_tools/scripts/fetch_cuda_deps.sh
@@ -37,7 +37,7 @@
   exit 1
 fi
 
-DOWNLOAD_SCRIPT_URL="https://raw.githubusercontent.com/NVIDIA/build-system-archive-import-examples/main/parse_redist.py"
+DOWNLOAD_SCRIPT_URL="https://raw.githubusercontent.com/NVIDIA/build-system-archive-import-examples/6ce1321daa48f5fa09de72a166011c397e29997b/parse_redist.py"
 DOWNLOAD_DIR="$TARGET_DIR/download"
 DOWNLOAD_SCRIPT_PATH="$DOWNLOAD_DIR/parse_redist.py"
 
diff --git a/integrations/pjrt/cmake/protobuf_cc_library.cmake b/integrations/pjrt/cmake/protobuf_cc_library.cmake
index afdd54e..291cca6 100644
--- a/integrations/pjrt/cmake/protobuf_cc_library.cmake
+++ b/integrations/pjrt/cmake/protobuf_cc_library.cmake
@@ -13,18 +13,41 @@
 # to prevent protobuf itself from using `find_package`
 set(protobuf_FORCE_FETCH_DEPENDENCIES ON)
 
-# pin the version of protobuf
+# pin the version of protobuf and the commit its tag must point to
 set(protobuf_VERSION 29.1)
+set(protobuf_COMMIT 796e49f6ca82f763d1087d2ff7355d2f0d7b71b1)
 
+# A shallow clone needs a tag rather than a commit, so only populate the
+# source here and check the commit before adding it to the build.
 FetchContent_Declare(
   protobuf
   GIT_REPOSITORY https://github.com/protocolbuffers/protobuf
   GIT_TAG v${protobuf_VERSION}
   GIT_SHALLOW ON
+  SOURCE_SUBDIR do-not-add-subdirectory
 )
 
 FetchContent_MakeAvailable(protobuf)
 
+# skip the check for a local source dir set with FETCHCONTENT_SOURCE_DIR_PROTOBUF
+if(NOT FETCHCONTENT_SOURCE_DIR_PROTOBUF)
+  find_package(Git REQUIRED)
+  execute_process(
+    COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
+    WORKING_DIRECTORY ${protobuf_SOURCE_DIR}
+    OUTPUT_VARIABLE _protobuf_commit
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    COMMAND_ERROR_IS_FATAL ANY
+  )
+  if(NOT _protobuf_commit STREQUAL protobuf_COMMIT)
+    message(FATAL_ERROR
+      "protobuf v${protobuf_VERSION} was fetched at commit ${_protobuf_commit}, "
+      "expected ${protobuf_COMMIT}")
+  endif()
+endif()
+
+add_subdirectory(${protobuf_SOURCE_DIR} ${protobuf_BINARY_DIR})
+
 # make protobuf_generate() function available
 include(${protobuf_SOURCE_DIR}/cmake/protobuf-generate.cmake)