Skip to content

Release: sign every shipped PowerShell script and publish digests for the rest - #11069

Merged
danielhanchen merged 4 commits into
mainfrom
sign-shipped-scripts
Sep 16, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
sign-shipped-scripts

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Why

install.ps1 was already Authenticode signed, but only the copy the Windows bundler packs. A user who clones the repo, or fetches from raw.githubusercontent, gets an unsigned file. studio/setup.ps1 and scripts/uninstall.ps1 were never signed at all, and scripts/uninstall.ps1 is advertised to users as a one-liner pointing straight at raw.githubusercontent.

Separately, .gitattributes had no *.ps1 rule. Authenticode signs the bytes, so a line ending rewrite invalidates the signature. install.ps1 is LF with no BOM, so a Windows clone with core.autocrlf=true stored it back as CRLF and any signature would read HashMismatch, which WDAC treats as tampering. That is strictly worse than shipping unsigned, and it had to be fixed before attaching a signature to anything.

What

The release now stages all seven shipped scripts, signs the three PowerShell ones through the same Trusted Signing path the bundle already uses, and attaches them to the release with a SHA256SUMS.txt.

Signed: install.ps1, setup.ps1, uninstall.ps1.

Not signable, published with digests: install.sh, setup.sh, uninstall.sh, setup.bat. There is no Authenticode subject interface package for .sh or .bat, and Windows performs no signature check on a batch file at all, so a published digest is the most that can be done for those. They are staged alongside so SHA256SUMS.txt describes exactly the bytes the release serves, in the two-space form sha256sum -c accepts unmodified.

Three details worth review:

  • Copies, not the working tree, except install.ps1, which has to be signed in place because the bundler packs it. Signing setup.ps1 or uninstall.ps1 in place would append a signature block to files that later steps and tests still read.
  • Every staged .ps1 is re-verified with Get-AuthenticodeSignature, including the one the existing step signed, so a release cannot carry a script whose signature does not check out on the machine that produced it.
  • Its own artifact, download and upload. The artifact is deliberately not named desktop-release-*: the publish job merges that pattern into one directory and validates it against an exact bundle name list, which these assets would break. The bundle contract is untouched. No --clobber, matching the bundle upload, so a re-run fails rather than quietly replacing bytes whose digest has already been published.

Testing

  • test_release_uploads_never_clobber_or_mutate_the_legacy_channel pins the number of versioned uploads, so it failed on the new one. Updated from 2 to 3 with a comment saying which three, keeping the property that a new upload has to be added deliberately. Confirmed the guard still covers the new upload: adding --clobber to it fails the test.
  • The staging and digest logic was run end to end locally under pwsh with signing stubbed out, since Trusted Signing is Windows only. All seven files stage, SHA256SUMS.txt correctly excludes itself, and sha256sum -c SHA256SUMS.txt returns OK for every entry. The digests match the ones recorded for these same files on VirusTotal, which confirms the staged bytes are the shipped bytes.
  • The .gitattributes rule was proved by cloning with core.autocrlf=true both ways. Without the rule the checkout gains CRLF; with it the bytes are unchanged. git check-attr reports text: unset for all three shipped scripts.
  • Suites: 941 passed, 7 skipped across tests/security/ and the installer shape suite. Workflow lint and trigger tests: 373 passed, 56 skipped. The workflow still parses as YAML and the new steps land in the right jobs and order.

What this does not do

It does not change irm https://unsloth.ai/install.ps1 | iex. Invoke-Expression compiles a string, so there is no file, no execution policy evaluation and no signature check. Anyone reading this expecting it to close the antivirus reports should know that up front.

What it does buy: signer identity on VirusTotal, acceptance under AllSigned and RemoteSigned for a downloaded copy, WDAC and Smart App Control evaluation, and the signature every vendor false positive form asks for first. Skyhigh's verdict on install.ps1 is a behavioural score on an unsigned, zero prevalence file, and signature and prevalence are inputs to that kind of score in a way that renaming constructs demonstrably is not.

Repointing unsloth.ai/install.ps1 at the signed release asset is CDN configuration outside this repository, and would change fix latency from "merge to main" to "cut a release". Not part of this PR.

