Skip to content

Redact plaintext MySQL password from superset entrypoint logs - #168

Merged
szachovy merged 2 commits into
masterfrom
fix/task-224-redact-db-password-in-logs
Jul 16, 2026
Merged

Redact plaintext MySQL password from superset entrypoint logs#168
szachovy merged 2 commits into
masterfrom
fix/task-224-redact-db-password-in-logs

Conversation

@szachovy

Copy link
Copy Markdown
Owner

Summary

  • entrypoint.sh ran under set -euxo pipefail, so the -x trace printed the fully-substituted superset test_db mysql+mysqlconnector://superset:<password>@... command to stderr on every start.
  • Separately, superset test_db itself prints the full SQLAlchemy connection URI (password included) to stdout as part of its "Collecting additional connection information..." output.
  • Both ended up in docker logs superset / docker service logs superset (no node access needed) and persisted indefinitely in the host's default json-file log driver (no rotation configured).

Fix

  • Build the DB URI in a variable with -x off, so bash's own trace never echoes the password. -x resumes right after the connectivity check for the rest of the script (create-admin, db upgrade, celery, etc. — unaffected).
  • Pipe test_db's combined stdout/stderr through a small inline python3 filter that does a literal string-replace of the password with <redacted>, as a backstop for Superset's own URI printout, which can't be silenced via bash flags since it's the CLI's own behavior.
  • pipefail (already set) still correctly propagates test_db's real exit code through the pipe, so the if/else connectivity check is unaffected.
  • Added a CHANGELOG.md entry under ### Fixed.

Test plan

  • bash -n services/superset/entrypoint.sh — syntax OK
  • Simulated both leak sources (bash -x trace line, and Superset's "SQLAlchemy URI: ..." printout) through the redaction filter locally — both resolve to <redacted>
  • Re-run the docker service logs superset | grep -c '<password>' check from the original test writeup against a live cluster (no docker/cluster access in the environment this was developed in)

szachovy added 2 commits July 16, 2026 12:33
entrypoint.sh's set -euxo pipefail traced the fully-substituted
superset test_db command, including the plaintext mysql_superset_password
secret, to stderr. Separately, superset test_db itself prints the full
SQLAlchemy connection URI (with password) to stdout. Both ended up in
docker logs / docker service logs superset, and persisted indefinitely
in the host's json-file log driver.

Build the DB URI in a variable with -x off, and pipe test_db's combined
output through a literal-string redaction filter before it reaches
Docker's log driver. -x tracing resumes for the rest of the script.
Inline python3 -c couldn't be indented to match entrypoint.sh's style
without breaking Python's indentation-sensitive syntax. Move it to
redact_secret.py (picked up by the existing COPY . /app/ in the
Dockerfile) so both files keep normal, consistent indentation.
@szachovy
szachovy merged commit 20e3dc7 into master Jul 16, 2026
12 checks passed
@szachovy
szachovy deleted the fix/task-224-redact-db-password-in-logs branch July 16, 2026 12:16
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