fix(docker): keep the Redis password out of the RQ worker command line

The worker received its connection string through `rq worker --url`, which
put the password in argv for the life of the process, readable via
/proc/<pid>/cmdline, ps, and any monitoring or diagnostic tooling that
collects command lines (CWE-214).

RQ's `--url` option already reads from RQ_REDIS_URL, so passing it through
the environment instead is behavior-preserving. This matches how the RQ
scheduler alongside it already takes its credentials.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Georges-Antoine Assi
2026-08-03 21:24:31 -04:00
parent e7c2362527
commit 76efbe72fd
2 changed files with 10 additions and 4 deletions

View File

@@ -251,15 +251,18 @@ start_bin_rq_worker() {
fi
# Set PYTHONPATH so RQ can find the tasks module.
# The connection URL goes through RQ_REDIS_URL rather than --url, so the
# embedded password stays out of the worker's world-readable command line.
# Use a worker class that drops the noisy per-sweep "cleaning registries for
# queue" log line. The maintenance interval keeps its default (~10 min) so
# orphaned STARTED jobs and stale workers are still pruned promptly, which the
# watcher's Worker.all() scan dedupe relies on.
PYTHONPATH="/backend:${PYTHONPATH-}" rq worker \
PYTHONPATH="/backend:${PYTHONPATH-}" \
RQ_REDIS_URL="${redis_url}" \
rq worker \
--path /backend \
--worker-class handler.rq_worker.RomMWorker \
--pid /tmp/rq_worker.pid \
--url "${redis_url}" \
--results-ttl "${TASK_RESULT_TTL:-86400}" \
--logging_level "${LOGLEVEL}" \
high default low &

View File

@@ -69,15 +69,18 @@ else
fi
# Set PYTHONPATH so RQ can find the tasks module.
# The connection URL goes through RQ_REDIS_URL rather than --url, so the
# embedded password stays out of the worker's world-readable command line.
# Use a worker class that drops the noisy per-sweep "cleaning registries for
# queue" log line. The maintenance interval keeps its default (~10 min) so
# orphaned STARTED jobs and stale workers are still pruned promptly, which the
# watcher's Worker.all() scan dedupe relies on.
PYTHONPATH="/app/backend:${PYTHONPATH-}" rq worker \
PYTHONPATH="/app/backend:${PYTHONPATH-}" \
RQ_REDIS_URL="${REDIS_URL}" \
rq worker \
--path /app/backend \
--worker-class handler.rq_worker.RomMWorker \
--pid /tmp/rq_worker.pid \
--url "${REDIS_URL}" \
--logging_level "${LOGLEVEL:-INFO}" \
high default low &