feat(security): encrypt host TLS private keys at rest - #65
Merged
Conversation
A TCP host's client private key (hosts.tls_key) was stored in plaintext in the SQLite DB. It's now encrypted with the same AES-256-GCM cipher that already protects registry and SMTP secrets: - CreateHost encrypts tls_key before insert; HostByID/ListHosts decrypt it transparently, so every consumer (the docker TLS client, ComposeHostEnv) keeps getting the plaintext key. The CA and client certificate are public, so they stay as-is. - Decryption is best-effort, so a legacy plaintext row keeps working, and EncryptPlaintextHostKeys (run once at startup, after the cipher is set) migrates any plaintext key to ciphertext — idempotent. Folds into the 1.5.0 release (not yet tagged). Tests cover encryption at rest (raw column isn't the plaintext key; CA stays plaintext), transparent decrypt on read, and the idempotent legacy-row migration.
1 task
malickyeu
added a commit
that referenced
this pull request
Jun 16, 2026
The 1.5.0 round updated CHANGELOG + per-feature docs/ pages but left the headline lists stale: - README ✨ Features: add image vulnerability scanning, schema-aware Compose autocomplete + private-registry tag suggestions, remote-host project deploy, alert-rule import/export, LDAP group→section, --make-certs, one-tap in-app update, and host TLS keys encrypted at rest. - NEXT.md: record host TLS-key encryption under Shipped (v1.5) and drop it from the RBAC "Next" bullet (it shipped in #65, not a TODO).
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.
Summary
A TCP host's client private key (
hosts.tls_key) was stored in plaintext in the SQLite DB. This encrypts it with the same AES-256-GCM cipher that already protects registry and SMTP secrets.CreateHostencryptstls_keybefore insert;HostByID/ListHostsdecrypt it transparently, so every consumer (the docker TLS client inmanager.go,ComposeHostEnvfor remote deploy) keeps getting the plaintext key. The CA and client certificate are public, so they're stored as-is.EncryptPlaintextHostKeys(run once at startup after the cipher is set) migrates any plaintext key to ciphertext — idempotent.Folds into 1.5.0 (not yet tagged) — caught during the Remote Projects review, fixing it now while we know about it.
Type of change
Checklist
go test -short ./...andgo vet ./...passgofmtgate is cleanCHANGELOG.mdentry (under 1.5.0 → Security)Notes for reviewers
Follows the already-audited registry/LDAP secret-encryption pattern (key-only — certs are public). Tests in
internal/store/hosts_test.go: encryption at rest (raw column ≠ plaintext key; CA stays plaintext), transparent decrypt viaHostByID/ListHosts, and the idempotent legacy-row migration. Verified no host reader bypasses the decrypting accessors.