Repository navigation
Add a Windows probe for code integrity blocks, and audit bundle signatures in CI - #10408
Conversation
…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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)ℹ️ 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. |
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.
Running this on a new machineNothing needs to be installed first beyond Python. 1. Get the scripts on the boxgit clone --branch windows-sac-probe --depth 1 https://github.com/unslothai/unsloth C:\unsloth-probe
cd C:\unsloth-probe\scripts\windows_sac_probeClone rather than downloading the files individually. These scripts are not Authenticode signed, so downloaded copies get Mark-of-the-Web and the default Get-ChildItem . -Recurse | Unblock-FileDo 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 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-unsignedOn a bare machine There is no password to supply in that case: the probe reads the bootstrap credential from Two details that matter:
4. Send back the zip
Please start with an AMD machineEvery Smart App Control report so far has been AMD, not NVIDIA: #6588 on unsigned ROCm libraries, #6648 on The ROCm bundle is also the largest unsigned surface. Measured against the published 75 unsigned files against 47 for CUDA, because ROCm carries AMD's TheRock runtime on top of ours. The comparison that actually settles itOne 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.jsonIf it is A 3077 in Grading the eventsThey are not interchangeable:
"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 Do not enable Windows test-signing mode; it changes enforcement conditions and invalidates the run. |
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.
…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.
…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.
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…shed exercise before an allow
… record install roots on cancel
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
… pull request runs
…rt test's fake Studio there
…licy ID outrank a lookalike name
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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:
0xc0e90002is 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.exewas unsigned and running. This PR is how we stop guessing.scripts/windows_sac_probeRun by a person on a real Windows machine, in four stages so a box is never left modified by accident.
preparerevertruncollectrevertIt 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.binfrom 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.pyDrives 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_toolsplusenabled_tools: ["web_search"]), and times every request.It also answers a second, separate question. A background poller hits
/api/inference/statusat the same 5 second cadence the frontend uses and reportsmax_ms,over_10sandover_75s. Field diagnostics show that route taking 80530 ms and 80156 ms, which starves/api/healthand 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
If Studio has been opened before on that machine its password has already been rotated and the bootstrap file is gone, so pass yours:
prepareis slow the first time because ofwinget upgrade --allandUpdate-MpSignature; add-SkipUpdatesto skip both.collectwrites 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
-Labelper cell:custom-sac-oncustom-sac-offggml-orgbuildupstream-sac-onupstream-sac-offThe 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:
ActivityID, never by timestamp 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 thanllama-server.exe.Do not enable Windows test-signing mode; it changes enforcement conditions and invalidates the run.
The CI workflow
windows-llama-signature-audit.ymldoes 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
enforcedefault once it has.Related
llama-common.dllin Windows install validation.