Skip to content

Studio: remove the Windows VBS launcher to clear the Kaspersky false positive - #6326

Merged
danielhanchen merged 3 commits into
mainfrom
harden-studio-launcher-native
Jun 16, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
harden-studio-launcher-native

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Problem

Some Windows users on Kaspersky saw Unsloth Studio flagged as HEUR:Trojan.VBS.Agent.gen during an update. The launcher is benign, but the shape of the Windows shortcut chain is exactly what generic VBS-dropper heuristics score:

Unsloth Studio.lnk  ->  wscript.exe //B //Nologo launch-studio.vbs
                    ->  powershell -ExecutionPolicy Bypass -File launch-studio.ps1

A generated .vbs that uses CreateObject("WScript.Shell").Run to start a hidden -ExecutionPolicy Bypass PowerShell is the canonical trigger for that detection family. This removes that shape.

What this does

The launch chain collapses to Unsloth Studio.lnk -> powershell.exe -WindowStyle Hidden -File launch-studio.ps1. There is no .vbs and no wscript.exe anywhere in the path.

Stop generating the VBS, and delete any legacy one. New installs no longer write launch-studio.vbs, and an upgrade now deletes a pre-existing one so the flagged file does not linger on machines that already installed it. The .lnk points straight at powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File launch-studio.ps1, and the shortcut is saved with WindowStyle = 7 (minimized) so the brief console flash is muted. launch-studio.ps1 itself (health-check /api/health, port selection, single-instance mutex, browser open) is unchanged.

Trim install-time heuristics. The ie4uinit -ClearIconCache plus StartMenuExperienceHost tile-cache rebuild now run only on a first install or a real icon change (SHA-256 compared before/after), instead of on every no-op reinstall. That repeated clear-cache plus kill cluster is itself a dropper-like behavioral pattern. The same gate is mirrored in the WSL shortcut path in install.sh.

Cross-platform

Linux, macOS and WSL installs are unchanged. WSL already targeted wsl.exe from its .lnk and never used a VBS; the only WSL change is the icon-cache gating above. install.sh has no VBS on any path. Uninstall already removes the whole data dir, so nothing is left behind.

CI

studio-windows-ui-smoke.yml: the shortcut launch path was previously untested (the job booted unsloth studio directly). It now seeds a legacy launch-studio.vbs, then after install asserts it was removed, asserts the .lnk targets hidden powershell.exe (never wscript.exe) with -WindowStyle Hidden, and launches via the shortcut's stored command and waits for /api/health to report healthy.

Test plan

  • tests/studio/install/test_launch_studio_launcher.py forbids VBS generation, requires the legacy-VBS cleanup, and asserts the shortcut is windowless PowerShell over launch-studio.ps1 and never wscript.exe.
  • Full local install test suite passes; install.ps1 and install.sh parse clean.
  • Windows / macOS Studio smoke workflows exercise the install and (now) the shortcut launch.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the legacy launch-studio.vbs launcher with a new windowless native GUI launcher written in Rust (unsloth-studio-launcher) to prevent antivirus heuristics from flagging the installer. It updates install.ps1 and install.sh to fetch, verify, and configure this signed native launcher, with a windowless PowerShell fallback, and adds corresponding tests. The review feedback highlights critical compilation errors in the new Rust launcher code where HWND and HANDLE are treated as pointer types instead of isize as defined in windows-sys v0.59, resulting in mismatched types and missing methods like .is_null().

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

