fix(secrets): reject placeholder/reference values before they reach the store - #412
Merged
Merged
Conversation
…he store
nself secrets set/edit now refuses empty values, unexpanded shell
references (${...}, $(...)), and bracketed placeholder tokens (<...>),
plus values implausibly short for their inferred type. Also fixes
Rotate() silently overwriting a stored value with an empty string for
key types that require manual rotation (API keys/tokens) instead of
erroring and leaving the existing value untouched.
Closes the exact gap behind the 2026-09-11/12 production incident,
where STRIPE_NSELF_SECRET_KEY=<set in .env.secrets> and
AUTH_JWT_SECRET=${PROD...} were captured as literal values and
overwrote working credentials.
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
ValidateSecretValue(internal/secrets/secrets_validate.go), wired intosecrets.Set(and therefore intonself secrets setand theeditre-save path): rejects empty values, unexpanded shell references (${...},$(...)), bracketed placeholder tokens (<...>), and values implausibly short for their inferred type.Rotate()silently persisting an empty string over an existing value for key types that require manual rotation (API keys/tokens) — it now errors and leaves the stored value untouched instead.Closes the exact gap behind the 2026-09-11/12 production incident, where
STRIPE_NSELF_SECRET_KEY=<set in .env.secrets>(a literal placeholder) andAUTH_JWT_SECRET=${PROD...}(an unexpanded shell reference) were captured as literal values and overwrote working credentials — the second also brokesourceon the whole vault file for ~18 hours.Test plan
go build ./...go vet ./internal/secrets/... ./cmd/commands/...go test ./internal/secrets/... ./cmd/commands/...— all greengofmt -lclean