Skip to content

feat: verify the authenticity of what dprint upgrade downloads - #1501

Closed
dsherret wants to merge 2 commits into
mainfrom
feat/harden-upgrade
Closed

dsherret wants to merge 2 commits into
mainfrom
feat/harden-upgrade

Conversation

@dsherret

@dsherret dsherret commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

dprint upgrade previously trusted whatever it downloaded over TLS. It now only installs a release that it can verify was signed by a workflow of this repository that was run by pushing the version's tag.

  • Verifies the release's packslip.sigstore.json against roots of trust compiled into the executable: signature, certificate chain, transparency log, signer (GitHub's id of the repository, the tag, a push trigger, and a GitHub-hosted runner), project, version, and the checksum of the specific zip. There is no fallback when this fails.
  • Requires the version in cli.json to be strict semver. Previously, a version with ../ in it could change the repository that was downloaded from.
  • Writes the new executable beside the current one and runs it before swapping it in. Previously, the current executable was removed first on non-Windows, so a failure left no executable. Only the executable is read from the zip now.
  • Always requires https, including for redirects. Previously, this was only when DPRINT_ALLOWED_HOSTS was set.
  • Limits the size of what's downloaded and decompressed for upgrades.
  • Detects Homebrew under any prefix and resolves symlinks to the executable first.
  • Other dprint processes are now only killed after the new executable is known to work.

Notes for reviewing

  • Adds sigstore-verify, using ring (already used by rustls) rather than its aws-lc-rs default. The Windows x64 release executable grows by 1.7 MB (4.9%).
  • Versions with this can no longer upgrade if the bundle is renamed, the repository is renamed or moved, the tag format changes, releases are signed by something other than a tag push on a GitHub-hosted runner, or Sigstore rotates to keys they don't know about. They fail and say to reinstall. Which workflow signs isn't checked, so it can be renamed. There's a comment about this in ci.ts.
  • This does not prevent downgrades to an older signed release, and relies on who is able to push a tag.

Testing

  • Unit tests, including tampering with the 0.65.0 bundle (included as a fixture).
  • Before the workflow name stopped being checked (since then, only the tests with the real 0.65.0 bundle): manually built as 0.64.0 and upgraded to the real 0.65.0 on Windows x64 and Linux x64, with killing other processes stubbed out. Also checked a directory that can't be written to, a renamed executable (Windows), and a symlink to the executable (Linux).
  • Not built locally for the other release targets, which need the ci:full label to be built on this PR.

@dsherret

dsherret commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Replaced by #1502.

@dsherret dsherret closed this Dec 1, 2026
@dsherret
dsherret deleted the feat/harden-upgrade branch December 1, 2026 02:02
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