Skip to content

fix(auth): stop writing the redis password into the ConfigMap - #38

Merged
binhnguyenduc merged 2 commits into
masterfrom
feat/redis-auth-out-of-configmap
Jul 25, 2026
Merged

fix(auth): stop writing the redis password into the ConfigMap#38
binhnguyenduc merged 2 commits into
masterfrom
feat/redis-auth-out-of-configmap

Conversation

@binhnguyenduc

Copy link
Copy Markdown

What

Stops embedding masterauth/requirepass in plaintext in the redis ConfigMap. The password is now handed to redis-server via --requirepass/--masterauth command-line args sourced from the existing REDIS_PASSWORD env (a SecretKeyRef).

Why

ConfigMaps are not encrypted at rest and are broadly readable, so writing the redis password into the redis ConfigMap (generator.go) leaked it to anyone with configmap read access.

How

  • getRedisCommand: when spec.auth.secretPath is set (and no custom command), launch redis via sh -c 'exec redis-server /redis/redis.conf --requirepass "$REDIS_PASSWORD" --masterauth "$REDIS_PASSWORD"'.
    • The shell expands the env var; exec keeps redis as PID 1 so SIGTERM still triggers a graceful shutdown.
    • The literal $REDIS_PASSWORD is what's stored in the pod spec, so the password appears in no cluster object (ConfigMap or pod spec).
    • redis applies the config file then the args before accepting connections, so there is no auth-less startup window.
  • generateRedisConfigMap / EnsureRedisConfigMap: drop the password embed and the now-unused password fetch/param.

Scope / compatibility

  • No-auth clusters and custom spec.redis.command are unchanged.
  • The sentinel ConfigMap never embedded the password (auth-pass is applied at runtime) — unaffected.
  • Upgrade is seamless: the ConfigMap updates, and under the OnDelete STS strategy running pods keep working; restarted pods pick up the args-based auth with the same password. No re-key needed.
  • Residual: inside the container ps shows the expanded password (same trust boundary that already holds the env). This is the standard trade-off and a strict improvement over cluster-readable plaintext.

Upstream references

Test

New tests: the redis ConfigMap contains no requirepass/masterauth; with auth the redis command is the env-based wrapper. go build ./..., go test ./..., gofmt clean.

Binh Nguyen added 2 commits July 25, 2026 12:12
masterauth and requirepass were embedded in plaintext in the redis
ConfigMap. ConfigMaps are not encrypted at rest and are broadly
readable, so the redis password leaked to anyone with configmap read
access.

Pass the password to redis-server via --requirepass/--masterauth
command args sourced from the existing REDIS_PASSWORD env (a
SecretKeyRef), through a shell wrapper that execs redis so it stays
PID 1 for graceful shutdown. The literal $REDIS_PASSWORD remains in the
pod spec, so the password no longer appears in any cluster object.
No-auth clusters and custom redis commands are unchanged; the sentinel
ConfigMap never embedded the password.

Refs upstream spotahome#684.
The auth integration test verified the old behavior (password embedded in
the redis ConfigMap). Update it to match: the ConfigMap must not contain
requirepass/masterauth, and the redis container command must carry them
via the REDIS_PASSWORD env instead.
@binhnguyenduc
binhnguyenduc merged commit 3ca2375 into master Jul 25, 2026
7 checks passed
@binhnguyenduc
binhnguyenduc deleted the feat/redis-auth-out-of-configmap branch July 25, 2026 05:32
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