Repository navigation
Sign the NSIS plugin DLLs, and fail the release on any unsigned file - #7819
Conversation
|
Marking this draft for the moment. The end to end run on a real bundler build caught a placement bug in the first version of this patch: With Moving it above the |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24bc282ccd
ℹ️ 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".
| if (-not $inner) { | ||
| Write-Host "::warning::no executable payload found inside $name" | ||
| } |
There was a problem hiding this comment.
Fail when no payload executables are extracted
When extraction produces no recognized inner executables—for example, because 7-Zip's NSIS handling changes or extraction yields only metadata—this branch emits a warning and the script later exits successfully after validating only the outer installer. That makes the release gate claim every bundled executable is signed without inspecting any payload, including the plugin DLLs this change is intended to protect; treat an empty $inner result as a fatal verification failure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed, and it is reachable rather than theoretical. Forcing 7-Zip onto its PE handler (-tPE) against the same installer exits 0 and yields .text .rdata .data .ndata CERTIFICATE version.txt plus numbered resources, none of which match the executable extensions, so the gate printed a warning and exited 0 having checked only the outer file. 7-Zip already reports SubType = NSIS-3 Unicode BadCmd=13 on this bundle, so its NSIS parser is partly out of step with what tauri emits. An empty payload list is now a hard failure.
| & $SevenZip x -y "-o$dest" $bundle | Out-Null | ||
| if (-not (Test-Path $dest)) { | ||
| Write-Host "::error::could not unpack $name; cannot verify its contents" | ||
| exit 1 |
There was a problem hiding this comment.
Reject partial 7-Zip extraction failures
When 7-Zip extracts only part of an installer and returns a warning or fatal exit code, this invocation ignores $LASTEXITCODE and tests only whether the destination directory was created. If the extracted subset contains signed files while an unextracted plugin is unsigned, the gate reports success; 7-Zip documents exit code 1 for warnings and 2 for fatal errors in its exit-code table, so require a zero exit code before inspecting the output.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Reproduced and fixed. Truncating the real installer to 200 KB, 500 KB, 2 MB and 20 MB all give 7-Zip exit 2 with Unexpected end of archive, and in every case the destination directory is still created with a partial tree, so Test-Path $dest passes. The intact bundle exits 0, so -ne 0 does not false-fail today.
9b6f9f3 to
54f8df2
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
9301792 to
c43f63c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c43f63cd76
ℹ️ 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".
| 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 |
There was a problem hiding this comment.
Keep the post-signature verification reachable
Invoking this helper in the current PowerShell process prevents the rest of the step from running because sign-with-trusted-signing.ps1 executes exit on both its success and failure paths. Consequently, the $LASTEXITCODE check and Get-AuthenticodeSignature validation below this line are unreachable; if trusted-signing-cli returns 0 without producing a valid signature—the exact case the validation is intended to catch—the workflow proceeds through the expensive build and Defender scan before the later bundle gate detects it. Invoke the signer in a child process or refactor the helper to return rather than exit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one, the premise does not hold. exit inside a script invoked from another script terminates only the invoked script and returns control to the caller, setting $LASTEXITCODE. It ends the session only at the top level of the entry script, which is how the helper is used from the bundler's signCommand (powershell -File ...).
Reproduced under the exact invocation GitHub Actions uses for shell: pwsh, which is pwsh -command ". <file>", with an inner script whose last statement is exit 7:
$ pwsh -NoProfile -command ". ./outer.ps1"
inner ran
AFTER: LASTEXITCODE=7
would error+exit 1 here
Get-AuthenticodeSignature check would run
process rc=0
Both the $LASTEXITCODE check and the Get-AuthenticodeSignature validation run, and the exit code propagates intact. Same result for the exit 0 path.
The underlying concern is a good one though, and it is already covered: trusted-signing-cli returning 0 without producing a valid signature is exactly why the step asserts $sig.Status -eq 'Valid' rather than trusting the exit code, and that assertion runs before the build rather than after it.
Both 0.1.51-beta and 0.1.512-beta ship four unsigned DLLs: NSISdl.dll, System.dll, StartMenu.dll and nsDialogs.dll. Only nsis_tauri_utils.dll carries the Unsloth AI Inc. signature. tauri-bundler is doing the work already. When a signing identity is configured it copies Plugins/x86-unicode aside, signs all five files listed in NSIS_PLUGIN_FILES, and exports the copy as the NSISPLUGINS environment variable. Nothing consumes it: no NSIS template references $%NSISPLUGINS%, and the only plugin directory added is ADDITIONALPLUGINSPATH, which points at the copy's additional subdirectory and holds exactly one file. So one DLL resolves from the signed copy and the other four fall back to the default unsigned one. Add the directory in our template, guarded so unsigned local builds still compile, and add a check that unpacks each bundle and fails listing every unsigned executable rather than stopping at the first.
7-Zip leaves a partial tree behind on error and can fall back to its PE handler, which yields sections rather than the payload. Both cases passed the gate having verified nothing. Move !addplugindir above the includes so the signed copy is registered before any plugin is packed.
install.ps1 ships as a bundle resource and is the first thing the app runs after install, but the bundler never signs it and the gate did not look at scripts. Sign it before the build packs it in, and add .ps1/.psm1 to the checked set. Verified on a Windows runner that signtool attaches a valid signature to a .ps1; trusted-signing-cli lists ps1 as supported and does not filter by extension.
458778e to
a1ca411
Compare
Three changes, none of which alter behaviour: install.rs no longer passes -WindowStyle Hidden -ExecutionPolicy Bypass to powershell.exe. CREATE_NO_WINDOW already suppresses the console and the NSIS-extracted script carries no mark-of-the-web, so RemoteSigned loads it. That flag pair is the command line Microsoft ships as a detection test. install.ps1 installs uv from a pinned, SHA-256 verified release archive instead of evaluating a downloaded script in-process. installer.nsi fills in CompanyName and InternalName, which upstream's template leaves empty.
… probe UV_UNMANAGED_INSTALL forces no-modify-path in astral's installer, so it must here too, and honour UV_INSTALLER_GHE_BASE_URL / UV_INSTALLER_GITHUB_BASE_URL so a mirrored environment still works. Every mirror serves the same asset, so the pinned hash is unchanged; UV_DOWNLOAD_URL stays unhonoured because it points at an arbitrary version the pin would then reject. Record where uv actually landed. Refresh-SessionPath rebuilds PATH machine first and drops the in-process prepend, and the recovery probe never checked the XDG_DATA_HOME or unmanaged destinations, so a good install could still report failure. Required by the change above, which leaves that prepend as the only thing putting uv on PATH.
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
1 similar comment
|
@codex review |
|
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". |
main #7819 replaced the in-process `Invoke-Expression (Invoke-RestMethod astral.sh/uv/install.ps1)` with Install-UvFromRelease, which fetches a pinned-SHA archive. This branch's offline fix was written against the call it deleted, so the rebase kept the behaviour but stranded the tests on a stub for a function that is no longer called. The harness now stubs Invoke-WebRequest, Get-HostMachineArch and Add-ToUserPath, and the escape-path assertion targets the release download's own try/catch instead of the removed Invoke-Expression. The invariant is unchanged and is the point of the file: the block runs under $ErrorActionPreference = Stop, so an unreachable host must surface as a return value rather than a script-terminating error that skips Exit-InstallFailure and leaves the venv unrolled-back. Verified the retarget still bites: replacing the download's try with a bare `if ($true)` fails 3 of the 4 tests.
…#7969) The windows-unit-tests leg added in #7943 pins powershell_script_path as a pure function. That cannot see the regression that actually shipped: #7819's entire install.rs diff was Bypass -> RemoteSigned, and dropping the powershell_script_path call from spawn_script leaves every existing assertion passing while first-run install is broken on every Windows bundle. Lift the argument vector into powershell_launch_args so the call site itself is testable, then run the real interpreter with those flags against a script addressed the way Tauri addresses it (fs::canonicalize, which resource resolution bottoms out in and which is documented to return extended-length syntax). The test asserts it reproduced a verbatim path before using it, so it cannot pass vacuously. A second test pins the flag set so a policy swap shows up as a diff. No behaviour change: the arguments spawn_script passes are byte for byte the ones it passed before.
What is wrong
Both
0.1.51-betaand0.1.512-betaship four unsigned DLLs inside the installer:nsis_tauri_utils.dllUnsloth AI Inc.Unsloth AI Inc.NSISdl.dllSystem.dllStartMenu.dllnsDialogs.dllNSIS extracts these to
$PLUGINSDIRat install time and runs them from there. An unsigned DLL appearing in a temp directory and being loaded by an installer is a well known false positive trigger, and it is the exact shape reported in tauri-apps/tauri#11673, where signing the plugins stopped Defender blocking, and in tauri-apps/nsis-tauri-utils#37.Why it happens
This is not a misconfiguration on our side.
tauri-bundleralready does the work and then discards it.In
crates/tauri-bundler/src/bundle/windows/nsis/mod.rs, when a signing identity is configured the bundler:Plugins/x86-unicodeaside so it does not modify the system install,NSIS_PLUGIN_FILES, which is exactlyNSISdl.dll,StartMenu.dll,System.dll,nsDialogs.dllandadditional/nsis_tauri_utils.dll,makensisas theNSISPLUGINSenvironment variable.Nothing consumes it. No NSIS template, upstream or ours, references
$%NSISPLUGINS%. The only plugin directory added isADDITIONALPLUGINSPATH, and that points at the copy'sadditionalsubdirectory, which contains exactly one file. Sonsis_tauri_utils.dllresolves from the signed copy and the other four fall back to the default, unsigned plugin directory.That predicts precisely the signed and unsigned split measured in both shipped bundles.
The fix
Three lines in our template, guarded because
NSISPLUGINSis only set when signing is configured:Plus
assert-bundle-signed.ps1, wired into the Windows release leg: it unpacks each bundle and fails listing every unsigned executable rather than stopping at the first, so one run gives the whole list.Verified
Tested on
windows-latestwith a minimal NSIS script and a self signed certificate, which isolates the variable properly, no Rust and no frontend:NSISPLUGINSset, with this fixSystem.dllandnsDialogs.dllembed withsigner='CN=NSIS Plugin Signing Test'NSISPLUGINSunsetSystem.dll -> status=NotSignedThe second case matters: without the guard this would break every local and unsigned build.
A full end to end run is also in flight on a real Tauri build with all of this applied, checking the four DLLs come out signed and the bundle still installs and launches. I will follow up with the result.
Notes
This is worth reporting upstream as well. Any Tauri app that signs its Windows installer currently ships four unsigned plugin DLLs, and the signing work is already being done and thrown away.
Stacked on #7813 because both touch
release-desktop.yml. Merge that first.Update: the bundled install script is now signed too
Same problem, different file.
install.ps1ships as a Tauribundle.resourcesentry, lands on disk at install, and is the first thing the app executes on first run, but the bundler never signs resources and the gate only looked at PE extensions. So the release could pass a gate named "no unsigned file ships" while shipping exactly that.Two halves, and they have to land together or the gate fails the release:
install.ps1with the existingsign-with-trusted-signing.ps1before the bundler packs it, asserting the result isValid.ps1and.psm1added to the checked extension setChecked on a
windows-latestrunner rather than assumed:signtoolsigns a.ps1(exit 0,Successfully signed, signer subject readable viaGet-AuthenticodeSignature), andtrusted-signing-clilistsps1among its supported types and does not filter by extension by default.The signature is an appended comment block and is applied in CI only, so the repo copy served for
irm https://unsloth.ai/install.ps1 | iexis untouched and its behaviour is unchanged.install.shstays out of the checked set: Authenticode does not cover shell scripts, so requiring it would be a false failure.