Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Sign the NSIS plugin DLLs, and fail the release on any unsigned file (#7819)

Daniel Han3c6343b455f9
diff --git a/.github/scripts/assert-bundle-signed.ps1 b/.github/scripts/assert-bundle-signed.ps1
new file mode 100644
index 00000000000..3d425eaf5e6
--- /dev/null
+++ b/.github/scripts/assert-bundle-signed.ps1
@@ -0,0 +1,93 @@
+# Fail if any executable inside a Windows bundle is unsigned. NSIS runs its
+# plugin DLLs from $PLUGINSDIR, so a signed installer proves nothing about them.
+
+param(
+ # Bundles to unpack; every PE inside is verified.
+ [Parameter(Mandatory = $true)][string[]] $Path,
+ # 7-Zip, preinstalled on windows-latest.
+ [string] $SevenZip = '7z',
+ # Known-unsigned leaf names to accept. Keep empty where possible.
+ [string[]] $Allow = @()
+)
+
+$ErrorActionPreference = 'Continue'
+# .ps1/.psm1 included: install.ps1 ships as a bundle resource and runs on first
+# launch. Authenticode covers scripts, and Smart App Control checks them.
+$exeExtensions = @('.exe', '.dll', '.sys', '.ocx', '.cpl', '.scr', '.ps1', '.psm1')
+
+$unsigned = @()
+$checked = 0
+
+foreach ($bundle in $Path) {
+ if (-not (Test-Path $bundle -PathType Leaf)) {
+ Write-Host "::error::bundle not found: $bundle"
+ exit 1
+ }
+ $name = Split-Path $bundle -Leaf
+ Write-Host ''
+ Write-Host "=== $name ==="
+
+ $sig = Get-AuthenticodeSignature $bundle
+ $checked++
+ if ($sig.Status -ne 'Valid') {
+ Write-Host " UNSIGNED $name ($($sig.Status))"
+ $unsigned += [pscustomobject]@{ Bundle = $name; File = $name; Status = [string]$sig.Status }
+ } else {
+ Write-Host " signed $name <- $($sig.SignerCertificate.Subject)"
+ }
+
+ $dest = Join-Path $env:RUNNER_TEMP ("sigcheck-" + [System.IO.Path]::GetFileNameWithoutExtension($name))
+ Remove-Item $dest -Recurse -Force -ErrorAction SilentlyContinue
+ & $SevenZip x -y "-o$dest" $bundle | Out-Null
+ # 7-Zip leaves a partial tree behind on error, so a created dir proves nothing.
+ if ($LASTEXITCODE -ne 0) {
+ Write-Host "::error::7-Zip exited $LASTEXITCODE unpacking $name; contents not verified"
+ exit 1
+ }
+ if (-not (Test-Path $dest)) {
+ Write-Host "::error::could not unpack $name; cannot verify its contents"
+ exit 1
+ }
+
+ $inner = Get-ChildItem $dest -Recurse -File |
+ Where-Object { $exeExtensions -contains $_.Extension.ToLower() }
+ # No hits means 7-Zip dumped PE sections, not that the payload is clean.
+ if (-not $inner) {
+ Write-Host "::error::no executable payload found inside $name; contents not verified"
+ exit 1
+ }
+
+ foreach ($f in ($inner | Sort-Object Name)) {
+ $checked++
+ $s = Get-AuthenticodeSignature $f.FullName
+ if ($s.Status -eq 'Valid') {
+ Write-Host (" signed {0}" -f $f.Name)
+ } elseif ($Allow -contains $f.Name) {
+ Write-Host (" ALLOWED {0} ({1}) - explicitly accepted as unsigned" -f $f.Name, $s.Status)
+ } else {
+ # UnknownError = no signature or unbuilt chain; StatusMessage tells which.
+ Write-Host (" UNSIGNED {0} ({1}) {2}" -f $f.Name, $s.Status, $s.StatusMessage)
+ $unsigned += [pscustomobject]@{ Bundle = $name; File = $f.Name; Status = [string]$s.Status }
+ }
+ }
+ Remove-Item $dest -Recurse -Force -ErrorAction SilentlyContinue
+}
+
+Write-Host ''
+Write-Host "checked $checked file(s) across $($Path.Count) bundle(s)"
+
+if (-not $unsigned) {
+ Write-Host 'Every executable in every bundle is validly signed.'
+ exit 0
+}
+
+Write-Host ''
+Write-Host '================ UNSIGNED FILES ================'
+$unsigned | Format-Table Bundle, File, Status -AutoSize | Out-String | Write-Host
+foreach ($u in $unsigned) {
+ Write-Host "::error file=$($u.File)::$($u.File) in $($u.Bundle) is $($u.Status) and needs signing"
+}
+Write-Host ''
+Write-Host 'These ship inside the installer and land on the user machine.'
+Write-Host 'For NSIS plugin DLLs see the NSISPLUGINS note in windows/installer.nsi.'
+exit 1
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 044ab5d62ea..7e1adb08ff3 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -814,6 +814,26 @@ jobs:
"$dmg_path"
# ── Windows: build + sign ──
+ # install.ps1 is a bundle resource the bundler never signs, yet the app
+ # runs it first. Sign before the build packs it in; the signature is an
+ # appended comment block, so the repo copy for `irm ... | iex` is unaffected.
+ - name: Sign the bundled install script
+ if: matrix.platform == 'windows-latest'
+ shell: pwsh
+ env:
+ AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
+ AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
+ AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
+ AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
+ AZURE_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_CERTIFICATE_PROFILE_NAME }}
+ run: |
+ $script = (Resolve-Path 'install.ps1').Path
+ studio/src-tauri/windows/sign-with-trusted-signing.ps1 -Path $script
+ if ($LASTEXITCODE -ne 0) { Write-Host "::error::could not sign install.ps1 (exit $LASTEXITCODE)"; exit 1 }
+ $sig = Get-AuthenticodeSignature $script
+ Write-Host "install.ps1 -> $($sig.Status) $($sig.SignerCertificate.Subject)"
+ if ($sig.Status -ne 'Valid') { Write-Host "::error::install.ps1 is $($sig.Status) after signing"; exit 1 }
+
- name: Build Windows app
id: build_windows
if: matrix.platform == 'windows-latest'
@@ -1029,6 +1049,19 @@ jobs:
compression-level: 0
retention-days: 7
+ # ── Windows: every executable in the bundle must be signed ──
+ # NSIS runs its plugin DLLs from $PLUGINSDIR; signing the installer misses them.
+ - name: Verify every executable in the Windows bundles is signed
+ if: matrix.platform == 'windows-latest'
+ shell: pwsh
+ env:
+ ARTIFACT_PATHS: ${{ steps.build_windows.outputs.artifactPaths }}
+ run: |
+ $paths = @($env:ARTIFACT_PATHS | ConvertFrom-Json) |
+ Where-Object { $_ -like '*-setup.exe' }
+ if (-not $paths) { Write-Host '::error::no Windows installer to verify'; exit 1 }
+ .github/scripts/assert-bundle-signed.ps1 -Path $paths
+
# ── Windows: assemble a Microsoft false-positive submission packet ──
# The WDSI portal is a web form with no API, so this cannot be automated,
# but pre-filling the lookups makes submitting a build take seconds.
diff --git a/install.ps1 b/install.ps1
index 332933a26f3..8e1d7063d46 100644
--- a/install.ps1
+++ b/install.ps1
@@ -20,9 +20,8 @@ function Install-UnslothStudio {
$ErrorActionPreference = "Stop"
$script:UnslothVerbose = ($env:UNSLOTH_VERBOSE -eq "1")
- # Same fix as studio/setup.ps1, for the same reason. This script also runs
- # astral's uv installer in-process (Invoke-Expression, below), and that
- # installer calls Get-ExecutionPolicy out of Microsoft.PowerShell.Security.
+ # Same fix as studio/setup.ps1, for the same reason. This script also calls
+ # Expand-Archive and Get-ExecutionPolicy, which resolve via PSModulePath.
# The desktop app reaches here as Tauri -> Rust -> powershell.exe
# (studio/src-tauri/src/install.rs), and PowerShell only rewrites
# PSModulePath for a direct pwsh -> powershell.exe hop, so the Rust process
@@ -1608,6 +1607,110 @@ exit 0
}
}
+ # Fallback for hosts without winget. Same archive, destination and user-PATH
+ # prepend as astral's install.ps1, but it fetches a data file with a pinned
+ # SHA-256 instead of script text run in-process, which is what AMSI and cloud
+ # ML scanners score hardest. Bumping the version means bumping all 3 hashes:
+ # curl -sL https://github.com/astral-sh/uv/releases/download/<ver>/uv-<arch>-pc-windows-msvc.zip.sha256
+ $UvPinnedVersion = "0.12.1"
+ $UvPinnedAssets = @{
+ "x86_64" = @{ Asset = "uv-x86_64-pc-windows-msvc.zip"; Sha256 = "8FCB0CB46E1229065E344758980924E569BEF5882EF45F46FADA8FB24E06B74A" }
+ "arm64" = @{ Asset = "uv-aarch64-pc-windows-msvc.zip"; Sha256 = "9BC7C18E616230FA2DC6FB24BC3AFDE18A95C2B5C9433DE747E9502C66041568" }
+ "x86" = @{ Asset = "uv-i686-pc-windows-msvc.zip"; Sha256 = "9B51C33D307A8AB9E9DFD88D4AE1491761F63DE0BFFA3CEC96BEC536491C9B97" }
+ }
+
+ function Install-UvFromRelease {
+ $arch = Get-HostMachineArch
+ if (-not $UvPinnedAssets.ContainsKey($arch)) {
+ substep "No uv build is published for this architecture ($arch)." "Yellow"
+ return $false
+ }
+ $asset = $UvPinnedAssets[$arch].Asset
+ $wanted = $UvPinnedAssets[$arch].Sha256
+
+ # Same destination priority as astral's installer, so an existing uv is
+ # replaced in place and the PATH probe further below still finds it.
+ $destDir = $null
+ foreach ($candidate in @($env:UV_INSTALL_DIR, $env:UV_UNMANAGED_INSTALL, $env:XDG_BIN_HOME)) {
+ if ($candidate) { $destDir = $candidate; break }
+ }
+ if (-not $destDir -and $env:XDG_DATA_HOME) { $destDir = Join-Path $env:XDG_DATA_HOME "../bin" }
+ if (-not $destDir) {
+ $userHome = if ($env:USERPROFILE) { $env:USERPROFILE } else { $HOME }
+ if (-not $userHome) {
+ substep "Could not determine a home directory to install uv into." "Yellow"
+ return $false
+ }
+ $destDir = Join-Path $userHome ".local\bin"
+ }
+
+ # Same mirrors and precedence as astral's installer; each serves the
+ # identical asset, so the pin holds across all of them. UV_DOWNLOAD_URL is
+ # not honoured: it points at an arbitrary version the pin would reject.
+ $uvBase = if ($env:UV_INSTALLER_GHE_BASE_URL) {
+ @("$($env:UV_INSTALLER_GHE_BASE_URL.TrimEnd('/'))/astral-sh/uv/releases/download/$UvPinnedVersion")
+ } elseif ($env:UV_INSTALLER_GITHUB_BASE_URL) {
+ @("$($env:UV_INSTALLER_GITHUB_BASE_URL.TrimEnd('/'))/astral-sh/uv/releases/download/$UvPinnedVersion")
+ } else {
+ @("https://releases.astral.sh/github/uv/releases/download/$UvPinnedVersion",
+ "https://github.com/astral-sh/uv/releases/download/$UvPinnedVersion")
+ }
+
+ $work = Join-Path ([System.IO.Path]::GetTempPath()) ("unsloth-uv-" + [guid]::NewGuid().ToString('N').Substring(0, 8))
+ $zip = Join-Path $work $asset
+ try {
+ [System.IO.Directory]::CreateDirectory($work) | Out-Null
+ $downloaded = $false
+ foreach ($base in $uvBase) {
+ substep "downloading uv $UvPinnedVersion ($arch) from $base..." "Yellow"
+ try {
+ Invoke-WebRequest -UseBasicParsing -OutFile $zip -Uri "$base/$asset"
+ $downloaded = $true
+ break
+ } catch {
+ substep "uv download failed: $($_.Exception.Message)" "Yellow"
+ }
+ }
+ if (-not $downloaded) { return $false }
+
+ $actual = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash
+ if ($actual -ne $wanted) {
+ substep "uv download failed checksum verification -- discarding it." "Red"
+ substep "expected $wanted, got $actual" "Red"
+ return $false
+ }
+
+ # The Windows archives are flat: uv.exe, uvx.exe, uvw.exe at the root.
+ Expand-Archive -LiteralPath $zip -DestinationPath $work -Force
+ [System.IO.Directory]::CreateDirectory($destDir) | Out-Null
+ $haveUv = $false
+ foreach ($exe in @("uv.exe", "uvx.exe", "uvw.exe")) {
+ $src = Join-Path $work $exe
+ if (Test-Path -LiteralPath $src) {
+ Copy-Item -LiteralPath $src -Destination (Join-Path $destDir $exe) -Force
+ if ($exe -eq "uv.exe") { $haveUv = $true }
+ }
+ }
+ if (-not $haveUv) {
+ substep "uv.exe was not present in $asset." "Yellow"
+ return $false
+ }
+ } finally {
+ Remove-Item -LiteralPath $work -Recurse -Force -ErrorAction SilentlyContinue
+ }
+
+ # Same PATH treatment and opt-outs astral's installer uses: an unmanaged
+ # install forces no-modify-path there, so it must here too.
+ if (-not $env:UV_NO_MODIFY_PATH -and -not $env:UV_UNMANAGED_INSTALL) {
+ Add-ToUserPath -Directory $destDir -Position Prepend | Out-Null
+ }
+ $env:PATH = "$destDir;$env:PATH"
+ # Refresh-SessionPath rebuilds PATH machine-first and drops that prepend,
+ # so record where uv actually landed for the probe below.
+ $script:UvInstallDestDir = $destDir
+ return $true
+ }
+
if (-not (Test-UvVersionOk)) {
if (Get-Command uv -ErrorAction SilentlyContinue) {
substep "updating uv package manager..."
@@ -1624,13 +1727,10 @@ exit 0
$ErrorActionPreference = $prevEAP
Refresh-SessionPath
}
- # Fallback: if winget is unavailable or didn't put uv on PATH,
- # use Astral's official PowerShell installer. This is the only
- # supported path on hosts without winget (Windows ARM64 runners,
- # corporate machines without the Store, etc.).
+ # winget unavailable or it didn't put uv on PATH: install the pinned
+ # release directly (ARM64 runners, machines without the Store).
if (-not (Test-UvVersionOk)) {
- substep "installing uv via https://astral.sh/uv/install.ps1..." "Yellow"
- Invoke-Expression (Invoke-RestMethod -Uri "https://astral.sh/uv/install.ps1")
+ Install-UvFromRelease | Out-Null
Refresh-SessionPath
}
}
@@ -1639,7 +1739,7 @@ exit 0
# venv, Scoop/pipx shim). Prefer a just-installed uv from a known location.
if (-not (Test-UvVersionOk)) {
$origPath = $env:PATH
- foreach ($d in @($env:UV_INSTALL_DIR, $env:XDG_BIN_HOME,
+ foreach ($d in @($script:UvInstallDestDir, $env:UV_INSTALL_DIR, $env:XDG_BIN_HOME,
(Join-Path $env:USERPROFILE ".local\bin"),
(Join-Path $env:LOCALAPPDATA "Microsoft\WinGet\Links"))) {
if ($d -and (Test-Path $d)) {
diff --git a/studio/src-tauri/src/install.rs b/studio/src-tauri/src/install.rs
index 39d67dc4278..d1cebe46ef4 100644
--- a/studio/src-tauri/src/install.rs
+++ b/studio/src-tauri/src/install.rs
@@ -324,15 +324,16 @@ fn spawn_script(
#[cfg(windows)]
let mut cmd = Command::new("powershell.exe");
+ // No -WindowStyle Hidden / -ExecutionPolicy Bypass: that pair is a Microsoft
+ // detection signature, CREATE_NO_WINDOW below already hides the console, and
+ // NSIS writes resources without a mark-of-the-web so RemoteSigned loads them.
#[cfg(windows)]
cmd.args([
"-NoLogo",
"-NoProfile",
"-NonInteractive",
- "-WindowStyle",
- "Hidden",
"-ExecutionPolicy",
- "Bypass",
+ "RemoteSigned",
"-File",
])
.arg(script)
diff --git a/studio/src-tauri/windows/installer.nsi b/studio/src-tauri/windows/installer.nsi
index 33b2f39554f..c00ec55ffa2 100644
--- a/studio/src-tauri/windows/installer.nsi
+++ b/studio/src-tauri/windows/installer.nsi
@@ -23,6 +23,12 @@ ManifestDPIAwareness PerMonitorV2
SetCompressor /SOLID "{{compression}}"
!endif
+; Signed NSIS plugins. tauri-bundler signs a copy and exports NSISPLUGINS, but no
+; template consumes it, so only nsis_tauri_utils.dll ships signed and the rest
+; (NSISdl/System/StartMenu/nsDialogs) run unsigned from $PLUGINSDIR, tripping AV.
+; Must precede any plugin use; a missing directory is a silent no-op.
+!addplugindir "$%NSISPLUGINS%\x86-unicode"
+
!include MUI2.nsh
!include FileFunc.nsh
!include x64.nsh
@@ -94,6 +100,11 @@ InstallDir "${PLACEHOLDER_INSTALL_DIR}"
VIProductVersion "${VERSIONWITHBUILD}"
VIAddVersionKey "ProductName" "${PRODUCTNAME}"
VIAddVersionKey "FileDescription" "${PRODUCTNAME}"
+; Not in upstream's template. ${MANUFACTURER} is bundle.publisher, already written
+; as the Add/Remove Programs Publisher, so these cannot be empty or disagree with
+; it. An installer with no CompanyName reads as unattributed to reputation checks.
+VIAddVersionKey "CompanyName" "${MANUFACTURER}"
+VIAddVersionKey "InternalName" "${INSTALLIDENTITY}"
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
VIAddVersionKey "FileVersion" "${VERSION}"
VIAddVersionKey "ProductVersion" "${VERSION}"