Skip to content

Sign the Windows prebuilt binaries with Azure Trusted Signing - #204

Merged
danielhanchen merged 4 commits into
masterfrom
windows-authenticode-signing
Sep 7, 2026
Merged

danielhanchen merged 4 commits into
masterfrom
windows-authenticode-signing

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

What this fixes

Every PE we ship in the Windows bundles is unsigned. Parsing the PE certificate tables of the published assets directly:

bundle (b10798-mix-659e406) PE files signed
windows-x64-cuda12-legacy 47 0
windows-x64-cpu 52 1
windows-x64-cpu (b10715-mix-86bd2d3) 52 1

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, the ggml backends 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 against llama-common.dll under ~\.unsloth\llama.cpp\build\bin\Release:

llama-server.exe - Bad Image
C:\Users\...\.unsloth\llama.cpp\build\bin\Release\llama-common.dll is either not
designed to run on Windows or it contains an error. ... Error status 0xc0e90002.

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-windows is a composite action that installs a digest pinned trusted-signing-cli and signs a build tree.
  • .github/scripts/sign-windows-tree.ps1 signs every .exe, .dll, .pyd, .sys, .ocx, .cpl and .scr under a directory. Signing is batched, since trusted-signing-cli accepts 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.ps1 is 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.
  • All four Windows legs (CPU, CUDA, Vulkan, ROCm) sign before packaging and verify after it. The parent workflow passes the signing secrets down with 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:

AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
AZURE_TENANT_ID
AZURE_TRUSTED_SIGNING_ACCOUNT_NAME
AZURE_CERTIFICATE_PROFILE_NAME

TAURI_SIGNING_PRIVATE_KEY is the updater's minisign key and is not needed here.

The Windows jobs name environment: release-signing, matching the build job in release-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:

$ext = '.exe','.dll','.pyd','.sys','.ocx','.cpl','.scr'
Expand-Archive .\app-<tag>-windows-x64-cpu.zip -DestinationPath .\bundle
Get-ChildItem .\bundle -Recurse -File |
  Where-Object { $ext -contains $_.Extension.ToLowerInvariant() } |
  ForEach-Object {
    $s = Get-AuthenticodeSignature -LiteralPath $_.FullName
    [pscustomobject]@{
      Name    = $_.Name
      Status  = $s.Status
      Subject = $s.SignerCertificate.Subject
    }
  } | Sort-Object Status, Name | Format-Table -AutoSize

Today every row except libomp140.*.dll reports NotSigned or UnknownError. After this lands every row should report Valid.

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.

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.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-07T01:01:26.453896Z 875d263 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +338 to +340
- name: Sign Windows binaries
id: sign_windows
uses: ./.github/actions/sign-windows

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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.
@danielhanchen

Copy link
Copy Markdown
Member Author

Proven end to end. Test run 34071621914, dispatched with publish=false so nothing was released, pinned to tag=b10798 and scoped to cuda12-legacy plus ROCm gfx1151.

Every Windows leg signed and passed the release gate:

leg signed by us PE files in bundle gate
CPU windows/x64 51 52 pass
CPU windows/arm64 38 39 pass
CUDA windows/x64 cuda12-legacy 47 47 pass
Vulkan windows/x64 47 47 pass
ROCm windows/gfx1151 75 75 pass

From the CPU x64 job:

Azure Trusted Signing credentials present; signing.
verified trusted-signing-cli sha256=8c9d750ca582891a7433925dcf302d5d3761fbed757b46c4bf5b417562dccb0e
signing 51 PE file(s) under src/build/bin/Release
=== batch 1/2: 40 file(s) ===
=== batch 2/2: 11 file(s) ===
all 51 file(s) report a valid Authenticode signature
checked 52 file(s) across 1 bundle(s)
Every PE in every bundle is validly signed.

The two CPU legs check one more file than they sign. That is libomp140.<arch>.dll, which the packaging step copies out of the Visual Studio redist tree after signing and which arrives already signed by Microsoft. The gate runs against the finished zip rather than the build tree precisely so a file added during packaging cannot slip past, and the skip rule means we do not strip Microsoft's signature and substitute ours.

For comparison, the same bundles from the currently published b10798-mix-659e406:

bundle PE files signed before signed after
windows-x64-cuda12-legacy 47 0 47
windows-x64-cpu 52 1 52

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:

  • ./.github/actions/sign-windows did not resolve. The build legs extract a source tarball instead of checking this repo out, and the CUDA leg has it at tooling/. CPU, Vulkan and ROCm now sparse-checkout .github into signing-tooling/, deliberately in a subdirectory since a checkout at the workspace root would clean the extracted source tree out from under the build.
  • The signing CLI was digest checked but never verified on PATH. sign-windows-tree.ps1 invokes it by bare name, so the step now asserts PATH resolves to the digest-verified copy and that the binary actually starts, the same fail-closed shape as release-desktop.yml.
  • Every PE was signed unconditionally, which would have replaced Microsoft's signature on libomp140.

Worth a decision before merge: the ROCm leg signs 75 files, which includes AMD's TheRock runtime DLLs (amdhip64_*.dll, rocblas.dll, hipblaslt.dll and the rest). Those arrive unsigned, so signing them under our certificate is the only way they load under Smart App Control, but it does mean we vouch for them. The alternative is excluding them and accepting that ROCm users with Smart App Control on stay broken.

Note the Resolve tag failure on the earlier attempt was unrelated to this PR: ggml-org/llama.cpp#27754 no longer merges cleanly onto base b10826, which will also fail the scheduled nightly until the pin is reordered or dropped in scripts/unsloth/pr-set.json.

This branch was previously deployed

1 inactive deployment
release-signing — 875d263c Deployed Sep 7, 2026 by danielhanchen via CPU / windows/x64 #167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant