ota: embed release root key, use keyservers only as fallback - #1493
Draft
adamshiervani wants to merge 1 commit into
Draft
ota: embed release root key, use keyservers only as fallback#1493adamshiervani wants to merge 1 commit into
adamshiervani wants to merge 1 commit into
Conversation
The OTA verifier fetched the release public key from public keyservers (keys.openpgp.org, keyserver.ubuntu.com) every time it had to verify a downloaded update. The trust anchor is the pinned fingerprint compiled into the binary, so the key bytes are effectively constant — fetching them over the network bought nothing while adding a hard dependency on third-party keyservers being reachable, plus a per-device IP leak to those servers. The in-memory-only cache made it worse: the first verify after every reboot had to reach a keyserver. Embed the root public key in the binary and use it first; it is validated against the same pinned fingerprint, so it is no less trusted. Keyservers remain a fallback if the embedded key is ever missing or fails to load. A test asserts the embedded key matches the pinned fingerprint so a wrong key can't ship silently.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The OTA verifier fetches the release public key from public keyservers (
keys.openpgp.org,keyserver.ubuntu.com) on the update path. But the trust anchor is the pinned fingerprint compiled into the binary (rootKeyFingerprint), and the fetched key is rejected unless it matches that fingerprint — so the key bytes are effectively constant. Fetching them over the network buys nothing and adds downsides:To be clear, this was not a security hole — the fingerprint pin already prevents a malicious/MITM'd keyserver from substituting a key. It's an availability/robustness fix.
Change
internal/ota/root_key.asc, viago:embed) and use it first inFetchPublicKey. It's validated against the same pinned fingerprint, so it's no less trusted.TestEmbeddedRootKey_MatchesPinnedFingerprintso a wrong/garbled key can't ship silently, andTestFetchPublicKey_PrefersEmbeddedKeyto confirm no keyserver request is made when the embedded key is valid.Notes for review
keys.openpgp.orgby fingerprint and matches the pinnedAF5A36A993D828FEFE7C18C2D1B9856C26A79E95(UIDJetKVM Release Root <release@jetkvm.com>). Please confirm it against the canonical/offline copy before merge.go test ./internal/ota/...passes.Note
Medium Risk
Touches OTA signature verification trust path; trust model is unchanged (fingerprint pin) but shipping the wrong
root_key.ascwould break updates until fixed—mitigated by new fingerprint tests.Overview
OTA GPG verification no longer depends on keyservers for the common path: the JetKVM release root public key is
go:embed’d frominternal/ota/root_key.ascand tried inFetchPublicKeybefore any HTTP lookup. The embedded material is validated with the same pinned fingerprint as fetched keys, then cached like a successful keyserver response; keyservers stay as fallback only if the embedded key is missing or fails validation.Tests assert the embedded bytes match
rootKeyFingerprint, that a valid embedded key triggers zero keyserver calls (even when HTTP would fail), andTestFetchPublicKey_AllKeyserversFailclearsembeddedKeyso the failure path still exercises the network.Reviewed by Cursor Bugbot for commit 660b85a. Bugbot is set up for automated code reviews on this repo. Configure here.