[Kalamos Development] Auto-Update Lessons: Private Key Isolation, Build-Signing Separation, Key Rotation, and CI Queuing
Recap In the previous two development logs, we discussed the functional evolution from v0.2 to v0.7 and external PR collaboration after going open-source (Functional Evolution and Reviewing External PRs After Open Sour
Recap
In the previous two development logs, we discussed the functional evolution from v0.2 to v0.7 and external PR collaboration after going open-source (Functional Evolution and Reviewing External PRs After Open Sourcing), as well as the various nuances of bringing Kalamos to Windows (Notes on Windows Implementation).
Once the macOS (Apple Silicon / Intel) and Windows versions could be automatically packaged and released, a very practical user experience friction point immediately emerged: With every new version, users had to go back to GitHub Releases, download the installer, and manually overwrite the old one. Thus, we scheduled the final piece of the Windows planβIssue #91: In-app automatic updates based on tauri-plugin-updaterβand truly completed the update pipeline in v0.8.0 and v0.8.1.
But honestly, "automatic updates" are on a completely different level of complexity compared to general editor features. If a layout breaks, it's just ugly; if automatic updates fail, at best users lose unsaved data, and at worst, the entire software becomes an entry point for remote malicious code execution.
This post won't talk about vague security slogans. Instead, I'll directly lay out our complete design trade-offs in PRs #130, #131, #133, #134, #135, and #136, the tightened "Separation of Build and Signing" during review, the five real-world pitfalls we hit during the first release, and the entire process of successfully running 0.8.0 β 0.8.1 on a real machine.
I. Security Design: Nailing Down the Trust Chain and User Control
Before opening Issue #91, I worked with Claude Code (acting as PM) to write several non-negotiable security baselines into the specifications, ensuring every stage was loophole-free before assigning it to the coder (PR #130):
| Defense Line | Actual Implementation | Purpose |
|---|---|---|
| Private Key Isolation | Private keys exist only in the maintainer's password manager/offline backup and GitHub Secrets; never in the repo, never given to agents, never in PR/CI, and no use of pull_request_target. |
Prevent private key leakage during development or external PR stages. |
| Environment & Dry-run Isolation | Only the build job triggered by a tag declares environment: release to access secrets; workflow_dispatch dry-runs use an independent build-dry-run job that cannot touch private keys. |
Manual dry-run packaging won't accidentally expose private keys. |
| Mandatory Public Key Verification | The public key is written into plugins.updater.pubkey in src-tauri/tauri.conf.json; tauri-plugin-updater enforces minisign verification before installation. |
Even if the transmission or hosting side is compromised, mismatched signatures result in a refusal to install. |
| Minimum Privilege Capabilities |
src-tauri/capabilities/default.json only allows updater:allow-check, updater:allow-download, and updater:allow-install. |
Restrict the native capabilities that the WebView can call. |
| Draft Gate | Update endpoints only use HTTPS, pointing to releases/latest/download/latest.json. |
GitHub's latest does not point to Draft Releases; users only get notified once the maintainer confirms the artifacts and manually clicks Publish. |
| No Silent Installation | Background check occurs 3 seconds after startup (can be disabled in "General" preferences) or manually via "Check for Updates..."; if a new version is found, a dialog always asks for consent before downloading and showing progress. | No stealthy data usage, no unexpected restarts interrupting writing. |
| Secure Rendering of Update Content | The CHANGELOG.md summary in the dialog is constructed entirely using pure DOM APIs (createElement + textContent / createTextNode), never calling innerHTML. |
Prevent update description text from becoming an XSS injection surface. |
| Protect Unsaved Documents Before Install | After download and before replacing the App, prepareForRestart() is called to run the existing multi-tab unsaved check (Save All / Don't Save / Cancel). |
Prevent users' hard work from evaporating due to an update restart. |
Two details here are particularly worth mentioning:
- Background check failures never interrupt with errors: If a user is writing offline (Kalamos is an offline-first editor) and the background check 3 seconds after startup can't connect to the network, it silently logs to the console and never pops up an error window. Only when the user manually clicks "Check for Updates..." do they need to be explicitly told "You are up to date" or why it failed.
-
Fallback for failed installation: If the user selects "Cancel" in the unsaved changes dialog, the installation process stops immediately without restarting. If
update.install()or the restart fails unexpectedly after the user clicks "Don't Save,"updater.tscallsrestoreRecoveryAfterFailedInstall()to restore the crash recovery snapshot, ensuring the user doesn't lose everything.
II. Strengthened Design During Review: Separation of Build and Signing
This was the most rewarding architectural reinforcement in the entire implementation.
If you follow the standard Tauri automatic update tutorial, you usually set bundle.createUpdaterArtifacts to true in tauri.conf.json, and then during npx tauri build in GitHub Actions, you inject TAURI_SIGNING_PRIVATE_KEY and TAURI_SIGNING_PRIVATE_KEY_PASSWORD into environment variables so Tauri can sign the package for you.
It sounds convenient, but while reviewing PR #130, we stopped to consider a question:
During
npx tauri build,vite build, hundreds of npm packages, and a long list of Cargo build scripts (build.rs) are executed. If any of these build-time dependencies are compromised by a supply chain attack, couldn't they just readprocess.envand steal our signing private key?
The thought sent a chill down my spine. So, before merging, we changed the release pipeline to a strict "Separation of Build and Signing":
1. Build Phase: No Private Keys
First, we set bundle.createUpdaterArtifacts to false by default in src-tauri/tauri.conf.json (which also has the benefit of not requiring private keys for local npm run tauri build).
In .github/workflows/release.yml, the build step does not inject any signing secrets:
# Build step runs WITHOUT TAURI_SIGNING_PRIVATE_KEY so Vite / npm / Cargo
# build-time dependencies can never read the signing private key.
- name: Build Tauri installers (unsigned)
shell: bash
run: npx tauri build --target "${TARGET}" --bundles "${BUNDLES}" --config '{"bundle":{"createUpdaterArtifacts":false}}'
After packaging, we first verify the macOS codesign --verify --deep --strict and .dmg structure through standard steps, then manually compress Kalamos.app into the tarball expected by tauri-plugin-updater 2.x (a small detail: the updater strips the outermost directory during extraction, so we must use COPYFILE_DISABLE=1 tar -czf ... -C .../macos Kalamos.app without the ./ prefix; we also check the first entry in the script to ensure the structure is correct).
2. Independent Signing Step: Run Only the Compiled Signer, No npm Scripts
Next, we create an independent signing step. Only this step has access to the private key and password, and it calls the signer in the Tauri CLI directly, bypassing npm run or any packaging tools:
- name: Sign macOS updater tarball
if: runner.os == 'macOS'
shell: bash
env:
ARCH_LABEL: ${{ matrix.settings.arch_label }}
RELEASE_VERSION: ${{ needs.check-version.outputs.version }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
run: |
set -euo pipefail
tarball="release-artifacts/Kalamos_${RELEASE_VERSION}_${ARCH_LABEL}.app.tar.gz"
node node_modules/@tauri-apps/cli/tauri.js signer sign \
--app-version "${RELEASE_VERSION}" \
"$tarball"
The Windows side uses the exact same isolation method, signing only the Kalamos_<version>_x64-setup.exe to produce a .sig.
3. Immediate Cryptographic Verification Using a "No-Key Step"
The step following signing carries no private keys. It immediately executes our custom zero-dependency verification script scripts/verify-updater-signature.mjs (implemented using Node's built-in node:crypto for Ed25519 + BLAKE2b-512 minisign verification). It uses the public key in src-tauri/tauri.conf.json to verify the newly generated .sig:
- Compare the Key ID of the public key and signature for a match;
- Verify the main file signature (supporting prehashed BLAKE2b-512 and legacy Ed25519);
- Verify the global signature of the
trusted comment(tamper-proof comment); - Enforce a
--require-signed-versioncheck to ensure theversion:locked in the signature matches the release version exactly.
Once all three platforms are built and signed, the subsequent checksums job runs scripts/generate-updater-manifest.mjs to generate latest.json, verifying all platforms (darwin-aarch64, darwin-x86_64, windows-x86_64) files, .sig, and HTTPS URLs again. Finally, the release job checks everything once more with --validate-only before creating the Draft Releaseβif any stage fails, the entire release process is aborted.
To ensure our verification logic had no blind spots, we included minisign-verify official test vectors in unit tests (tests/verify-updater-signature.test.mjs), covering scenarios where file or trusted comment versions were tampered with. We also ran a local test with a disposable key: "Sign β Verification passes β Tamper with file content β Immediately rejected." When PR #130 was merged, the entire defense lineβincluding vitest 561, node --test 43, cargo test 126, and Playwright 208βwas all green.
III. Five Real Pitfalls (More Exciting Than the Code Itself)
The features were written, tests were green, PR #130 was merged, and we even fixed a race condition that made preference E2E tests occasionally flaky (PR #131: setTimeout(..., 0) when opening the preference modal was clearing the "Unable to save UI language" error).
I thought all that was left was to merge the Changesets v0.8.0 version PR (#132) and push a tag to call it a day. However, after pushing v0.8.0, a series of real-world "reality checks" began.
Pitfall 1: Running Interactive gh secret set in Claude Code with ! Saved the Password as an Empty String
After creating the signing key, I needed to set the private key and password in GitHub Secrets. For convenience, I used the ! shell command in Claude Code to run an interactive gh secret set TAURI_SIGNING_PRIVATE_KEY_PASSWORD, thinking I could just enter the password as prompted.
When I pushed v0.8.0 for the first time, the Release workflow failed on all three platforms during the independent signing step:
env:
TAURI_SIGNING_PRIVATE_KEY: ***
TAURI_SIGNING_PRIVATE_KEY_PASSWORD:
incorrect updater private key password: Wrong password for that key
Error incorrect updater private key password: Wrong password for that key
Staring at those two env: lines for three seconds, it hit me: TAURI_SIGNING_PRIVATE_KEY had a *** mask, but TAURI_SIGNING_PRIVATE_KEY_PASSWORD: was completely blank!
It turns out that when executing interactive commands via Claude Code's !, there is no standard interactive TTY for gh secret set to read the password input, so it silently saved an empty string as the secret. GitHub Actions doesn't print *** for empty values; it just leaves them blank, which is how it was exposed in the log.
To make matters worse, I hit a second snag: after discovering the empty string, the PM tried to help by using pbpaste | gh secret set to write from the clipboard, but the clipboard was empty at that moment, saving another empty string. It wasn't until the third attempt, when I decided to verify the password locally before setting it, that I realized the password I remembered was wrong, leading to the next pitfall.
Lesson: Always set GitHub Secrets in your own independent terminal, or ensure there is a value before writing via a stdin pipe. Never run interactive input in a non-full TTY tool shell. Furthermore, before setting a secret, it's best to use
tauri signer signlocally to verify the password can correctly sign.
Pitfall 2: Forgetting the Password for the First Key β Rotating Keys Before Release (PR #133)
After finding the cause, I originally wanted to just write the correct password into GitHub Secretsβonly to find that the password for the first key could not be recovered.
At that moment, I was glad the first stage had failed. Because the v0.8.0 signing step didn't pass, no public release or user-installed App yet trusted that old public key.
So we didn't hesitate to start over:
- Regenerate a new minisign key pair on the maintainer's machine, immediately save the new private key and password in a password manager, and update GitHub Secrets in an independent terminal.
- Open PR #133 to replace
plugins.updater.pubkeyinsrc-tauri/tauri.conf.jsonwith the new public key (the entire PR was just a+1 -1line). - After merging, move the unreleased
v0.8.0tag to the new commit to re-trigger the release.
This episode made me deeply realize one thing:
Rotating keys before release costs nothing; rotating keys after release is extremely painful.
Why? Because old versions of the App already installed on users' computers only recognize the old public key hardcoded inside. If you lose your private key after release and are forced to rotate, old Apps cannot bridge the key rotation via automatic updatesβthey will judge update files signed with the new key as "signature verification failed" and reject them. You would have to issue an announcement asking all users to manually download and install from GitHub again.
Because of this pain, we wrote the "Private Key Backup Principles," "Private Key Loss Handling," and "Private Key Leakage Response Steps" into docs/release.md, rather than relying on memory.
Pitfall 3: The release Job Was Skipped Because it Depended on the Skipped build-dry-run (PR #134)
After rotating the keys and rerunning v0.8.0, a beautiful green checkmark appeared on GitHub Actions!
I excitedly opened the GitHub Releases page to check the Draft Release... only to find it empty. The Draft Release was never created!
Looking back at each job in that workflow run, I was stunned:
Check release version: success
Build (x86_64-apple-darwin): success
Build (x86_64-pc-windows-msvc): success
Build (aarch64-apple-darwin): success
Build dry-run ($): skipped
Generate updater manifest and SHA256SUMS: success
Create draft GitHub Release: skipped
The builds, signing, verification, latest.json, and SHA256SUMS.txt for all three platforms were all success, but the final Create draft GitHub Release was skipped!
Tracing it back to .github/workflows/release.yml, I caught a very subtle behavior of GitHub Actions:
- To make the
checksumsjob serve both "push tag for formal release (build)" and "workflow_dispatchmanual dry-run (build-dry-run)", we wroteneeds: [check-version, build, build-dry-run]and addedalways() && ...to theifcondition ofchecksums. Thus, whenbuild-dry-runwas skipped,checksumsstill executed normally and reportedsuccess. - However, the downstream
releasejob originally only hadneeds: [check-version, checksums]andif: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'), withoutalways(). - In GitHub Actions rules, a job without an explicit
always()implicitly appliessuccess(). If any ancestor job in the entire upstream dependency chain is skipped (even if separated by asuccesschecksumsjob), thereleasejob will also be skipped!
The fix in PR #134 was very explicit, hardcoding the dependencies and conditions for release:
release:
name: Create draft GitHub Release
needs: [check-version, build, checksums]
if: >-
always() && !failure() && !cancelled() &&
github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') &&
needs.check-version.result == 'success' &&
needs.build.result == 'success' &&
needs.checksums.result == 'success'
This way, workflow_dispatch dry-runs or any upstream failures will still never accidentally create a Release, and formal tag releases will no longer be dragged down by the skipped status of build-dry-run. After the fix, the v0.8.0 Draft Release was finally generated successfully.
Pitfall 4: GitHub macOS arm64 Runner Capacity Issues, Cancelled After 15 Minutes with 0 Steps (PR #135)
While running CI and Releases intensively over these two days, we repeatedly hit an annoying external issue: the GitHub Actions-hosted macos-latest (Apple Silicon arm64) runners occasionally had capacity issues. Jobs would queue for about 15 minutes and then time out, becoming cancelled (or failure). Clicking in showed that not a single step had run (steps count was 0), with this annotation on the page:
The job was not acquired by Runner of type hosted even after multiple attempts
This had nothing to do with our code, but every time it happened, we had to manually click "Re-run failed jobs." Since we'll be releasing frequently, PR #135 added a .github/workflows/rerun-on-runner-shortage.yml to handle this automatically:
- Use
workflow_runto listen forCIandReleasecompletedevents, triggering only when the overall conclusion isfailureorcancelledandrun_attempt < 3(auto-rerun up to 2 times). - Use the GitHub REST API to check if there is indeed a job in that attempt with
conclusionascancelled/failureandstepslength as0, and if the check-run annotations containnot acquired by runner. - If all conditions match, call
POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun-failed-jobsβonly rerunning failed jobs, not those that already passed. -
Security design intact: This workflow does not checkout any code, does not use
pull_request_target, and does not access any secrets. Permissions are limited toactions: writeandchecks: read, so even if triggered by an external fork PR, it won't execute untrusted code.
Pitfall 5: Versions Prior to 0.7.0 Lack the Updater and Must Be Manually Updated Once
The last one isn't strictly a bug, but a transitional reality of introducing automatic updates for the first time:
- The automatic update mechanism was only added to the App starting from
v0.8.0. Users onv0.7.0or earlier don't have the updater module in their App, so they will never see an update prompt. They must manually download and install0.8.xfrom GitHub Releases once; after that, they can use in-app automatic updates. - Additionally, because macOS is currently using ad-hoc signing (not yet notarized by Apple), the system might request re-authorization (Right-click "Open" in Finder or
xattr -cr) after the automatic update replaces/Applications/Kalamos.app. We have explicitly written these two points into the four-language README,docs/release.md, and every set of Release Notes to avoid user confusion.
IV. v0.8.1 Born for Verification, and the First Successful Real-Machine Auto-Update
With v0.8.0 out, mock testing wasn't enoughβas learned repeatedly in previous articles, it's not truly done until you've run a real packaged version from start to finish. We had to release a v0.8.1 and go through the full 0.8.0 β 0.8.1 auto-update on a real macOS machine.
However, rather than releasing an empty test version, we included another user-facing improvement in v0.8.1 from PR #135: Localization of automatic update error messagesβan improvement sparked by an accident while testing v0.8.0.
The real-machine verification went like this:
-
Clicking "Check for Updates..." before
v0.8.0was published verified error handling and sparkedv0.8.1: Beforev0.8.0was Published, we downloaded the.dmgfrom the Draft and installed it on an Apple Silicon Mac, then clicked "Kalamos β Check for Updates...". At that time, GitHub'sreleases/lateststill pointed tov0.7.0, which had nolatest.json. The App failed to fetch and popped up an errorβthis verified that error handling wouldn't crash the App, but it also showed a pain point: it threw raw technical English from the Tauri plugin (e.g.,Could not fetch a valid release JSON from the remote) directly at the user. So, we decided to addclassifyUpdaterErrortosrc/updater/updater.tsin PR #135, categorizing errors into six types (Unable to fetch info, Signature verification failed, Download failed, Install failed, Restart failed, Other), each with friendly Traditional Chinese and English descriptions. The raw technical message is tucked away in an expandable "Details" (<details>) section for easier reporting. -
Confirming "Up to Date" after Publishing
v0.8.0: We then officially clicked Publish release forv0.8.0, clicked "Check for Updates..." in the App again, and confirmed it successfully displayed "You are currently using the latest version." -
Releasing
v0.8.1, the Real Update Dialog Appears: We merged PR #135 and the Changesets version PR (PR #136) and pushed thev0.8.1tag to create a Draft Release (by design, since the endpoint points toreleases/latest, the Draft state is not caught by users). After confirming the artifacts, we clicked Publish release forv0.8.1, went back tov0.8.0, and clicked "Check for Updates...". This long-awaited real update dialog immediately appeared:
-
Completing the Update Chain: After clicking "Update Now," it successfully went through Prompt β Download with progress β minisign signature verification β Check for unsaved documents β Replace installation β Auto-restart. Upon restarting, I opened "About Kalamos," and the version number was officially
0.8.1!
To be honest, I should note what hasn't been tested: the end-to-end verification completed so far is for macOS (Apple Silicon). While the CI artifacts, signing, and latest.json verification for Windows NSIS auto-updates all passed, I haven't yet run a full upgrade on a real Windows machine. We have noted this in Issue #91 and the Release Notes.
V. Checklist for Those Implementing Automatic Updates
I've condensed the experience of implementing Tauri auto-updates and hitting those five pitfalls into a checklist you can use before you start:
- [ ] 1. Private keys never enter the repo, and don't set Secrets in non-standard TTYs: Generate keys in the maintainer's own independent terminal; save the private key and password in a password manager immediately and make an offline backup. After setting GitHub Secrets, verify they aren't empty strings.
- [ ] 2. Verify keys and signing flow before the first release: Rotating keys before release is free; rotating after release prevents all old versions from auto-upgrading. Write the "Private Key Loss/Leakage SOP" into your release documentation.
- [ ] 3. Build and Signing must be separated: Do not put private keys into
tauri buildor any step that runs npm/Cargo dependencies. Create an independent step that only runstauri signer, and useenvironmentto lock secrets to tag releases, keeping them away from PRs, CI, or dry-runs. - [ ] 4. Verify signatures with the public key immediately after signing: Use the built-in public key in a no-key step to perform cryptographic verification, ensuring Key ID, file content, trusted comment, and version all match. Verify locally with a disposable key that "tampering is always rejected."
- [ ] 5. Use Draft Releases as the final manual gate: Point the endpoint to
releases/latest/download/latest.json. Have CI only create Drafts, manually Publish after confirming artifacts, and test that "old Apps cannot find the update while in Draft state." - [ ] 6. Never install silently, and always intercept unsaved documents: Background check failures should only be silently logged; if a new version exists, show plain-text update content and ask for consent (no
innerHTML). Before replacing the App after download, always go through the unsaved changes check. - [ ] 7. Localize error messages and hide technical details: Don't throw English low-level errors at users. Translate network/signature/download/install errors into plain language, while keeping the original message in a collapsible section for reporting.
- [ ] 8. Watch out for GitHub Actions
skippedpropagation and runner capacity: If the workflow has parallel dry-run branches, remember to writealways() && !failure() && !cancelled()for the downstreamreleasejob and checkneeds.*.result == 'success'for each upstream job. For occasional macOS runner 0-step queue cancellations, write aworkflow_runthat calls the API to rerun failed jobs without checking out code. - [ ] 9. Remind old version users to manually upgrade once: Versions prior to the introduction of the updater won't receive notifications. Be clear about this in the release announcement and README. If you don't have formal code signing/Apple notarization, write instructions for re-authorizing after the update.
Summary
Looking back at the journey from #91 to v0.8.1, it was quite interesting:
-
Security isn't finished just by installing a package:
tauri-plugin-updaterhandles the App-side verification, but how to isolate private keys, whether build dependencies steal environment variables, whether Drafts are exposed early, whether update descriptions become XSS, and how to save unsaved documentsβthese are all things you have to fill in layer by layer. -
Real releases reveal the dark corners of the process: Interactive
gh secret setsaving empty strings, forgetting the first key's password, thereleasejob being skipped due tobuild-dry-run, macOS runners being cancelled after 15 minutesβnone of these could be caught by unit tests; they only appeared when pushing tags for real releases. -
After crossing the
0.8.0 β 0.8.1step, things get much easier: The moment the update dialog appeared on a real macOS machine, verified the signature, installed, and restarted as0.8.1, all those detours became worth it.
If you want to try Kalamos, or if you are using a version prior to v0.7.0, remember to manually update to the latest version once. After that, you'll receive updates directly in the App:
- GitHub Repo: kkdai/Kalamos
- Product Page: https://www.evanlin.com/Kalamos/
- Latest Official Download: Releases Latest
Series Articles:
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.