let wcap = wide(APP_TITLE);
unsafe {
MessageBoxW(
std::ptr::null_mut(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

In windows-sys v0.59, HWND is defined as isize rather than a pointer type. Passing std::ptr::null_mut() (which is *mut c_void) will cause a compilation error due to mismatched types. Use 0 instead.

Suggested change
std::ptr::null_mut(),
0,

let wfile = wide(&url);
unsafe {
ShellExecuteW(
std::ptr::null_mut(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

In windows-sys v0.59, HWND is defined as isize. Passing std::ptr::null_mut() will cause a compilation error. Use 0 instead.

Suggested change
std::ptr::null_mut(),
0,

break;
}
std::thread::sleep(Duration::from_millis(1000));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

In windows-sys v0.59, HANDLE is defined as isize. Since isize is a primitive integer type, it does not have an .is_null() method. Calling mutex.is_null() will result in a compilation error. Check mutex != 0 instead.

            if mutex != 0 {

message_box(&msg);
}

if !mutex.is_null() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

In windows-sys v0.59, HANDLE is defined as isize. Calling mutex.is_null() will result in a compilation error. Check mutex != 0 instead.

Suggested change
if !mutex.is_null() {
if mutex != 0 {

The Windows shortcut launched Unsloth Studio through wscript.exe ->
launch-studio.vbs, and that VBS used CreateObject("WScript.Shell").Run to
start a hidden -ExecutionPolicy Bypass PowerShell. That wscript + .vbs +
bypass-powershell shape is the canonical trigger for generic VBS-dropper
heuristics (Kaspersky HEUR:Trojan.VBS.Agent.gen). The launcher is benign;
only its shape is the problem.

- install.ps1: stop generating launch-studio.vbs and point the Desktop /
  Start Menu .lnk straight at powershell.exe -WindowStyle Hidden running
  launch-studio.ps1. The shortcut is saved WindowStyle 7 (minimized) so the
  brief console flash is muted. launch-studio.ps1 (health poll, port,
  mutex, browser) is byte-for-byte unchanged.
- install.ps1: delete a pre-existing launch-studio.vbs on upgrade, so the
  flagged file does not linger on machines that already installed it.
- install.ps1 / install.sh: run the heavier ie4uinit -ClearIconCache plus
  StartMenuExperienceHost tile-cache rebuild only on a first install or a
  real icon change, instead of on every no-op reinstall. That repeated
  clear-cache plus kill cluster is itself a dropper-like behavioral pattern.
- tests: forbid VBS generation and require the legacy-VBS cleanup.

Linux, macOS and WSL install paths are unchanged. WSL already targets
wsl.exe from its .lnk and never used a VBS; its only change is the same
icon-cache gating.
The shortcut launch path was previously untested: studio-windows-ui-smoke
installed then booted `unsloth studio` directly, so a broken .lnk could ship
silently. After install the job now seeds a legacy launch-studio.vbs, asserts
the upgrade removed it, asserts the .lnk targets hidden powershell.exe (never
wscript.exe), and launches via the shortcut's stored command, waiting for
/api/health to report healthy.
@danielhanchen
danielhanchen force-pushed the harden-studio-launcher-native branch from 9c87a92 to b4c3211 Compare June 15, 2026 11:42
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: f9fdcf4cdf

ℹ️ 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
danielhanchen merged commit d50a2e2 into main Jun 16, 2026
41 checks passed
@danielhanchen
danielhanchen deleted the harden-studio-launcher-native branch June 16, 2026 11:00
danielhanchen added a commit that referenced this pull request Sep 15, 2026
…scarding the packets

Every report of security software blocking Unsloth (#8523, #6326, #6588, #6648, #10540, #10805) named
no antivirus product, no detection name and no AMSI provider. Clearance is per hash and vendors act on
a detection name, so not one of those reports could be submitted anywhere, and not one of the six
hardening passes since can be shown to have fixed what it aimed at. That is the gap here.

## A required-field issue form

`.github/ISSUE_TEMPLATE/install-blocked-windows.yml`, a form rather than a markdown template for one
reason: a form can mark a field `required` and a template cannot. Required: the product and version,
the detection name exactly as displayed, the full error including the `FullyQualifiedErrorId` line,
and the output of a collection script. Also a dropdown separating "the script would not run at all"
from "something it created was blocked", because those are different mechanisms with different fixes
and have been conflated in past reports.

The script reads registered antivirus products from `root/SecurityCenter2`, resolves each AMSI
provider CLSID through `InprocServer32` to a DLL and reads its `CompanyName`/`ProductName`/version,
then `Get-MpComputerStatus` and recent Defender events. The provider resolution is the part that
actually answers "which product", since a bare CLSID is not actionable. So is `AMRunningMode`:
anything other than `Normal` means another product is primary.

It downloads nothing, writes nothing, and changes nothing -- and it deliberately carries none of the
shapes the installers are being cleaned of, because a diagnostic that trips the same product that
blocked the installer is worthless. A test enforces that: no `Add-Type`, no `Invoke-Expression`, no
base64, no `Set-MpPreference`, no `Remove-Item`, no `Start-Process`.

## The packets that were being thrown away

Two false-positive submission packets are built today and discarded. `release-desktop.yml` writes a
Microsoft submission packet to `$RUNNER_TEMP` and never uploads it, so `flagged-windows-bundles-*`
held the flagged bundles and nothing describing them; it is now included in that artifact. And
`scripts/virustotal_scan.py`'s packet went only into a job summary, which is ephemeral, so the one
document written for the purpose of disputing a detection was discarded along with the run; it is now
kept as an artifact.

Retention on the flagged bundles goes from 7 days to 90. Clearance is per hash and a rebuild hashes
differently, so those copies are the only submittable sample for that release, and a vendor round trip
plus our own reaction routinely outlasts a week -- after which the evidence for the detection being
disputed is gone.

`test_the_scan_job_is_not_conditioned_away` allowed `if: always()` on exactly one step. The new upload
needs it for the identical stated reason, "precisely so the evidence survives a failed scan", so the
exception becomes a named set of two rather than a shape a future step could inherit by resembling.

## Verification

- 675 passed, 6 skipped across `tests/security/` and `tests/python/test_virustotal_scan.py`.
- The collection script is extracted from the YAML and **parsed**, not eyeballed. It is pasted
  verbatim by people who are already stuck, so a syntax error in it costs them a round trip and
  reports our form instead of their antivirus. It also runs end to end under pwsh on Linux, where
  every Windows-only facility reports itself unavailable and nothing crashes.
- That guard earned itself immediately: the first draft put the script in a YAML **folded** scalar
  (`>`), which joins every line and silently collapsed the whole code block to nothing. The test
  catches that specific mistake and names it as the likely cause.
- Both new guards confirmed to bite: reverting the scalar to `>` fails three tests, and making
  `detection-name` optional fails with the reason the field exists.
danielhanchen added a commit that referenced this pull request Sep 15, 2026
…scarding the packets

Every report of security software blocking Unsloth (#8523, #6326, #6588, #6648, #10540, #10805) named
no antivirus product, no detection name and no AMSI provider. Clearance is per hash and vendors act on
a detection name, so not one of those reports could be submitted anywhere, and not one of the six
hardening passes since can be shown to have fixed what it aimed at. That is the gap here.

## A required-field issue form

`.github/ISSUE_TEMPLATE/install-blocked-windows.yml`, a form rather than a markdown template for one
reason: a form can mark a field `required` and a template cannot. Required: the product and version,
the detection name exactly as displayed, the full error including the `FullyQualifiedErrorId` line,
and the output of a collection script. Also a dropdown separating "the script would not run at all"
from "something it created was blocked", because those are different mechanisms with different fixes
and have been conflated in past reports.

The script reads registered antivirus products from `root/SecurityCenter2`, resolves each AMSI
provider CLSID through `InprocServer32` to a DLL and reads its `CompanyName`/`ProductName`/version,
then `Get-MpComputerStatus` and recent Defender events. The provider resolution is the part that
actually answers "which product", since a bare CLSID is not actionable. So is `AMRunningMode`:
anything other than `Normal` means another product is primary.

It downloads nothing, writes nothing, and changes nothing -- and it deliberately carries none of the
shapes the installers are being cleaned of, because a diagnostic that trips the same product that
blocked the installer is worthless. A test enforces that: no `Add-Type`, no `Invoke-Expression`, no
base64, no `Set-MpPreference`, no `Remove-Item`, no `Start-Process`.

## The packets that were being thrown away

Two false-positive submission packets are built today and discarded. `release-desktop.yml` writes a
Microsoft submission packet to `$RUNNER_TEMP` and never uploads it, so `flagged-windows-bundles-*`
held the flagged bundles and nothing describing them; it is now included in that artifact. And
`scripts/virustotal_scan.py`'s packet went only into a job summary, which is ephemeral, so the one
document written for the purpose of disputing a detection was discarded along with the run; it is now
kept as an artifact.

Retention on the flagged bundles goes from 7 days to 90. Clearance is per hash and a rebuild hashes
differently, so those copies are the only submittable sample for that release, and a vendor round trip
plus our own reaction routinely outlasts a week -- after which the evidence for the detection being
disputed is gone.

`test_the_scan_job_is_not_conditioned_away` allowed `if: always()` on exactly one step. The new upload
needs it for the identical stated reason, "precisely so the evidence survives a failed scan", so the
exception becomes a named set of two rather than a shape a future step could inherit by resembling.

## Verification

- 675 passed, 6 skipped across `tests/security/` and `tests/python/test_virustotal_scan.py`.
- The collection script is extracted from the YAML and **parsed**, not eyeballed. It is pasted
  verbatim by people who are already stuck, so a syntax error in it costs them a round trip and
  reports our form instead of their antivirus. It also runs end to end under pwsh on Linux, where
  every Windows-only facility reports itself unavailable and nothing crashes.
- That guard earned itself immediately: the first draft put the script in a YAML **folded** scalar
  (`>`), which joins every line and silently collapsed the whole code block to nothing. The test
  catches that specific mistake and names it as the likely cause.
- Both new guards confirmed to bite: reverting the scalar to `>` fails three tests, and making
  `detection-name` optional fails with the reason the field exists.
danielhanchen added a commit that referenced this pull request Sep 15, 2026
…stead of arguing that it does not

Six antivirus-hardening passes have shipped (#7822, #8586, #6326, #10540, #10560, #10504). Each was
argued safe in prose, because there was no way to show it. The worry that hardening breaks
functionality is the right worry, and the answer to it is a measurement, not a more careful argument.

This lane installs from the merge base and from the candidate on two identical Windows runners and
compares four things. Zero differences is the pass condition.

- **The transcript.** Every line the installer printed, normalised. `step` pads its label to exactly
  15 columns and the output lock pins the indent, so leading whitespace is compared and only
  trailing whitespace is stripped.
- **The `.lnk` launch contract**, read back through the shell rather than taken from the installer's
  own log: target, arguments, working directory, window style, icon. `arguments` carries
  `-WindowStyle` and `-ExecutionPolicy`, which is the pair this whole effort is about, and a change
  there is completely invisible in the transcript -- which is what a prose review looks at.
- **The generated files** whose text is a contract: `launch-studio.ps1`, `unsloth.cmd`,
  `share/studio.conf`, plus the shape of the install tree.
- **Idempotency**, by installing twice. Several of the changes this lane judges touch
  content-comparison paths -- the code deciding whether a launcher needs rewriting at all -- so "a
  reinstall writes nothing" is a contract that can break silently.

## VOID is not a pass

Same commit on both sides, missing evidence, an installer that did not finish, a checkout that
resolved to the wrong tree: each is reported as "nothing was measured" and exits **3**, distinct from
**2** for "it changed", because those need different reactions from whoever reads the run.

Two of those guards exist because the failure actually happened while building this:

- A collection error on both sides compared equal to itself. Two runs that both failed to read any
  shortcut reported "1 compared, every field equal" and exited zero. Failures are symmetric far more
  often than behaviour changes are, since they come from the host and both sides share it, so the
  symmetry is no comfort at all. Any entry carrying an `error` is now VOID.
- `ConvertTo-Json` unwraps a one-element collection into a bare object, and `-AsArray` does not exist
  on Windows PowerShell 5.1. With exactly one shortcut found, `shortcuts.json` was an object;
  iterating that yields dictionary *keys*, so two different launch contracts would have compared as
  agreement. Forced to an array on the producing side and tolerated on the consuming side.

The `measure` job also asserts that `git rev-parse HEAD` equals the SHA it asked for. A checkout that
silently resolved to the default branch would make both sides the same tree, the comparison trivially
pass, and the lane report that a change broke nothing while never having seen the change.

Both sides are measured with the tools from the candidate, never each side's own copy: a base commit
that predates them has neither, and measuring two sides with two different rulers is not a
measurement.

## The comparer can fail, and that is tested

A differ reporting no differences looks identical whether it is working or broken, so the comparer
carries positive controls and refuses to produce a verdict if they fail. They run twice: once before
either install starts, so a drifted normaliser costs seconds rather than ninety minutes of runner
time ending in a meaningless green check, and once immediately before the verdict.

20 unit tests in `tests/python/test_installer_differential_comparer.py`, weighted toward the failure
direction. A changed output line, a lost indent, `RemoteSigned` becoming `Bypass` in a shortcut, a
shortcut that stopped being created, a changed generated launcher, a second run that rewrote
something -- each must be reported. One of them widens the normaliser until it erases every line and
requires the self-test to notice, because a control that cannot fail is decoration.

The other direction is tested too, since a lane that fails on every run gets disabled, which costs
the same coverage by a slower route: a `uv` patch release and a 30-second timing difference must not
fail it. Version drift is normalised away **and printed anyway** -- silently normalising something
and never mentioning it is how a lane stops being able to tell you anything. Every normalisation rule
carries a written cause, enforced by a test, because that list is exactly where a future "just make
it green" change would land.

## Cost

Two full clean-machine installs, so it opts in: the `installer-differential` label, a dispatch, or
the weekly schedule. `synchronize` is in the trigger list so a labelled PR keeps being re-measured as
it is pushed to, rather than the verdict being about whichever commit was there when the label went
on. Not a required check.

## What it cannot answer

Nothing about a third-party antivirus: hosted runners have none, and installing an endpoint agent per
run is neither fast nor faithful. Nothing about Windows PowerShell 5.1 at a real console either --
that is `windows-vt-preflight.yml`.

## Verification

- 887 passed, 9 skipped across `tests/security/`, the new comparer tests, the workflow-trigger lint
  and the installer shape suite.
- The collector was run end to end under `pwsh` on Linux, feeding the real comparer. That is what
  exposed both JSON defects above and a third: `Join-Path` throws on a null path, and composing
  `%APPDATA%` unconditionally made a parse-clean script print a binding error before doing any work.
- `Parser::ParseFile` clean on the collector; the workflow parses as YAML with the three expected
  jobs.
danielhanchen added a commit that referenced this pull request Sep 15, 2026
…already worked

Six hardening passes shipped with no measurement (#7822, #8586, #6326, #10540, #10560, #10504). There
was no baseline to measure against. There is one now: install.ps1 at commit 1ad4467 is the revision
reported in #10805, it hashes to ec29980b..., and VirusTotal holds its verdict.

## The result, run live against the real key

    | | baseline (1ad4467) | main (2c70592a) |
    | engines flagging | 1 / 60                | 1 / 61          |
    | which            | Skyhigh BehavesLike.PS.Suspicious.gr | the same |
    | Sigma            | 17 (high 1, medium 11, low 5) | 14 (medium 10, low 4) |
    | YARA             | 2                     | 0               |

The **high**-severity Sigma rule is gone. So are both crowdsourced YARA hits,
`INDICATOR_SUSPICIOUS_PWSH_B64Encoded_Concatenated_FileEXEC` and `Windows_API_Function`. Three fewer
Sigma rules overall. The Skyhigh verdict has not moved, and that is reported as unchanged rather than
dressed up: a cloud behavioural verdict is not recomputed because we deleted some code.

So the static indicators, which are what drives the alarming scores third-party analysis sites report,
already improved measurably. That was not knowable before.

Two corrections to what I wrote in the plan, both from running this rather than reasoning about it:

- I recorded current main's install.ps1 as **not on VirusTotal**. It is. It has been scanned since,
  so the delta above is real and not a projection.
- I treated the prior passes as unverifiable. They are verifiable, retroactively, and they worked on
  the axis they could affect.

## Three axes, separately

Reporting only the engine count makes every shape win look like it achieved nothing. Reporting only
Sigma overclaims. Both, or the number is not worth having.

Engines are compared **by name**, not by count. A count-only comparison calls the single most
consequential possible change -- Skyhigh's detection being replaced by Microsoft's, one engine before
and one after -- "no difference". Defender is on every Windows machine; Skyhigh is enterprise-deployed.
There is a test for exactly that case.

Sigma is compared **per severity**, not in total. Trading one high for three lows is an improvement a
total calls a regression, and the reverse is a regression a total calls an improvement.

## GET only, and VOID is not clean

There is no upload path, and that is a deliberate omission rather than an oversight. A freshly
uploaded file is a prevalence-zero, first-seen sample, which is exactly what `CloudBlockLevel
HighPlus` and ASR rule `01443614` punish -- so uploading a candidate can *create* the detection it was
meant to measure, under a hash no user will ever have. Released artefacts are uploaded by
`virustotal_scan.py` at release time; branches are not. A test parses the module and asserts no
non-GET method appears, having first been written as a grep and caught matching the module's own
explanation of why there is no upload.

So an unknown hash is VOID, exit 3, never clean. Also VOID: a missing `VT_API_KEY`, and a file
VirusTotal knows but has never analysed -- that last one being the subtle case, because zero engine
verdicts is not sixty engines clearing the file. Exit codes are distinct: 3 could-not-measure, 2
worse, 0 not worse.

## The baseline is checked, not trusted

A baseline hash copied out of an issue is a number nobody can verify, and if it ever pointed at the
wrong file every delta reported against it would be wrong while the lane looked perfectly healthy. So
both a test and a workflow step recompute it from this repository's history -- `git show
1ad4467:install.ps1` -- and assert the 427,113 bytes the sample is recorded as. A shallow clone
skips rather than fails.

## Verification

- 613 passed, 6 skipped across `tests/security/`, including 25 new tests.
- Run live against the real key; the table above is its actual output.
- Weighted toward the failure direction: a new high-severity rule, a new YARA hit, an engine swap at
  an unchanged count, and a medium promoted to high must each be reported as worse. One test replaces
  the comparison with one that reports nothing and requires the self-test to notice, because a
  control that cannot fail is decoration.
- Both parsers are fuzzed against schema drift. VirusTotal has renamed and added buckets over time,
  and a crash would break the measurement on precisely the day the schema moved.
danielhanchen added a commit that referenced this pull request Sep 15, 2026
…op discarding the false-positive submission packets (#10986)

* Capture the evidence six reports of this never contained, and stop discarding the packets

Every report of security software blocking Unsloth (#8523, #6326, #6588, #6648, #10540, #10805) named
no antivirus product, no detection name and no AMSI provider. Clearance is per hash and vendors act on
a detection name, so not one of those reports could be submitted anywhere, and not one of the six
hardening passes since can be shown to have fixed what it aimed at. That is the gap here.

## A required-field issue form

`.github/ISSUE_TEMPLATE/install-blocked-windows.yml`, a form rather than a markdown template for one
reason: a form can mark a field `required` and a template cannot. Required: the product and version,
the detection name exactly as displayed, the full error including the `FullyQualifiedErrorId` line,
and the output of a collection script. Also a dropdown separating "the script would not run at all"
from "something it created was blocked", because those are different mechanisms with different fixes
and have been conflated in past reports.

The script reads registered antivirus products from `root/SecurityCenter2`, resolves each AMSI
provider CLSID through `InprocServer32` to a DLL and reads its `CompanyName`/`ProductName`/version,
then `Get-MpComputerStatus` and recent Defender events. The provider resolution is the part that
actually answers "which product", since a bare CLSID is not actionable. So is `AMRunningMode`:
anything other than `Normal` means another product is primary.

It downloads nothing, writes nothing, and changes nothing -- and it deliberately carries none of the
shapes the installers are being cleaned of, because a diagnostic that trips the same product that
blocked the installer is worthless. A test enforces that: no `Add-Type`, no `Invoke-Expression`, no
base64, no `Set-MpPreference`, no `Remove-Item`, no `Start-Process`.

## The packets that were being thrown away

Two false-positive submission packets are built today and discarded. `release-desktop.yml` writes a
Microsoft submission packet to `$RUNNER_TEMP` and never uploads it, so `flagged-windows-bundles-*`
held the flagged bundles and nothing describing them; it is now included in that artifact. And
`scripts/virustotal_scan.py`'s packet went only into a job summary, which is ephemeral, so the one
document written for the purpose of disputing a detection was discarded along with the run; it is now
kept as an artifact.

Retention on the flagged bundles goes from 7 days to 90. Clearance is per hash and a rebuild hashes
differently, so those copies are the only submittable sample for that release, and a vendor round trip
plus our own reaction routinely outlasts a week -- after which the evidence for the detection being
disputed is gone.

`test_the_scan_job_is_not_conditioned_away` allowed `if: always()` on exactly one step. The new upload
needs it for the identical stated reason, "precisely so the evidence survives a failed scan", so the
exception becomes a named set of two rather than a shape a future step could inherit by resembling.

## Verification

- 675 passed, 6 skipped across `tests/security/` and `tests/python/test_virustotal_scan.py`.
- The collection script is extracted from the YAML and **parsed**, not eyeballed. It is pasted
  verbatim by people who are already stuck, so a syntax error in it costs them a round trip and
  reports our form instead of their antivirus. It also runs end to end under pwsh on Linux, where
  every Windows-only facility reports itself unavailable and nothing crashes.
- That guard earned itself immediately: the first draft put the script in a YAML **folded** scalar
  (`>`), which joins every line and silently collapsed the whole code block to nothing. The test
  catches that specific mistake and names it as the likely cause.
- Both new guards confirmed to bite: reverting the scalar to `>` fails three tests, and making
  `detection-name` optional fails with the reason the field exists.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Upload the submission packet after the step that writes it, and make the form's labels real

Two defects found reviewing this PR, both of which would have failed silently.

## The packet was uploaded sixty lines before it was written

`Preserve flagged Windows bundles` is step 24; the packet is assembled in step 26. Steps run top to
bottom, so `${{ runner.temp }}/ms-submission-packet.md` never existed when that upload ran -- and
`if-no-files-found: ignore` would have hidden it permanently. The artefact meant to carry a vendor
submission would have held the flagged bundles and nothing describing them, which is the exact
failure this PR exists to fix, reintroduced one step higher up.

The packet now has its own upload step immediately after the step that writes it. The path is
removed from the earlier step rather than left in as harmless, because a path that cannot match is a
claim the file is covered. Removing it also avoids a side effect worth knowing: upload-artifact
computes the artefact root from glob pattern prefixes rather than matched files, so the second path
would have re-rooted that zip from flat to nested.

`if-no-files-found: ignore`, not `warn`: the packet is only assembled when there is something to
submit, so its absence on a clean release is the normal case and must not add an annotation to every
green run.

## Two of the form's three labels did not exist

`windows` and `antivirus-false-positive` were not among the repository's labels. GitHub does not
error on an unknown label, it drops it -- so every issue filed through this form would have arrived
with `bug` only, losing precisely the two triage labels the form exists to attach, with nothing
reporting the loss.

Both labels now exist on the repository, and `test_the_labels_the_form_declares_are_real` keeps the
form and the repository in step. It checks against a checked-in list rather than the GitHub API,
because a test that needs the network is a test that gets skipped.

* Start pwsh through the shared runner here too

Same reason as the sibling fix in the AMSI probe lane: tests/studio/test_pwsh_calls_use_the_shared_runner.py
bans a direct subprocess call to pwsh, because a direct one shares a single
$XDG_CACHE_HOME/powershell startup cache with every xdist worker and an interpreter that dies at
startup then reads as the script under test having failed.

Caught only by running the full suite against all ten open PRs merged into one tree; the guard lives
in tests/studio/ and never ran against this branch alone.

* Redact the profile directory and account name before the report is published

The collection block is a required field, so its output goes into a public issue, and it
printed Path and Process Name for every Defender detection in the last two hours whether or
not it had anything to do with Unsloth. On a normal machine those paths begin with the profile
directory and therefore carry the account name, and the file name can be anything the person
had open. The description also promised it touched no personal data, which was not true.

Redact at the point of printing rather than asking the reporter to do it, since the reporter is
someone whose install is already broken and who is pasting a block they did not write. Say
plainly what is still printed and tell them to read it first. Verified against paths with a
space in the name and with mismatched case.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Match the Defender event fields, which are indented

Defender renders 1116 and its siblings as a header line followed by indented 'Field: value'
lines, so anchoring on '^Name:' matched none of them and the section that exists to carry the
detection name, the path and the triggering process emitted a timestamp and an event id and
nothing else. Measured against a message in the documented shape: the old filter selects the
empty string, the new one selects all six fields.

Severity is included now too, since it is free once the line is being read and it is the field
that tells us whether a report is a block or a warning. The guard drives the snippet's own filter
rather than asserting the regex text, so a future rewrite is judged on what it extracts.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Give screenshots their own field, survive localised Defender labels, warn on the error field too

A render: textarea wraps everything it contains in a code fence, attachments included, so the
error field invited a screenshot it could never display. It keeps render: text, because it carries
pasted console output where the monospace block earns its place, and screenshots get their own
unrendered field.

Defender localises the event field labels, so the English-only filter missed them and a
non-English reporter would have sent a timestamp and an event id. Testing for an empty result is
not enough: German renders Name: identically, so one match out of six looks like a successful
extraction. The fallback counts instead, and prints the whole message, redacted and truncated,
when fewer than two fields resolve. Measured on English, German and Japanese messages.

The privacy note covered the probe output only. A PowerShell error quotes the script's location,
so on the documented cloned-checkout path the required error field carries the reporter's user
name and they are told to paste it verbatim before they reach that note. It now says the issue is
public and suggests the substitution.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Warn on the issue form field that asks for a full path

The error and probe fields say the issue is public and show what to
write instead, but the file path field asked for a full path with only a
profile-shaped placeholder to follow, so a reporter doing what it says
publishes their user name. Give it the same warning and the same worked
replacement.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Redact only real account components, and scope the probe's error preference

The username replacement rewrote every case-insensitive occurrence
anywhere in the line, so an account named win rewrote Windows Defender
and one named cat rewrote Wacatac. Those are the product and detection
names the form exists to collect, and the reporter cannot see it happen.
Require a path separator before the name and no word character after it.

The probe also set ErrorActionPreference at the prompt, which persists
for the rest of that session, against the field's own promise that it
changes nothing. Run the body in a script block so the assignment is
scoped to it.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen added a commit that referenced this pull request Sep 15, 2026
…already worked (#10996)

* Give this work a before-and-after number, and find out the hardening already worked

Six hardening passes shipped with no measurement (#7822, #8586, #6326, #10540, #10560, #10504). There
was no baseline to measure against. There is one now: install.ps1 at commit 1ad4467 is the revision
reported in #10805, it hashes to ec29980b..., and VirusTotal holds its verdict.

## The result, run live against the real key

    | | baseline (1ad4467) | main (2c70592a) |
    | engines flagging | 1 / 60                | 1 / 61          |
    | which            | Skyhigh BehavesLike.PS.Suspicious.gr | the same |
    | Sigma            | 17 (high 1, medium 11, low 5) | 14 (medium 10, low 4) |
    | YARA             | 2                     | 0               |

The **high**-severity Sigma rule is gone. So are both crowdsourced YARA hits,
`INDICATOR_SUSPICIOUS_PWSH_B64Encoded_Concatenated_FileEXEC` and `Windows_API_Function`. Three fewer
Sigma rules overall. The Skyhigh verdict has not moved, and that is reported as unchanged rather than
dressed up: a cloud behavioural verdict is not recomputed because we deleted some code.

So the static indicators, which are what drives the alarming scores third-party analysis sites report,
already improved measurably. That was not knowable before.

Two corrections to what I wrote in the plan, both from running this rather than reasoning about it:

- I recorded current main's install.ps1 as **not on VirusTotal**. It is. It has been scanned since,
  so the delta above is real and not a projection.
- I treated the prior passes as unverifiable. They are verifiable, retroactively, and they worked on
  the axis they could affect.

## Three axes, separately

Reporting only the engine count makes every shape win look like it achieved nothing. Reporting only
Sigma overclaims. Both, or the number is not worth having.

Engines are compared **by name**, not by count. A count-only comparison calls the single most
consequential possible change -- Skyhigh's detection being replaced by Microsoft's, one engine before
and one after -- "no difference". Defender is on every Windows machine; Skyhigh is enterprise-deployed.
There is a test for exactly that case.

Sigma is compared **per severity**, not in total. Trading one high for three lows is an improvement a
total calls a regression, and the reverse is a regression a total calls an improvement.

## GET only, and VOID is not clean

There is no upload path, and that is a deliberate omission rather than an oversight. A freshly
uploaded file is a prevalence-zero, first-seen sample, which is exactly what `CloudBlockLevel
HighPlus` and ASR rule `01443614` punish -- so uploading a candidate can *create* the detection it was
meant to measure, under a hash no user will ever have. Released artefacts are uploaded by
`virustotal_scan.py` at release time; branches are not. A test parses the module and asserts no
non-GET method appears, having first been written as a grep and caught matching the module's own
explanation of why there is no upload.

So an unknown hash is VOID, exit 3, never clean. Also VOID: a missing `VT_API_KEY`, and a file
VirusTotal knows but has never analysed -- that last one being the subtle case, because zero engine
verdicts is not sixty engines clearing the file. Exit codes are distinct: 3 could-not-measure, 2
worse, 0 not worse.

## The baseline is checked, not trusted

A baseline hash copied out of an issue is a number nobody can verify, and if it ever pointed at the
wrong file every delta reported against it would be wrong while the lane looked perfectly healthy. So
both a test and a workflow step recompute it from this repository's history -- `git show
1ad4467:install.ps1` -- and assert the 427,113 bytes the sample is recorded as. A shallow clone
skips rather than fails.

## Verification

- 613 passed, 6 skipped across `tests/security/`, including 25 new tests.
- Run live against the real key; the table above is its actual output.
- Weighted toward the failure direction: a new high-severity rule, a new YARA hit, an engine swap at
  an unchanged count, and a medium promoted to high must each be reported as worse. One test replaces
  the comparison with one that reports nothing and requires the self-test to notice, because a
  control that cannot fail is decoration.
- Both parsers are fuzzed against schema drift. VirusTotal has renamed and added buckets over time,
  and a crash would break the measurement on precisely the day the schema moved.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Read the VirusTotal secret this repository actually has, so the lane can measure something

`secrets.VT_API_KEY` does not exist. `VT_API_KEY` is the ENV VAR name the Python reads
(`scripts/virustotal_scan.py:37`); the repository secret is `VIRUS_TOTAL_API_TOKEN`, which is the only
VirusTotal secret in all 51 workflows, and `release-desktop.yml:2193` maps it the same way.

As written the expression expanded to empty and the lane exited 3 / VOID on every dispatch. That is
the right failure shape -- it refuses to report a clean it did not measure -- but a lane that can
never measure anything is not worth having, and the failure only surfaces after someone dispatches
it and waits.

Two guards added, because both halves of this were invisible:

- `test_the_workflow_reads_the_secret_this_repository_actually_has` pins the secret name in both
  directions and also asserts the checkout keeps `fetch-depth: 0`, since the step that reverifies
  the baseline against commit 1ad4467 reverifies nothing on a shallow clone.
- `test_the_baseline_hash_is_the_file_the_reporter_ran` now checks the constant's shape
  unconditionally before the git half. That git half skips on a shallow clone, which is every CI lane
  that collects `tests/security` -- so the one assertion tying the baseline to real history was green
  locally and silently absent everywhere it mattered.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Compare Sigma severities in order, and void an unanalysed baseline too

The per-severity comparison reported each bucket independently, which cannot express a trade:
swapping the single high rule for three extra low ones moves two buckets in opposite
directions, so it landed in worse and in better at once and exit_code answered worse. The
comment beside that loop calls exactly that swap an improvement. SEVERITIES is ordered most
severe first, so the most severe bucket that moved now decides and the rest are reported
alongside it without flipping the verdict.

The zero-engine guard was on the candidate only. A baseline hash VirusTotal knows but has never
analysed carries no engines, no Sigma and no YARA, so every finding on the candidate read as
newly introduced and the run exited 2 having compared against nothing.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Bound the lookups, keep ruleset identity, and escape third-party text

Neither lookup carried a deadline, and request can spend four 300-second socket attempts plus 20,
40 and 80 seconds of backoff. The workflow gives the whole job 20 minutes, so the baseline lookup
alone could exhaust it and the runner would kill the step before it fetched the candidate or wrote
its summary, which is a lost run rather than a reported one. Both lookups now share a 420 second
budget and an expired budget is reported as VOID, since we did not find out.

YARA hits were keyed on the rule name alone, so the same rule identifier appearing in two
crowdsourced rulesets collapsed to one entry: a candidate could gain a hit from a second ruleset,
parse to the same list as the baseline, and exit 0 on a real regression. Keyed on ruleset and rule
now.

Engine names and detection labels are third-party text and the report is appended to
GITHUB_STEP_SUMMARY, where a newline ends the row, a pipe opens a cell and an angle bracket starts
HTML that GitHub renders. virustotal_scan._md_text exists for exactly this and the report was
bypassing it; reused rather than duplicated.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Stop labelling an overridden baseline as the recorded install.ps1

A dispatch can supply baseline_sha256, and the lookup and the comparison then use that hash while
the header still announced the recorded identity and printed install.ps1's historical scores
beside the override's live table. That is an artifact built to be misattributed: the numbers
belong to one file and the name to another.

The note is now printed only when the baseline hash really is the recorded one, and an override
says so and disclaims the historical comparison.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Catch a spent deadline in the VirusTotal delta lookup

VirusTotalClient.request signals an expired deadline with TimeoutError,
which inherits from OSError rather than RuntimeError, so the handler in
fetch never ran and the workflow died with a traceback before render
wrote its summary. That is the lost run the deadline was meant to
prevent. Catch both and keep returning a VOID row.

* Keep Sigma buckets this tool cannot rank

The parser warned in its own docstring that VirusTotal renames and adds
severity buckets, then read a fixed key list, so a candidate that gained
rules only in a new bucket produced a dictionary identical to the
baseline's and the run exited 0 on a regression. Keep every reported
bucket. Unrankable ones stay out of the ordered trade-off, which depends
on knowing which of two buckets is more severe, and a rise in one is
reported as worse rather than assumed minor.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Count every engine verdict bucket, not the five the dataclass carries

parse_stats names type-unsupported and failure as categories VirusTotal
has added, but ScanStats has fields only for five buckets, so the engine
count this report prints was short by however many engines answered that
way, and a response made up entirely of those buckets summed to zero and
voided the run as unanalysed. Sum every numeric bucket from the raw
stats, which leaves the shared dataclass alone for the release scanner.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Require an explicit verdict before calling an engine cleared

An engine that flagged the baseline and is absent from the candidate's
results has not cleared it, it did not evaluate it, and a set difference
cannot tell those apart. Since Skyhigh is the one engine that actually
flags this file, a sparse candidate analysis could print the single most
consequential sentence in the report and exit 0. Track which engines
returned a verdict of any kind, call only an answering non-flagging
engine cleared, and report the silent ones as an unanswered question.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Only a conclusive verdict clears a prior detection

The responder set was built on the truthiness of the category, so
timeout, confirmed-timeout, failure and type-unsupported counted as
answers while parse_detections correctly left them out of the flagging
list. An engine returning one of those appeared in neither set and was
reported as having stopped flagging the candidate, which is the same
mistake as treating absence as a clean verdict.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…op discarding the false-positive submission packets (unslothai#10986)

* Capture the evidence six reports of this never contained, and stop discarding the packets

Every report of security software blocking Unsloth (unslothai#8523, unslothai#6326, unslothai#6588, unslothai#6648, unslothai#10540, unslothai#10805) named
no antivirus product, no detection name and no AMSI provider. Clearance is per hash and vendors act on
a detection name, so not one of those reports could be submitted anywhere, and not one of the six
hardening passes since can be shown to have fixed what it aimed at. That is the gap here.

## A required-field issue form

`.github/ISSUE_TEMPLATE/install-blocked-windows.yml`, a form rather than a markdown template for one
reason: a form can mark a field `required` and a template cannot. Required: the product and version,
the detection name exactly as displayed, the full error including the `FullyQualifiedErrorId` line,
and the output of a collection script. Also a dropdown separating "the script would not run at all"
from "something it created was blocked", because those are different mechanisms with different fixes
and have been conflated in past reports.

The script reads registered antivirus products from `root/SecurityCenter2`, resolves each AMSI
provider CLSID through `InprocServer32` to a DLL and reads its `CompanyName`/`ProductName`/version,
then `Get-MpComputerStatus` and recent Defender events. The provider resolution is the part that
actually answers "which product", since a bare CLSID is not actionable. So is `AMRunningMode`:
anything other than `Normal` means another product is primary.

It downloads nothing, writes nothing, and changes nothing -- and it deliberately carries none of the
shapes the installers are being cleaned of, because a diagnostic that trips the same product that
blocked the installer is worthless. A test enforces that: no `Add-Type`, no `Invoke-Expression`, no
base64, no `Set-MpPreference`, no `Remove-Item`, no `Start-Process`.

## The packets that were being thrown away

Two false-positive submission packets are built today and discarded. `release-desktop.yml` writes a
Microsoft submission packet to `$RUNNER_TEMP` and never uploads it, so `flagged-windows-bundles-*`
held the flagged bundles and nothing describing them; it is now included in that artifact. And
`scripts/virustotal_scan.py`'s packet went only into a job summary, which is ephemeral, so the one
document written for the purpose of disputing a detection was discarded along with the run; it is now
kept as an artifact.

Retention on the flagged bundles goes from 7 days to 90. Clearance is per hash and a rebuild hashes
differently, so those copies are the only submittable sample for that release, and a vendor round trip
plus our own reaction routinely outlasts a week -- after which the evidence for the detection being
disputed is gone.

`test_the_scan_job_is_not_conditioned_away` allowed `if: always()` on exactly one step. The new upload
needs it for the identical stated reason, "precisely so the evidence survives a failed scan", so the
exception becomes a named set of two rather than a shape a future step could inherit by resembling.

## Verification

- 675 passed, 6 skipped across `tests/security/` and `tests/python/test_virustotal_scan.py`.
- The collection script is extracted from the YAML and **parsed**, not eyeballed. It is pasted
  verbatim by people who are already stuck, so a syntax error in it costs them a round trip and
  reports our form instead of their antivirus. It also runs end to end under pwsh on Linux, where
  every Windows-only facility reports itself unavailable and nothing crashes.
- That guard earned itself immediately: the first draft put the script in a YAML **folded** scalar
  (`>`), which joins every line and silently collapsed the whole code block to nothing. The test
  catches that specific mistake and names it as the likely cause.
- Both new guards confirmed to bite: reverting the scalar to `>` fails three tests, and making
  `detection-name` optional fails with the reason the field exists.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Upload the submission packet after the step that writes it, and make the form's labels real

Two defects found reviewing this PR, both of which would have failed silently.

## The packet was uploaded sixty lines before it was written

`Preserve flagged Windows bundles` is step 24; the packet is assembled in step 26. Steps run top to
bottom, so `${{ runner.temp }}/ms-submission-packet.md` never existed when that upload ran -- and
`if-no-files-found: ignore` would have hidden it permanently. The artefact meant to carry a vendor
submission would have held the flagged bundles and nothing describing them, which is the exact
failure this PR exists to fix, reintroduced one step higher up.

The packet now has its own upload step immediately after the step that writes it. The path is
removed from the earlier step rather than left in as harmless, because a path that cannot match is a
claim the file is covered. Removing it also avoids a side effect worth knowing: upload-artifact
computes the artefact root from glob pattern prefixes rather than matched files, so the second path
would have re-rooted that zip from flat to nested.

`if-no-files-found: ignore`, not `warn`: the packet is only assembled when there is something to
submit, so its absence on a clean release is the normal case and must not add an annotation to every
green run.

## Two of the form's three labels did not exist

`windows` and `antivirus-false-positive` were not among the repository's labels. GitHub does not
error on an unknown label, it drops it -- so every issue filed through this form would have arrived
with `bug` only, losing precisely the two triage labels the form exists to attach, with nothing
reporting the loss.

Both labels now exist on the repository, and `test_the_labels_the_form_declares_are_real` keeps the
form and the repository in step. It checks against a checked-in list rather than the GitHub API,
because a test that needs the network is a test that gets skipped.

* Start pwsh through the shared runner here too

Same reason as the sibling fix in the AMSI probe lane: tests/studio/test_pwsh_calls_use_the_shared_runner.py
bans a direct subprocess call to pwsh, because a direct one shares a single
$XDG_CACHE_HOME/powershell startup cache with every xdist worker and an interpreter that dies at
startup then reads as the script under test having failed.

Caught only by running the full suite against all ten open PRs merged into one tree; the guard lives
in tests/studio/ and never ran against this branch alone.

* Redact the profile directory and account name before the report is published

The collection block is a required field, so its output goes into a public issue, and it
printed Path and Process Name for every Defender detection in the last two hours whether or
not it had anything to do with Unsloth. On a normal machine those paths begin with the profile
directory and therefore carry the account name, and the file name can be anything the person
had open. The description also promised it touched no personal data, which was not true.

Redact at the point of printing rather than asking the reporter to do it, since the reporter is
someone whose install is already broken and who is pasting a block they did not write. Say
plainly what is still printed and tell them to read it first. Verified against paths with a
space in the name and with mismatched case.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Match the Defender event fields, which are indented

Defender renders 1116 and its siblings as a header line followed by indented 'Field: value'
lines, so anchoring on '^Name:' matched none of them and the section that exists to carry the
detection name, the path and the triggering process emitted a timestamp and an event id and
nothing else. Measured against a message in the documented shape: the old filter selects the
empty string, the new one selects all six fields.

Severity is included now too, since it is free once the line is being read and it is the field
that tells us whether a report is a block or a warning. The guard drives the snippet's own filter
rather than asserting the regex text, so a future rewrite is judged on what it extracts.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Give screenshots their own field, survive localised Defender labels, warn on the error field too

A render: textarea wraps everything it contains in a code fence, attachments included, so the
error field invited a screenshot it could never display. It keeps render: text, because it carries
pasted console output where the monospace block earns its place, and screenshots get their own
unrendered field.

Defender localises the event field labels, so the English-only filter missed them and a
non-English reporter would have sent a timestamp and an event id. Testing for an empty result is
not enough: German renders Name: identically, so one match out of six looks like a successful
extraction. The fallback counts instead, and prints the whole message, redacted and truncated,
when fewer than two fields resolve. Measured on English, German and Japanese messages.

The privacy note covered the probe output only. A PowerShell error quotes the script's location,
so on the documented cloned-checkout path the required error field carries the reporter's user
name and they are told to paste it verbatim before they reach that note. It now says the issue is
public and suggests the substitution.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Warn on the issue form field that asks for a full path

The error and probe fields say the issue is public and show what to
write instead, but the file path field asked for a full path with only a
profile-shaped placeholder to follow, so a reporter doing what it says
publishes their user name. Give it the same warning and the same worked
replacement.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Redact only real account components, and scope the probe's error preference

The username replacement rewrote every case-insensitive occurrence
anywhere in the line, so an account named win rewrote Windows Defender
and one named cat rewrote Wacatac. Those are the product and detection
names the form exists to collect, and the reporter cannot see it happen.
Require a path separator before the name and no word character after it.

The probe also set ErrorActionPreference at the prompt, which persists
for the rest of that session, against the field's own promise that it
changes nothing. Run the body in a script block so the assignment is
scoped to it.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…already worked (unslothai#10996)

* Give this work a before-and-after number, and find out the hardening already worked

Six hardening passes shipped with no measurement (unslothai#7822, unslothai#8586, unslothai#6326, unslothai#10540, unslothai#10560, unslothai#10504). There
was no baseline to measure against. There is one now: install.ps1 at commit 1ad4467 is the revision
reported in unslothai#10805, it hashes to ec29980b..., and VirusTotal holds its verdict.

## The result, run live against the real key

    | | baseline (1ad4467) | main (2c70592a) |
    | engines flagging | 1 / 60                | 1 / 61          |
    | which            | Skyhigh BehavesLike.PS.Suspicious.gr | the same |
    | Sigma            | 17 (high 1, medium 11, low 5) | 14 (medium 10, low 4) |
    | YARA             | 2                     | 0               |

The **high**-severity Sigma rule is gone. So are both crowdsourced YARA hits,
`INDICATOR_SUSPICIOUS_PWSH_B64Encoded_Concatenated_FileEXEC` and `Windows_API_Function`. Three fewer
Sigma rules overall. The Skyhigh verdict has not moved, and that is reported as unchanged rather than
dressed up: a cloud behavioural verdict is not recomputed because we deleted some code.

So the static indicators, which are what drives the alarming scores third-party analysis sites report,
already improved measurably. That was not knowable before.

Two corrections to what I wrote in the plan, both from running this rather than reasoning about it:

- I recorded current main's install.ps1 as **not on VirusTotal**. It is. It has been scanned since,
  so the delta above is real and not a projection.
- I treated the prior passes as unverifiable. They are verifiable, retroactively, and they worked on
  the axis they could affect.

## Three axes, separately

Reporting only the engine count makes every shape win look like it achieved nothing. Reporting only
Sigma overclaims. Both, or the number is not worth having.

Engines are compared **by name**, not by count. A count-only comparison calls the single most
consequential possible change -- Skyhigh's detection being replaced by Microsoft's, one engine before
and one after -- "no difference". Defender is on every Windows machine; Skyhigh is enterprise-deployed.
There is a test for exactly that case.

Sigma is compared **per severity**, not in total. Trading one high for three lows is an improvement a
total calls a regression, and the reverse is a regression a total calls an improvement.

## GET only, and VOID is not clean

There is no upload path, and that is a deliberate omission rather than an oversight. A freshly
uploaded file is a prevalence-zero, first-seen sample, which is exactly what `CloudBlockLevel
HighPlus` and ASR rule `01443614` punish -- so uploading a candidate can *create* the detection it was
meant to measure, under a hash no user will ever have. Released artefacts are uploaded by
`virustotal_scan.py` at release time; branches are not. A test parses the module and asserts no
non-GET method appears, having first been written as a grep and caught matching the module's own
explanation of why there is no upload.

So an unknown hash is VOID, exit 3, never clean. Also VOID: a missing `VT_API_KEY`, and a file
VirusTotal knows but has never analysed -- that last one being the subtle case, because zero engine
verdicts is not sixty engines clearing the file. Exit codes are distinct: 3 could-not-measure, 2
worse, 0 not worse.

## The baseline is checked, not trusted

A baseline hash copied out of an issue is a number nobody can verify, and if it ever pointed at the
wrong file every delta reported against it would be wrong while the lane looked perfectly healthy. So
both a test and a workflow step recompute it from this repository's history -- `git show
1ad4467:install.ps1` -- and assert the 427,113 bytes the sample is recorded as. A shallow clone
skips rather than fails.

## Verification

- 613 passed, 6 skipped across `tests/security/`, including 25 new tests.
- Run live against the real key; the table above is its actual output.
- Weighted toward the failure direction: a new high-severity rule, a new YARA hit, an engine swap at
  an unchanged count, and a medium promoted to high must each be reported as worse. One test replaces
  the comparison with one that reports nothing and requires the self-test to notice, because a
  control that cannot fail is decoration.
- Both parsers are fuzzed against schema drift. VirusTotal has renamed and added buckets over time,
  and a crash would break the measurement on precisely the day the schema moved.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Read the VirusTotal secret this repository actually has, so the lane can measure something

`secrets.VT_API_KEY` does not exist. `VT_API_KEY` is the ENV VAR name the Python reads
(`scripts/virustotal_scan.py:37`); the repository secret is `VIRUS_TOTAL_API_TOKEN`, which is the only
VirusTotal secret in all 51 workflows, and `release-desktop.yml:2193` maps it the same way.

As written the expression expanded to empty and the lane exited 3 / VOID on every dispatch. That is
the right failure shape -- it refuses to report a clean it did not measure -- but a lane that can
never measure anything is not worth having, and the failure only surfaces after someone dispatches
it and waits.

Two guards added, because both halves of this were invisible:

- `test_the_workflow_reads_the_secret_this_repository_actually_has` pins the secret name in both
  directions and also asserts the checkout keeps `fetch-depth: 0`, since the step that reverifies
  the baseline against commit 1ad4467 reverifies nothing on a shallow clone.
- `test_the_baseline_hash_is_the_file_the_reporter_ran` now checks the constant's shape
  unconditionally before the git half. That git half skips on a shallow clone, which is every CI lane
  that collects `tests/security` -- so the one assertion tying the baseline to real history was green
  locally and silently absent everywhere it mattered.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Compare Sigma severities in order, and void an unanalysed baseline too

The per-severity comparison reported each bucket independently, which cannot express a trade:
swapping the single high rule for three extra low ones moves two buckets in opposite
directions, so it landed in worse and in better at once and exit_code answered worse. The
comment beside that loop calls exactly that swap an improvement. SEVERITIES is ordered most
severe first, so the most severe bucket that moved now decides and the rest are reported
alongside it without flipping the verdict.

The zero-engine guard was on the candidate only. A baseline hash VirusTotal knows but has never
analysed carries no engines, no Sigma and no YARA, so every finding on the candidate read as
newly introduced and the run exited 2 having compared against nothing.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Bound the lookups, keep ruleset identity, and escape third-party text

Neither lookup carried a deadline, and request can spend four 300-second socket attempts plus 20,
40 and 80 seconds of backoff. The workflow gives the whole job 20 minutes, so the baseline lookup
alone could exhaust it and the runner would kill the step before it fetched the candidate or wrote
its summary, which is a lost run rather than a reported one. Both lookups now share a 420 second
budget and an expired budget is reported as VOID, since we did not find out.

YARA hits were keyed on the rule name alone, so the same rule identifier appearing in two
crowdsourced rulesets collapsed to one entry: a candidate could gain a hit from a second ruleset,
parse to the same list as the baseline, and exit 0 on a real regression. Keyed on ruleset and rule
now.

Engine names and detection labels are third-party text and the report is appended to
GITHUB_STEP_SUMMARY, where a newline ends the row, a pipe opens a cell and an angle bracket starts
HTML that GitHub renders. virustotal_scan._md_text exists for exactly this and the report was
bypassing it; reused rather than duplicated.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Stop labelling an overridden baseline as the recorded install.ps1

A dispatch can supply baseline_sha256, and the lookup and the comparison then use that hash while
the header still announced the recorded identity and printed install.ps1's historical scores
beside the override's live table. That is an artifact built to be misattributed: the numbers
belong to one file and the name to another.

The note is now printed only when the baseline hash really is the recorded one, and an override
says so and disclaims the historical comparison.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Catch a spent deadline in the VirusTotal delta lookup

VirusTotalClient.request signals an expired deadline with TimeoutError,
which inherits from OSError rather than RuntimeError, so the handler in
fetch never ran and the workflow died with a traceback before render
wrote its summary. That is the lost run the deadline was meant to
prevent. Catch both and keep returning a VOID row.

* Keep Sigma buckets this tool cannot rank

The parser warned in its own docstring that VirusTotal renames and adds
severity buckets, then read a fixed key list, so a candidate that gained
rules only in a new bucket produced a dictionary identical to the
baseline's and the run exited 0 on a regression. Keep every reported
bucket. Unrankable ones stay out of the ordered trade-off, which depends
on knowing which of two buckets is more severe, and a rise in one is
reported as worse rather than assumed minor.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Count every engine verdict bucket, not the five the dataclass carries

parse_stats names type-unsupported and failure as categories VirusTotal
has added, but ScanStats has fields only for five buckets, so the engine
count this report prints was short by however many engines answered that
way, and a response made up entirely of those buckets summed to zero and
voided the run as unanalysed. Sum every numeric bucket from the raw
stats, which leaves the shared dataclass alone for the release scanner.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Require an explicit verdict before calling an engine cleared

An engine that flagged the baseline and is absent from the candidate's
results has not cleared it, it did not evaluate it, and a set difference
cannot tell those apart. Since Skyhigh is the one engine that actually
flags this file, a sparse candidate analysis could print the single most
consequential sentence in the report and exit 0. Track which engines
returned a verdict of any kind, call only an answering non-flagging
engine cleared, and report the silent ones as an unanswered question.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Only a conclusive verdict clears a prior detection

The responder set was built on the truthiness of the category, so
timeout, confirmed-timeout, failure and type-unsupported counted as
answers while parse_detections correctly left them out of the flagging
list. An engine returning one of those appeared in neither set and was
reported as having stopped flagging the candidate, which is the same
mistake as treating absence as a clean verdict.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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