Skip to content

fix(secrets): reject placeholder/reference values before they reach the store - #412

Merged
acamarata merged 1 commit into
mainfrom
fix/secrets-reject-placeholder-values
Sep 12, 2026
Merged

acamarata merged 1 commit into
mainfrom
fix/secrets-reject-placeholder-values

Conversation

@acamarata

Copy link
Copy Markdown
Collaborator

Summary

  • Adds ValidateSecretValue (internal/secrets/secrets_validate.go), wired into secrets.Set (and therefore into nself secrets set and the edit re-save path): rejects empty values, unexpanded shell references (${...}, $(...)), bracketed placeholder tokens (<...>), and values implausibly short for their inferred type.
  • Fixes 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.
  • Updates two existing rotate/list tests whose fixture values are no longer valid under the new floor, and adds a test covering the manual-rotation-preserves-value fix.

Closes the exact gap behind the 2026-09-11/12 production incident, where STRIPE_NSELF_SECRET_KEY=<set in .env.secrets> (a literal placeholder) and AUTH_JWT_SECRET=${PROD...} (an unexpanded shell reference) were captured as literal values and overwrote working credentials — the second also broke source on the whole vault file for ~18 hours.

Test plan

  • go build ./...
  • go vet ./internal/secrets/... ./cmd/commands/...
  • go test ./internal/secrets/... ./cmd/commands/... — all green
  • gofmt -l clean
  • Not merged — opened for review per task constraints

…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.
@acamarata
acamarata marked this pull request as ready for review September 12, 2026 14:19
@acamarata
acamarata merged commit c4443ce into main Sep 12, 2026
31 checks passed
@acamarata
acamarata deleted the fix/secrets-reject-placeholder-values branch September 12, 2026 14:19
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