Repository navigation
Sign the Windows prebuilt binaries with Azure Trusted Signing - #204
Conversation
Every PE we ship in the Windows bundles is unsigned. Checking the assets from b10798-mix-659e406 directly: windows-x64-cuda12-legacy 47 PE files, 0 signed windows-x64-cpu 52 PE files, 1 signed windows-x64-cpu (b10715) 52 PE files, 1 signed The single signature is libomp140.x86_64.dll, which Microsoft signed before we vendored it. llama-server.exe, llama-common.dll, llama.dll, the ggml backends and the ROCm runtime DLLs all ship with no certificate table at all, and VirusTotal has never seen any of them, so they carry no prevalence either. Smart App Control evaluates every binary as it loads, not just installers, and blocks unknown unsigned code. When it does, Windows shows a Bad Image dialog naming the dependent DLL it refused and reporting status 0xc0e90002. Users have reported exactly that against llama-common.dll under ~/.unsloth/llama.cpp/build/bin/Release, with the block clearing when Smart App Control is turned off and returning after a reboot. The Studio installer downloads these bundles after its own signed installer has already run, so they sit outside the Authenticode scope of that installer and nothing downstream signs them. A SHA-256 manifest proves the bytes arrived intact but establishes no trust. This signs the whole build tree in each of the four Windows legs, before packaging, using the same Azure Trusted Signing setup the desktop release already uses. Signing is batched: trusted-signing-cli takes any number of trailing paths and authenticates once per invocation, so a bundle costs one round trip rather than one per file. The release then verifies the finished zip rather than the build tree, because packaging copies extra runtimes in afterwards (the OpenMP DLL out of the Visual Studio redist tree, the ROCm DLLs out of the TheRock dist), and only the archive shows what actually ships. An unsigned file fails the job. Forks have no signing credentials and keep building unsigned so that contributors are not blocked. On this repo a missing secret is a hard error instead: a skip that looks like a pass is how the desktop Defender scan went missing for five releases in unslothai/unsloth#8358. Before this can pass on unslothai/llama.cpp, a release-signing environment needs AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID, AZURE_TRUSTED_SIGNING_ACCOUNT_NAME and AZURE_CERTIFICATE_PROFILE_NAME.
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e23ed939e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - name: Sign Windows binaries | ||
| id: sign_windows | ||
| uses: ./.github/actions/sign-windows |
There was a problem hiding this comment.
Check out the local signing action before invoking it
Every Windows leg reaches this local uses: without the action existing under $GITHUB_WORKSPACE: the CPU, Vulkan, and ROCm jobs never check out this repository, while the CUDA job checks it out under tooling/. Consequently ./.github/actions/sign-windows/action.yml cannot be loaded and the jobs fail before signing; the later .github/scripts/assert-windows-bundle-signed.ps1 paths have the same problem. I checked all four modified child workflows; they need the current repository checked out at the referenced root or paths adjusted to an existing checkout.
Useful? React with 👍 / 👎.
| source_artifact: ${{ needs.resolve.outputs.source_artifact }} | ||
| commit: ${{ needs.resolve.outputs.commit }} | ||
| matrix: ${{ needs.resolve.outputs.win_cuda_matrix }} | ||
| secrets: inherit |
There was a problem hiding this comment.
Attach signing jobs to the release-signing environment
When these credentials are stored in the release-signing GitHub environment as the new action's input descriptions and error message specify, secrets: inherit cannot expose them because neither the caller nor any job in the reusable workflows selects that environment. All ${{ secrets.AZURE_* }} expressions therefore resolve empty on the canonical repository, and the gate deliberately exits 1, preventing every release. Bind the Windows jobs to release-signing (or move the credentials to caller-visible repository secrets).
Useful? React with 👍 / 👎.
The build legs extract a source tarball rather than checking this repo out, so ./.github/actions/sign-windows did not exist in the workspace for the CPU, Vulkan and ROCm jobs, and the CUDA job has this repo at tooling/ rather than at the root. As written the signing step would have failed to resolve in all four legs on the first dispatch. CPU, Vulkan and ROCm now sparse-checkout .github into signing-tooling/. A checkout at the workspace root would clean the extracted source tree out from under the build, which is why it goes in a subdirectory. CUDA reuses the tooling/ checkout it already makes for package_bundle.py.
Two things the desktop release workflow already does that this was missing. The Windows jobs now name environment: release-signing, the same as the build job in unslothai/unsloth. It is inert today, since the environment has no protection rules and repository secrets resolve inside a job that names one, so nothing about a build changes. What it buys is a place to hang a required reviewer later. Without it, anyone who can dispatch the parent workflow can sign under our identity. Approval is per (run, environment), so one approval would cover all four Windows legs. The signing action also verifies trusted-signing-cli before using it, rather than only checking the download digest. sign-windows-tree.ps1 invokes it by bare name, so whatever PATH resolves is what signs; the step asserts that resolves to the digest-verified copy and refuses otherwise. It also runs --version, handling the two distinct failure modes separately: a truncated download cannot start and raises under Stop, while a binary that starts and exits non-zero does not raise and needs $LASTEXITCODE read explicitly. The desktop workflow carries a comment saying this used to exit 0 on both branches and the failure only surfaced later inside the bundler with no obvious cause.
Signing replaces an existing signature, and some of what the bundles carry arrives already signed by its vendor. The CPU bundle ships libomp140 copied out of the Visual Studio redist tree, signed by Microsoft; signing every PE in the tree would have stripped that and substituted ours for no gain. Files that are unsigned, or whose chain does not build, are still ours to sign. The tree is re-verified afterwards either way, so a file left alone still has to report Valid, and the release gate checks the finished zip independently.
|
Proven end to end. Test run 34071621914, dispatched with Every Windows leg signed and passed the release gate:
From the CPU x64 job: The two CPU legs check one more file than they sign. That is For comparison, the same bundles from the currently published
Cost is small. Batching keeps it to one Azure round trip per 40 files: 97s for the first batch and 25s for the second, roughly two minutes per bundle. Three bugs were found by running this rather than by reading it, all fixed in this branch:
Worth a decision before merge: the ROCm leg signs 75 files, which includes AMD's TheRock runtime DLLs ( Note the |
What this fixes
Every PE we ship in the Windows bundles is unsigned. Parsing the PE certificate tables of the published assets directly:
b10798-mix-659e406)windows-x64-cuda12-legacywindows-x64-cpuwindows-x64-cpu(b10715-mix-86bd2d3)The single signature is
libomp140.x86_64.dll, which Microsoft signed before we vendored it out of the Visual Studio redist tree.llama-server.exe,llama-common.dll,llama.dll, theggmlbackends and the ROCm runtime DLLs have no certificate table at all. VirusTotal returns 404 for all of them, so they carry no prevalence either.Smart App Control evaluates every binary as it loads, not just installers, and blocks unknown unsigned code. When it does, Windows shows a Bad Image dialog naming the dependent DLL it refused, with status
0xc0e90002(STATUS_SYSTEM_INTEGRITY_POLICY_VIOLATION, CodeIntegrity event 3077). Users have reported exactly that againstllama-common.dllunder~\.unsloth\llama.cpp\build\bin\Release:The block clears when Smart App Control is turned off and returns after a reboot, which is consistent with a per file hash reputation verdict being re-evaluated from a cleared cache.
The Studio installer downloads these bundles after its own signed installer has already run, so they sit outside that installer's Authenticode scope and nothing downstream signs them. The SHA-256 manifest proves the bytes arrived intact but establishes no trust.
Related history: unslothai/unsloth#6588 and unslothai/unsloth#6648 hit the same mechanism against unsigned ROCm DLLs, and ggml-org#6648 recorded Smart App Control changing its verdict on a byte identical file.
What changed
.github/actions/sign-windowsis a composite action that installs a digest pinnedtrusted-signing-cliand signs a build tree..github/scripts/sign-windows-tree.ps1signs every.exe,.dll,.pyd,.sys,.ocx,.cpland.scrunder a directory. Signing is batched, sincetrusted-signing-cliaccepts any number of trailing paths and authenticates to Azure once per invocation, so a bundle costs one round trip rather than one per file..github/scripts/assert-windows-bundle-signed.ps1is the release gate. It verifies the finished zip rather than the build tree, because packaging copies extra runtimes in afterwards (the OpenMP DLL from the Visual Studio redist tree, the ROCm DLLs from the TheRock dist), and only the archive shows what actually ships.secrets: inherit.Nothing about the build itself changes. No compiler flags, no toolchain, no DLL set.
Secrets
Added at repository level on
unslothai/llama.cpp, the same five names the desktop release uses:TAURI_SIGNING_PRIVATE_KEYis the updater's minisign key and is not needed here.The Windows jobs name
environment: release-signing, matching the build job inrelease-desktop.yml. That is inert today: the environment has no protection rules, and repository secrets resolve normally inside a job that names one, so nothing about a build changes. What it buys is a place to hang a required reviewer later. Without it, anyone who can dispatch the parent workflow can sign under our identity. Approval is per (run, environment), so one approval would cover all four Windows legs.Forks have no credentials and keep building unsigned, so contributors are not blocked. On this repo a missing secret is a hard error instead. A skip that looks like a pass is how the desktop Defender scan went missing for five releases in unslothai/unsloth#8358.
How to verify
Signature inventory of any bundle, from Windows:
Today every row except
libomp140.*.dllreportsNotSignedorUnknownError. After this lands every row should reportValid.The same check runs in CI as
assert-windows-bundle-signed.ps1, which fails the job and annotates each offending file.What this does not prove
Signing removes the signature half of a Smart App Control verdict. It does not on its own guarantee a given build clears cloud reputation, and the evidence that reputation is what users are hitting is currently one screenshot rather than a controlled reproduction. Shipping roughly 850 unsigned, zero prevalence files per release is worth fixing regardless. A separate change adds a reproducible Windows probe that collects CodeIntegrity 3076/3077 events so the reputation half can be measured properly.