Repository navigation
Release: sign every shipped PowerShell script and publish digests for the rest - #11069
Conversation
… 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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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 |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex security review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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).
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
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
Same engine Two things worth correcting in the record:
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 |
… 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).
Why
install.ps1was already Authenticode signed, but only the copy the Windows bundler packs. A user who clones the repo, or fetches fromraw.githubusercontent, gets an unsigned file.studio/setup.ps1andscripts/uninstall.ps1were never signed at all, andscripts/uninstall.ps1is advertised to users as a one-liner pointing straight atraw.githubusercontent.Separately,
.gitattributeshad no*.ps1rule. Authenticode signs the bytes, so a line ending rewrite invalidates the signature.install.ps1is LF with no BOM, so a Windows clone withcore.autocrlf=truestored it back as CRLF and any signature would readHashMismatch, 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.shor.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 soSHA256SUMS.txtdescribes exactly the bytes the release serves, in the two-space formsha256sum -caccepts unmodified.Three details worth review:
install.ps1, which has to be signed in place because the bundler packs it. Signingsetup.ps1oruninstall.ps1in place would append a signature block to files that later steps and tests still read..ps1is re-verified withGet-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.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_channelpins 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--clobberto it fails the test.pwshwith signing stubbed out, since Trusted Signing is Windows only. All seven files stage,SHA256SUMS.txtcorrectly excludes itself, andsha256sum -c SHA256SUMS.txtreturns 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..gitattributesrule was proved by cloning withcore.autocrlf=trueboth ways. Without the rule the checkout gains CRLF; with it the bytes are unchanged.git check-attrreportstext: unsetfor all three shipped scripts.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-Expressioncompiles 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
AllSignedandRemoteSignedfor a downloaded copy, WDAC and Smart App Control evaluation, and the signature every vendor false positive form asks for first. Skyhigh's verdict oninstall.ps1is 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.ps1at 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.