… the rest

install.ps1 was already signed, but only the copy the Windows bundler packs. A user who
clones the repo or fetches from raw.githubusercontent gets an unsigned file, and
studio/setup.ps1 and scripts/uninstall.ps1 were never signed at all.

The release now stages all seven shipped scripts, signs the three PowerShell ones with the
same Trusted Signing path the bundle already uses, and attaches them to the release along
with SHA256SUMS.txt.

Copies rather than the working tree, except install.ps1, which has to be signed in place
because the bundler packs it. Signing setup.ps1 or uninstall.ps1 in place would append a
signature block to files later steps and tests still read.

Every staged .ps1 is verified with Get-AuthenticodeSignature afterwards, including the one
the existing step signed, so a release cannot carry a script whose signature does not check
out on the machine that produced it.

.sh and .bat cannot carry an Authenticode signature. There is no subject interface package
for either, and Windows performs no signature check on a batch file at all, so the most that
can be done for those is a published digest. They are staged alongside so SHA256SUMS.txt
describes exactly the bytes the release serves, and the format is the two-space form
`sha256sum -c` accepts unmodified.

The artifact is deliberately not named desktop-release-*: the publish job merges that pattern
into one directory and validates it against an exact bundle name list, which these would
break. It gets its own artifact, its own download and its own upload, leaving the bundle
contract untouched. No --clobber, matching the bundle upload, so a re-run fails rather than
quietly replacing bytes whose digest has already been published.

Also adds the *.ps1 -text rule this depends on. Authenticode signs the bytes, so a line
ending rewrite invalidates the signature. install.ps1 is LF with no BOM, and a Windows clone
with core.autocrlf=true stored it back as CRLF, after which the signature reads HashMismatch,
which WDAC treats as tampering and is worse than shipping unsigned. Verified by cloning with
core.autocrlf=true both ways: without the rule the checkout gains CRLF, with it the bytes are
unchanged.

Note this does not change `irm https://unsloth.ai/install.ps1 | iex`, which compiles a string
and checks no signature. What it buys is signer identity on VirusTotal, acceptance under
AllSigned and RemoteSigned for the downloaded file, WDAC and Smart App Control evaluation,
and the signature every vendor false positive form asks for first.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 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-16T04:34:54.260096Z a28f382 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff5e2fa5e1

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

foreach ($item in $toSign) {
$target = Join-Path $stage $item.Name
Copy-Item -LiteralPath (Resolve-Path $item.Source).Path -Destination $target
studio/src-tauri/windows/sign-with-trusted-signing.ps1 -Path $target

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Prevent the signer from exiting the staging shell

On the first successful iteration, sign-with-trusted-signing.ps1 executes exit 0 (lines 36–37 of that helper); because it is invoked directly in the same PowerShell process, this terminates the entire run block rather than returning to the loop. The artifact therefore contains only the previously copied install.ps1 and the first signed setup.ps1, while signing uninstall.ps1, signature verification, copying the shell/batch scripts, and generating SHA256SUMS.txt are all skipped; the wildcard artifact upload still succeeds. Invoke the signer in a child process or make the helper return without exiting the host.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not correct, and I checked this rather than reasoning about it.

exit inside a script invoked by path returns to the caller with $LASTEXITCODE set. It only
terminates the host when the script is dot-sourced, and the signer is not dot-sourced here.

Reproduced both ways, with a signer that does nothing but exit 0 and a step that calls it in a
loop:

=== invoked by path (what the workflow does):
  signer running for a
  after signer a, LASTEXITCODE=0
  signer running for b
  after signer b, LASTEXITCODE=0
REACHED THE END OF THE STEP

=== simulating GitHub 'shell: pwsh', which dot-sources the step file:
  signer running for a
  after signer a, LASTEXITCODE=0
  signer running for b
  after signer b, LASTEXITCODE=0
REACHED THE END OF THE STEP

Both iterations run and the step reaches its end in each case.

There is also direct evidence in the file itself. The existing "Sign the bundled install script"
step calls the same helper the same way and then reads $LASTEXITCODE and
Get-AuthenticodeSignature on the following lines. Those lines run on every release build today,
which they could not do if the helper's exit 0 terminated the step.

Review caught a real ordering hazard. The signed scripts upload after the bundles and without
--clobber, but the guard that refuses to republish a release only looked for Unsloth-Desktop-*
and latest.json. A release already carrying install.ps1 or SHA256SUMS.txt therefore passed the
pre-flight, the bundles uploaded, and only then did the script upload fail on the duplicate
name, leaving the release publicly half replaced and without its manifest.

The eight script asset names now sit in the same guard, in both copies of it (prepare-version
and publish-release), so the clash is reported before any upload rather than after the bundles
are already public.

tests/security/test_release_desktop_integrity.py covers it: an existing install.ps1,
SHA256SUMS.txt or uninstall.sh on the target release each fail the guard and are named in the
output. The fake gh gained an optional TARGET_ASSET_NAMES so a test can put an arbitrary asset
on the release; its previous behaviour is unchanged when the variable is unset. Shown failing
with the guard extension removed.

Verified: 23 passed in the release integrity suite.
Independent review pointed out that the new upload sat between the bundle upload and the
latest.json upload, so a failure in it would leave a release carrying bundles with no manifest.
That is the one state that stops every updater client, and the scripts are secondary to the
update contract, so they now go last.

Also records why the Windows checkout matters here. GitHub's windows-latest image ships Git for
Windows with core.autocrlf=true and actions/checkout offers no way to override it, so without
the *.ps1 -text rule the runner checks install.ps1 out as CRLF while raw.githubusercontent
serves LF. The signed release asset and the raw copy would then be two different files with two
different digests, which would make SHA256SUMS.txt describe neither reliably.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 4b49d8f279

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

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 16, 2026
Comment pass over this PR's own additions: 38 added comment lines down to 31, keeping the facts
that are not recoverable from the code (why copies rather than the working tree, why .sh and
.bat cannot be signed at all, why the digest format is the one sha256sum -c accepts, and why the
script upload has to follow the manifest).
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: a28f3828af

ℹ️ 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 6731ba1 into main Sep 16, 2026
36 of 38 checks passed
@danielhanchen
danielhanchen deleted the sign-shipped-scripts branch September 16, 2026 05:42
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 16, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

Following up with a measurement, since this PR states the hypothesis that "signature and prevalence are inputs to that kind of score" and it is now testable.

A release run produced a genuinely signed install.ps1 (Azure Trusted Signing, subject Unsloth AI Inc., 72 hour leaf), which made a controlled pair possible for the first time: that file, and the identical file with only the signature block stripped. Both were first-seen by VirusTotal, so both got a fresh pass rather than a replayed one.

Sample Size Skyhigh Totals Timeouts
signed 589,290 B malicious BehavesLike.PS.Suspicious.hr 1 / 60 0
unsigned, identical content 566,991 B malicious BehavesLike.PS.Suspicious.hr 1 / 55 5

Same engine v2021.2.0+4045, same definitions 20260916, same detection family, same suffix. A valid Authenticode signature from a Microsoft issued CA does not move Skyhigh. That is consistent with the rest of the evidence: the detection is an aggregate behavioural score over the script text, which is why removing the reflection-emit apparatus moves it from malicious to undetected and why renaming constructs does not.

Two things worth correcting in the record:

signature_info is False on both samples. VirusTotal did not parse the Authenticode block on the signed one. It extracts signer identity from PE files, and a .ps1 is text with a trailing signature comment block. So "signer identity on VirusTotal" holds for the .exe bundles but not for the .ps1 assets this PR signs.

The unsigned control returned 5 timeouts to the signed sample's 0. A timeout is the absence of a verdict rather than a pass, so the only sound comparison is over engines that actually returned one. Skyhigh returned a verdict on both, which is what makes the pair decisive.

None of this argues against the change. The execution policy, WDAC and Smart App Control benefits stand, the .gitattributes fix was a real latent bug, and the signature is what the Trellix false positive form asks for first. It is just not a lever on the detection itself.

shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
… the rest (unslothai#11069)

* Release: sign every shipped PowerShell script and publish digests for the rest

install.ps1 was already signed, but only the copy the Windows bundler packs. A user who
clones the repo or fetches from raw.githubusercontent gets an unsigned file, and
studio/setup.ps1 and scripts/uninstall.ps1 were never signed at all.

The release now stages all seven shipped scripts, signs the three PowerShell ones with the
same Trusted Signing path the bundle already uses, and attaches them to the release along
with SHA256SUMS.txt.

Copies rather than the working tree, except install.ps1, which has to be signed in place
because the bundler packs it. Signing setup.ps1 or uninstall.ps1 in place would append a
signature block to files later steps and tests still read.

Every staged .ps1 is verified with Get-AuthenticodeSignature afterwards, including the one
the existing step signed, so a release cannot carry a script whose signature does not check
out on the machine that produced it.

.sh and .bat cannot carry an Authenticode signature. There is no subject interface package
for either, and Windows performs no signature check on a batch file at all, so the most that
can be done for those is a published digest. They are staged alongside so SHA256SUMS.txt
describes exactly the bytes the release serves, and the format is the two-space form
`sha256sum -c` accepts unmodified.

The artifact is deliberately not named desktop-release-*: the publish job merges that pattern
into one directory and validates it against an exact bundle name list, which these would
break. It gets its own artifact, its own download and its own upload, leaving the bundle
contract untouched. No --clobber, matching the bundle upload, so a re-run fails rather than
quietly replacing bytes whose digest has already been published.

Also adds the *.ps1 -text rule this depends on. Authenticode signs the bytes, so a line
ending rewrite invalidates the signature. install.ps1 is LF with no BOM, and a Windows clone
with core.autocrlf=true stored it back as CRLF, after which the signature reads HashMismatch,
which WDAC treats as tampering and is worse than shipping unsigned. Verified by cloning with
core.autocrlf=true both ways: without the rule the checkout gains CRLF, with it the bytes are
unchanged.

Note this does not change `irm https://unsloth.ai/install.ps1 | iex`, which compiles a string
and checks no signature. What it buys is signer identity on VirusTotal, acceptance under
AllSigned and RemoteSigned for the downloaded file, WDAC and Smart App Control evaluation,
and the signature every vendor false positive form asks for first.

* Include the script asset names in the pre-upload collision guard

Review caught a real ordering hazard. The signed scripts upload after the bundles and without
--clobber, but the guard that refuses to republish a release only looked for Unsloth-Desktop-*
and latest.json. A release already carrying install.ps1 or SHA256SUMS.txt therefore passed the
pre-flight, the bundles uploaded, and only then did the script upload fail on the duplicate
name, leaving the release publicly half replaced and without its manifest.

The eight script asset names now sit in the same guard, in both copies of it (prepare-version
and publish-release), so the clash is reported before any upload rather than after the bundles
are already public.

tests/security/test_release_desktop_integrity.py covers it: an existing install.ps1,
SHA256SUMS.txt or uninstall.sh on the target release each fail the guard and are named in the
output. The fake gh gained an optional TARGET_ASSET_NAMES so a test can put an arbitrary asset
on the release; its previous behaviour is unchanged when the variable is unset. Shown failing
with the guard extension removed.

Verified: 23 passed in the release integrity suite.

* Upload the scripts after the manifest, not before it

Independent review pointed out that the new upload sat between the bundle upload and the
latest.json upload, so a failure in it would leave a release carrying bundles with no manifest.
That is the one state that stops every updater client, and the scripts are secondary to the
update contract, so they now go last.

Also records why the Windows checkout matters here. GitHub's windows-latest image ships Git for
Windows with core.autocrlf=true and actions/checkout offers no way to override it, so without
the *.ps1 -text rule the runner checks install.ps1 out as CRLF while raw.githubusercontent
serves LF. The signed release asset and the raw copy would then be two different files with two
different digests, which would make SHA256SUMS.txt describe neither reliably.

* Tighten the new comments

Comment pass over this PR's own additions: 38 added comment lines down to 31, keeping the facts
that are not recoverable from the code (why copies rather than the working tree, why .sh and
.bat cannot be signed at all, why the digest format is the one sha256sum -c accepts, and why the
script upload has to follow the manifest).
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