Aller au contenu

Secret rotation & git-history purge (launch blocker B-10 / B-11)

Brouillon : cette page n'a pas encore été relue et peut être incomplète ou inexacte.

Two production secrets were committed and remain recoverable from git history in both repos. Removing them from the working tree (this PR deletes values-do.yaml) is not sufficient — anyone who has ever cloned, or who reads history, can still read them. They must be rotated and the history purged. This is an out-of-band operation (it rewrites history and touches live infrastructure); it cannot be done by a normal merge.

Secret Where Repo/commits (ancestors of master)
Prod Postgres password helm/kili-shops/values-do.yaml (removed in this PR) backend 9209998, 0c2846a
Kkiapay webhook secret historical frontend .env frontend d2ac547, 14f7d2e, e33e38c
Frontend public keys (reCAPTCHA site key, FedaPay/Kkiapay public keys, Google client id, TinyMCE key) historical frontend .env frontend (same commits) — public by nature; rotate only if policy requires

SMTP creds (H-9) were never committed as real values (placeholders only) — no action.

1. Rotate at the source (do this first — assume both are compromised)

Section intitulée « 1. Rotate at the source (do this first — assume both are compromised) »
  • Postgres: change the password on the managed DB / cluster, then update the Kubernetes secret only (never a values file):
    Fenêtre de terminal
    kubectl -n <ns> create secret generic postgresql-secret \
    --from-literal=postgres-password='<NEW_STRONG_PASSWORD>' \
    --dry-run=client -o yaml | kubectl apply -f -
    kubectl -n <ns> rollout restart deploy/users statefulset/postgres # pick up the new value
    The chart already reads the password via secretKeyRef: postgresql-secret — no values file needs the plaintext.
  • Kkiapay webhook secret: regenerate it in the Kkiapay dashboard, then set the new value as KKIAPAY_WEBHOOK_SECRET (helm --set appSecrets.kkiapayWebhookSecret=… / your secret manager). The users service already fails-closed if it’s unset.
  • helm/kili-shops/values-do.yaml is removed (this PR). The per-environment overlays values-{dev,staging,prod}.yaml are the replacement; real secrets are injected via --set appSecrets.* / secretKeyRef, never committed.
  • docs/DEPLOY-DIGITAL-OCEAN.md and docs/FIX-REGISTRY-AUTH.md still describe the old values-do.yaml flow — follow values-prod.yaml + --set secrets instead.

3. Purge git history (coordinated — everyone re-clones afterward)

Section intitulée « 3. Purge git history (coordinated — everyone re-clones afterward) »

Use git filter-repo (preferred) on a fresh mirror clone of EACH repo. Freeze merges first.

Fenêtre de terminal
# Backend
git clone --mirror git@github.com:af-corporation-outlook-com/kili-shops-microservices.git
cd kili-shops-microservices.git
git filter-repo --path helm/kili-shops/values-do.yaml --invert-paths
# and scrub any residual literal. Supply the real value from a LOCAL, untracked
# file — never paste the plaintext secret into this (committed) doc:
git filter-repo --replace-text <(echo '<OLD_POSTGRES_PASSWORD>==>REDACTED')
git push --force --mirror
# Frontend (scrub the historical .env value)
git clone --mirror git@github.com:af-corporation-outlook-com/kilimmanjaro.git
cd kilimmanjaro.git
git filter-repo --path .env --invert-paths
git filter-repo --replace-text <(echo '<kkiapay-webhook-secret-value>==>REDACTED')
git push --force --mirror

After the force-push: everyone deletes their local clones and re-clones (old clones still contain the secrets). Rotate again if any secret could have been used between step 1 and now. Consider GitHub secret-scanning / push protection to prevent recurrence.

Fenêtre de terminal
git log --all -S '<OLD_POSTGRES_PASSWORD>' --oneline # backend → no results
git log --all -S '<kkiapay-webhook-secret>' --oneline # frontend → no results

Until rotation and purge are both done, the leaked credentials remain usable by anyone with the history. Removing the file (this PR) closes the working-tree exposure only.