Skip to content

Add a Windows probe for code integrity blocks, and audit bundle signatures in CI - #10408

Merged
danielhanchen merged 96 commits into
mainfrom
windows-sac-probe
Sep 28, 2026
Merged

danielhanchen merged 96 commits into
mainfrom
windows-sac-probe

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Why

Users report Studio installing and launching, then failing to load a model, with the failure clearing when Smart App Control is turned off and returning after a reboot. The dialog names the file:

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.

0xc0e90002 is a code integrity refusal. Every PE we ship is unsigned (47 of 47 in the CUDA bundle, 51 of 52 in the CPU bundle, the exception being Microsoft's own OpenMP runtime) and VirusTotal has never seen any of them, so they carry no cloud reputation either.

That is a strong hypothesis resting on one screenshot. #6588 previously tested this and concluded the opposite, that signing was not the differentiator, because llama-server.exe was unsigned and running. This PR is how we stop guessing.

scripts/windows_sac_probe

Run by a person on a real Windows machine, in four stages so a box is never left modified by accident.

stage what it changes undone by
prepare records a baseline; updates packages and Defender signatures; turns Defender real-time, MAPS advanced, cloud block level high and PUA on; raises the CodeIntegrity log to 64 MB; applies the audit policy if one is supplied revert
run nothing; inventories signatures and drives Studio n/a
collect nothing; exports events and zips the evidence n/a
revert removes the audit policy, restores Defender settings from the baseline n/a

It never turns Smart App Control itself on or off. Doing so through Settings is a one-way operation that cannot be undone without reinstalling Windows, and the registry route needs BitLocker suspended and a boot into recovery. Only the audit policy is added, and only that is removed.

The policy worth supplying is Microsoft's SmartAppControlAuditNoISG.bin from https://aka.ms/sacauditpolicies. It checks signatures and skips the cloud reputation lookup, which means it works even with Smart App Control off, so any machine can produce evidence about the half of the verdict signing actually changes. It logs event 3076 for every file it would have refused.

studio_scenario.py

Drives Studio over HTTP using only the standard library, so it needs no browser and no pip install. It loads a GGUF, generates, runs a web search turn and a tool call turn (enable_tools plus enabled_tools: ["web_search"]), and times every request.

It also answers a second, separate question. A background poller hits /api/inference/status at the same 5 second cadence the frontend uses and reports max_ms, over_10s and over_75s. Field diagnostics show that route taking 80530 ms and 80156 ms, which starves /api/health and gets the backend killed by the desktop watchdog at its 3 strike, roughly 75 second budget, surfacing as "Server stopped unexpectedly". Both stalls happened with no model loaded, so the cause is not established. This measures it instead of assuming it.

How to run it

# elevated PowerShell, Studio installed and running
cd scripts\windows_sac_probe

.\sac-probe.ps1 -Stage prepare -Label custom-sac-on -AuditPolicy C:\path\to\SmartAppControlAuditNoISG.bin
.\sac-probe.ps1 -Stage run     -Label custom-sac-on
.\sac-probe.ps1 -Stage collect -Label custom-sac-on
.\sac-probe.ps1 -Stage revert  -Label custom-sac-on

If Studio has been opened before on that machine its password has already been rotated and the bootstrap file is gone, so pass yours:

$env:UNSLOTH_STUDIO_PASSWORD = 'your studio password'

prepare is slow the first time because of winget upgrade --all and Update-MpSignature; add -SkipUpdates to skip both. collect writes a zip to %USERPROFILE%\unsloth-sac-probe\. Attach it here. It contains your Windows user name in file paths; redacting the user name is fine, but keep the file names and the rest of each path, because which file was blocked is the whole point.

Please run all four cells

One run is not a result. Use a distinct -Label per cell:

Smart App Control enforcing Smart App Control off
our build custom-sac-on custom-sac-off
upstream ggml-org build upstream-sac-on upstream-sac-off

The upstream row separates "our additive-merge build is the problem" from "the whole unsigned llama.cpp ecosystem is the problem". Upstream is also 0 of N signed, and so is lemonade-sdk/llamacpp-rocm (72 PE files, 0 signed), so the upstream-enforcing cell is what tells us whether download prevalence alone carries a build through.

Pin an older, more established runtime with $env:UNSLOTH_LLAMA_RELEASE_TAG = 'b10715-mix-86bd2d3' before a run.

Grading the evidence

These are not interchangeable, and the README repeats it because it is the easiest thing to get wrong:

  • 3077 is an enforced block. This is proof.
  • 3076 is audit only, "would have been blocked". Strong, not enforcement.
  • 3089 carries signature detail; correlate to a 3077 by ActivityID, never by timestamp alone.
  • 3090 to 3092 are allow and origin context and prove nothing alone.

"Unsigned" and "low reputation" are also different diagnoses: Smart App Control may allow a validly signed file whose reputation is inconclusive, which is the behaviour the signing fix depends on. And search for every PE path in the bundle, since the blocked file can be a dependent ggml, HIP, OpenMP or VC runtime DLL rather than llama-server.exe.

Do not enable Windows test-signing mode; it changes enforcement conditions and invalidates the run.

The CI workflow

windows-llama-signature-audit.yml does the part a hosted runner honestly can. GitHub's Windows images have Smart App Control off and it cannot be enabled there, so the job reports that state explicitly, up front, so that nobody later reads a green tick as evidence that Smart App Control allows our binaries. Then it audits what it can measure: how many PE files in the published bundles carry a valid Authenticode signature, with a per bundle table in the job summary and a CSV artifact.

It warns rather than fails today, because every published bundle is currently unsigned and enforcing now would only paint main red until unslothai/llama.cpp#204 lands. Flip the enforce default once it has.

Related

…tures in CI

We have one screenshot showing Smart App Control blocking llama-common.dll
with status 0xc0e90002, and no reproduction. This is how that becomes a
measurement.

scripts/windows_sac_probe is meant to be run by a person on a real Windows
machine, in four stages so a box is never left modified by accident:
prepare records a baseline, updates packages and Defender signatures, turns
the reversible security settings up and optionally applies Microsoft's
SmartAppControlAuditNoISG policy; run inventories every PE under
~/.unsloth/llama.cpp and exercises Studio; collect exports the CodeIntegrity
events and zips everything; revert puts the machine back.

It never turns Smart App Control itself on or off. That is a one-way
operation through Settings, and the registry route needs BitLocker suspended
and a recovery-mode boot. Only the audit policy is added, and only that is
removed. The NoISG variant is the one worth having: it checks signatures and
skips the cloud reputation lookup, so it works even with Smart App Control
off, which means any machine can produce evidence about the half of the
verdict that signing actually changes.

studio_scenario.py drives Studio over HTTP with the standard library alone,
so it needs no browser and no pip install. It loads a GGUF, generates, runs
a web search turn and a tool call turn, and times every request. A
background poller hits /api/inference/status at the same 5 second cadence
the frontend uses and reports max, over_10s and over_75s. Field diagnostics
show that route taking over 80 seconds, which starves /api/health and gets
the backend killed by the watchdog at its ~75 second budget as
unresponsive_health_check. Those stalls happened with no model loaded, so
the cause is not established, and this measures it rather than assuming it.

The README spells out the 2x2 matrix (our build and upstream's, against
Smart App Control on and off) and how to grade the events, because they are
not interchangeable: 3077 is an enforced block, 3076 only says a file would
have been blocked, and 3089 must be correlated to a 3077 by ActivityID
rather than by timestamp.

The CI workflow does the part a hosted runner honestly can. GitHub's Windows
images have Smart App Control off and it cannot be enabled, so the job
reports that state explicitly and then audits what it can measure: how many
PE files in the published bundles carry a valid Authenticode signature. It
warns rather than fails today, because every published bundle is currently
unsigned and enforcing now would only paint main red until the signing
change in unslothai/llama.cpp lands. Flip the enforce default once it has.
@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-28T04:30:47.902263Z b168bfe Manual request
🔒 Security Review ✅ Completed 2026-09-25T11:28:59.278137Z 46177e7 Manual request

Security findings

Advisory findings (1)

ℹ️ 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[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
Two gaps. The scripts are not Authenticode signed, so downloading them
individually rather than cloning gets them Mark-of-the-Web tagged and
PowerShell refuses to run them under the default RemoteSigned policy. The
README now says to clone, and gives Unblock-File or a process-scoped Bypass
as the alternatives, while warning off changing the machine-wide policy,
which is part of what the probe measures.

It also now says to start with an AMD machine. Every Smart App Control
report so far has been AMD rather than NVIDIA: #6588 on unsigned ROCm
libraries, #6648 on rocfft.dll where the verdict changed on a byte identical
file, and the report that prompted this work. The ROCm bundle is also the
largest unsigned surface at 75 PE files against 47 for CUDA, because it
carries AMD's TheRock runtime DLLs, which ship unsigned.
The probe assumed Studio was already installed and running, which made it
useless on a fresh Windows box, and a fresh box is exactly what we want to
test: it is the state a new user is in when they hit this.

prepare now detects whether anything answers /api/liveness, then whether a
managed interpreter exists, and installs with the documented
irm https://unsloth.ai/install.ps1 | iex when neither holds. Piping rather
than downloading first is deliberate. The copy served from unsloth.ai is not
Authenticode signed, so writing it to disk would attach Mark-of-the-Web and
the default RemoteSigned policy would refuse to run it, and piping is also
what a real user does.

The install runs after the event log window opens. Installing is what
downloads the llama.cpp bundle and first launch is what loads it, so both
land inside the window collect exports; on an affected machine the block may
appear during prepare rather than during run.

Studio starts through python -X utf8 -I -m unsloth_cli, not the generated
unsloth.exe. Windows materialises that console script as an unsigned PE and
Application Control denies it while the signed interpreter beside it keeps
running, so on the machines this probe targets the normal launch would fail
for a reason unrelated to what is being measured. unsloth_cli/__main__.py
documents this as the supported entry point for that case.

run re-checks and restarts Studio as well, since a machine may have been
rebooted between stages, which is itself part of the reported behaviour.
Startup is polled for up to five minutes rather than slept on, because the
first launch imports torch. -SkipInstall and -Port are there for the cases
that need them.
@danielhanchen

Copy link
Copy Markdown
Member Author

Running this on a new machine

Nothing needs to be installed first beyond Python. prepare detects whether Unsloth Studio is present and installs it if not.

1. Get the scripts on the box

git clone --branch windows-sac-probe --depth 1 https://github.com/unslothai/unsloth C:\unsloth-probe
cd C:\unsloth-probe\scripts\windows_sac_probe

Clone rather than downloading the files individually. These scripts are not Authenticode signed, so downloaded copies get Mark-of-the-Web and the default RemoteSigned policy refuses them. If you did download them:

Get-ChildItem . -Recurse | Unblock-File

Do not change the machine-wide execution policy. It is part of what we are measuring.

2. Get the audit policy (recommended)

Download the sample policies from https://aka.ms/sacauditpolicies and keep SmartAppControlAuditNoISG.bin. That one checks signatures and skips the cloud reputation lookup, so it works even with Smart App Control off, which means any machine can produce evidence about the half of the verdict signing changes. It logs event 3076 for every file it would refuse.

3. Run the four stages, elevated

.\sac-probe.ps1 -Stage prepare -Label amd-unsigned -AuditPolicy C:\path\SmartAppControlAuditNoISG.bin

$env:UNSLOTH_STUDIO_PASSWORD = 'your studio password'   # only if Studio was already set up on this box
.\sac-probe.ps1 -Stage run     -Label amd-unsigned
.\sac-probe.ps1 -Stage collect -Label amd-unsigned
.\sac-probe.ps1 -Stage revert  -Label amd-unsigned

On a bare machine prepare prints:

=== Unsloth Studio ===
Studio is not installed on this machine.

=== Install Unsloth Studio ===
irm https://unsloth.ai/install.ps1 | iex
...
managed interpreter: C:\Users\you\.unsloth\studio\unsloth_studio\Scripts\python.exe
starting Studio on port 8888
Studio answering on port 8888 after 65s

There is no password to supply in that case: the probe reads the bootstrap credential from <home>\auth\.bootstrap_password and rotates it. UNSLOTH_STUDIO_PASSWORD is only needed when Studio was opened before on that machine, because Studio deletes the bootstrap file once rotated and the credential cannot be recovered from disk.

Two details that matter:

  • The install runs after the event log window opens. Installing is what downloads the llama.cpp bundle and first launch is what loads it, so both are inside the window collect exports. On an affected machine the block may appear during prepare rather than during run.
  • Studio is started with python -X utf8 -I -m unsloth_cli studio -p 8888, not the generated unsloth.exe. Windows materialises that console script as an unsigned PE and Application Control denies it ([Bug] Unsloth Studio Windows installation fails: Application Control policy blocks unsloth.exe #8490) while the signed interpreter beside it keeps running. Launching the normal way on these machines would fail for a reason unrelated to what we are measuring. unsloth_cli/__main__.py documents this as the supported entry point.

prepare is slow the first time because of winget upgrade --all and Update-MpSignature; add -SkipUpdates to skip both. Use -SkipInstall to refuse to install, -Port if 8888 is taken.

4. Send back the zip

collect writes %USERPROFILE%\unsloth-sac-probe\unsloth-sac-<machine>-<label>-<timestamp>.zip. Attach it here. It contains your Windows user name inside file paths. Redacting the user name is fine, but keep the file names and the rest of each path, because which file was blocked is the whole point.

Please start with an AMD machine

Every Smart App Control report so far has been AMD, not NVIDIA: #6588 on unsigned ROCm libraries, #6648 on rocfft.dll where the verdict changed on a byte identical file, and the report that prompted this work. The NVIDIA user in the diagnostics we have loaded a model successfully; the blocked screenshot is an AMD machine.

The ROCm bundle is also the largest unsigned surface. Measured against the published b10798-mix-659e406:

PUBLISHED rocm-gfx1150: 75 PE files, 0 signed
  AMD-supplied DLLs: amd_comgr.dll, amdhip64_7.dll, ggml-hip.dll, hipblas.dll,
                     libhipblaslt.dll, origami.dll, rocblas.dll, rocm_kpack.dll, ...

75 unsigned files against 47 for CUDA, because ROCm carries AMD's TheRock runtime on top of ours.

The comparison that actually settles it

One run proves little. What answers "does signing fix Smart App Control" is the same machine, twice.

Check which bundle the machine has:

Get-Content ~\.unsloth\llama.cpp\UNSLOTH_PREBUILT_INFO.json

If it is gfx1151, a signed build already exists: download app-b10798-mix-659e406-windows-x64-rocm-gfx1151 from llama.cpp run 34071621914, unzip it over ~\.unsloth\llama.cpp\build\bin\Release, and re-run with -Label amd-signed. For any other target, say which and a signed build can be produced for it; that run only covered gfx1151.

A 3077 in amd-unsigned and none in amd-signed is the result we are after. A 3077 naming a signed file in the second means signing was not sufficient on its own, and the next lever is a Microsoft WDSI submission to seed reputation, which the probe output is shaped to feed.

Grading the events

They are not interchangeable:

  • 3077 is an enforced block. This is proof.
  • 3076 is audit only, "would have been blocked". Strong, not enforcement.
  • 3089 carries signature detail; correlate to a 3077 by ActivityID, never by timestamp alone.
  • 3090 to 3092 are allow and origin context and prove nothing alone.

"Unsigned" and "low reputation" are also different diagnoses: Smart App Control may allow a validly signed file whose reputation is inconclusive, which is the behaviour the signing fix depends on. Search for every PE path in the bundle, since the blocked file can be a dependent ggml, HIP, OpenMP or VC runtime DLL rather than llama-server.exe itself.

Do not enable Windows test-signing mode; it changes enforcement conditions and invalidates the run.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Scenario:
- split the repo:variant shorthand into model_path and gguf_variant, since
  the load route has no colon parser and the default never reached llama.cpp
- require an operator password for the bootstrap rotation and never print it
- rename the poller's stop flag so Thread.join() no longer hits an Event
- unload by model_path (an empty body is a 422 and leaves the runtime resident)
- join the poller for the full request timeout and count an in-flight poll
- default --home from UNSLOTH_STUDIO_HOME / STUDIO_HOME

PowerShell:
- check native exit codes (CiTool, mountvol) instead of trusting them
- verify the audit policy GUID is active after refresh, not merely listed
- preserve and restore a pre-existing policy with the same GUID
- record and restore the CodeIntegrity log settings
- mount the EFI partition only when absent and unmount what was mounted
- serialise empty inventories and event lists as [] rather than an empty file
- follow UNSLOTH_LLAMA_CPP_PATH and UNSLOTH_STUDIO_HOME for runtime and logs

Audit the arm64 CPU and ROCm bundles too, and correct the README on what the
release tag pin does at run time. Guards in tests/studio/test_windows_sac_probe.py.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…fe to retry

Scenario:
- /api/inference/load and /unload commit a 200 after 15 seconds and report a
  later failure only under _deferred_error, so a download followed by the
  CodeIntegrity refusal was recorded as a successful load; read the body the
  way unsloth_cli/_inference.py does, including a truncated pad
- tool turns stream and require a tool_end event, since the non-streaming
  route returns the final text alone and a model answering from memory passed

PowerShell:
- rerunning prepare with the same label keeps the first baseline and does not
  save its own policy as pre-existing
- the rollback state is written before CiTool -r, so a failed refresh is
  still undone by revert
- an occupied S: that is not the EFI system partition is an error
- -SkipStudio no longer starts or installs Studio inside the evidence window
- collect refuses a label that was never prepared instead of inventing a
  two-hour window
- winget upgrade --all is opt-in (-UpgradePackages): revert cannot undo it
- the interpreter locator shares Get-StudioHome's precedence
- an empty Defender detection list serialises as []

Workflow: each bundle download checks its exit code and that a file landed,
since a later successful download replaced $LASTEXITCODE.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…ed in the probe

Scenario:
- unload the model before the measured load: a resident model makes /load an
  already_loaded no-op that loads no PE inside the window, and that reply is
  now a failure rather than a success
- an empty bootstrap file is a rotated installation (Studio truncates it on
  Windows when it cannot delete it), so the operator's password is used
- a tool_end whose result is empty, a refusal or an Error: is not an execution
- the status poller abandons a read at 10 s and follows it at once with the
  next, as the frontend does, and reports each stall as a run of abandoned
  reads instead of one long request

PowerShell:
- the run stage restarts an installed Studio and never installs one, so a
  prepare -SkipInstall stays in force
- no policy list from CiTool fails prepare instead of warning
- only NoMatchingEventsFound is an empty window; any other Get-WinEvent
  failure is recorded in the evidence and fatal
- Defender preferences are restored one at a time so one failure does not
  skip the rest

The guard module reads a workflow file, so it is added to the unfiltered
workflow-trigger-lint job as tests/studio/test_workflow_guards_run_unfiltered.py requires.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 1084598f51

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 7cfb66d847

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 36987c744a

ℹ️ 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".

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: b168bfe8c4

ℹ️ 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".

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: b168bfe8c4

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature# security# Moves a security boundary: sandbox, allowlist, permission or network guard >3000#

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants