fix(redpanda): Use rpk --password-stdin to keep SASL password off argv#643
Conversation
The previous SASL-user hook piped the password via stdin into a shell
var inside the container, then expanded it as `rpk ... --password
"$RPK_PASS"`. The shell expansion put the password back into argv at
the rpk level — visible to anyone with /proc access inside the redpanda
container. The header comment in this file already acknowledged this
("still has the password in its argv inside the container — different
threat model").
rpk's `--password-stdin` flag closes the last surface: the password
flows host stdin → docker exec stdin → rpk stdin → rpk's internal
state, never landing in any argv on any of the three process-list
surfaces (host, docker daemon, container).
The earlier attempt at this (commit 7c3c530, 2026-04-15) reverted
because the then-bundled rpk was older than v23 and didn't recognise
--password-stdin. The pinned redpanda image is now v24.3 where rpk
v24+ supports the flag natively. If a future image downgrade
re-introduces the limitation, the symptom is a clean "unknown flag"
error from rpk — failure mode is loud, not silent.
Existing 10 redpanda-hook unit tests still pass — none of them pinned
the previous `RPK_PASS=$(cat)` shell shape, so the rendered-bash
shape change is invisible to them. Idempotency contract and rotation
path unchanged.
Closes #463
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR addresses security issue ChangesSafer password transport for RedPanda SASL user creation
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Switches the RedPanda SASL-user hook from
rpk ... --password "$RPK_PASS"(password expanded into rpk's argv inside the container) torpk ... --password-stdin(password flows end-to-end on stdin, never landing in argv).Closes #463.
Why
The previous shape:
passed the password via stdin to the OUTER
docker exec(good — hostps auxshows just thesh -cinvocation), but the innersh -cexpanded$RPK_PASSand re-injected the password into rpk's argv inside the container. The file's own header comment already acknowledged this:--password-stdincloses that last surface — password flows host-stdin → docker exec stdin → rpk stdin → rpk internal state, never landing in argv on any of:ps auxps auxps aux(rpk's argv)History
An earlier attempt at this landed and was reverted in 7c3c530 (2026-04-15) because the then-bundled rpk version didn't recognise
--password-stdin. The pinned redpanda image is nowv24.3and rpk v23+ supports the flag natively per Redpanda docs. If a future image downgrade re-introduces the limitation, the failure mode is a loud "unknown flag" error from rpk (not silent).Test plan
RPK_PASS=$(cat)shell shape, so the rendered-bash change is invisible to them. Idempotency contract and rotation path unchanged.gh workflow run spin-up.ymlsucceeds; the services-configure phase reportsRESULT hook=redpanda status=configured; SASL clients (Kestra, Flink-stack tutorials) authenticate against the broker as before.status=configuredvia the delete+recreate rotation path.Rollback
Revert the commit. The single edit is constrained to two
rpk acl user createinvocations + the rationale comment block; no API/contract changes to the orchestrator or the rest of the services module.Summary by CodeRabbit