Skip to content

fix(install): migrate existing encryption key instead of generating a fresh GROUNDCONTROL_SECRET - #117

Open
teckedd-code2save wants to merge 1 commit into
mainfrom
fix/install-migrate-encryption-key
Open

teckedd-code2save wants to merge 1 commit into
mainfrom
fix/install-migrate-encryption-key

Conversation

@teckedd-code2save

Copy link
Copy Markdown
Owner

What

scripts/install (upgrade path) appended a random GROUNDCONTROL_SECRET to .env whenever it was missing, which overrode prisma/.groundcontrol-key — the key that actually encrypted secrets already at rest.

Why

GROUNDCONTROL_SECRET takes precedence over the file key in crypto.getKey(). So a fresh install/upgrade that added the env var changed the effective decryption key out from under already-encrypted secrets, orphaning them: AES-GCM auth tags no longer verified and the GitHub App private key (and any other enc:v1: secret) failed to decrypt with Unsupported state or unable to authenticate data.

Change

When GROUNDCONTROL_SECRET is absent, the installer now reads the existing /app/prisma/.groundcontrol-key (via docker exec, when a 64-char key is present) and migrates it into GROUNDCONTROL_SECRET, rather than generating a fresh random key. It only falls back to generating a new key when there's no existing file key.

Validation

  • bash -n scripts/install — clean
  • Verified on the running VPS: GROUNDCONTROL_SECRET now equals the file key, and the enc:v1: GitHub App private key decrypts successfully.

… fresh GROUNDCONTROL_SECRET

The upgrade path appended a random GROUNDCONTROL_SECRET to .env whenever it was
missing, which overrode prisma/.groundcontrol-key — the key that actually
encrypted secrets already at rest. This orphaned those secrets (AES-GCM auth
tags no longer verified) and broke GitHub App decryption.

Now, when GROUNDCONTROL_SECRET is absent, the installer migrates the existing
file key into the env var instead of generating a fresh one, so an upgrade can
never change the encryption key out from under already-encrypted data.
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