fix(backup): redact S3 credentials from logs and error output#4648
Open
rafaumeu wants to merge 1 commit into
Open
fix(backup): redact S3 credentials from logs and error output#4648rafaumeu wants to merge 1 commit into
rafaumeu wants to merge 1 commit into
Conversation
…y#4621) S3 backup credentials (access key + secret) were logged in plaintext to Dokploy service stdout via logger.info in getBackupCommand() and console.error in keepLatestNBackups(). Any operator with access to service logs could recover S3 credentials. Added redactRcloneCredentials() pure function that masks --s3-access-key-id and --s3-secret-access-key values with [REDACTED]. Applied to both the structured logger call and the error handler. Closes Dokploy#4621
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #4621
S3 backup credentials (access key ID + secret access key) are logged in plaintext to Dokploy's structured logger output (service stdout) on every backup run, not just on errors. Any operator who can read service logs — including log aggregators, syslog forwarders, or anyone with
docker service logs dokployaccess — can recover S3 credentials.Two leak points identified:
getBackupCommand()inutils.ts— logs the fullrcloneCommand(including--s3-access-key-idand--s3-secret-access-keyflags) vialogger.infoon every runkeepLatestNBackups()inindex.ts— surfaces the rclone command (with credentials) viaconsole.error(error)on failureSolution
Extracted
redactRcloneCredentials()— a pure function that masks--s3-access-key-id="..."and--s3-secret-access-key="..."values with[REDACTED]using regex.Applied to both leak points:
logger.infoingetBackupCommand()—rcloneCommandis now redacted before loggingconsole.errorinkeepLatestNBackups()— error string is now redacted before outputThe function is in its own file (
redact.ts) with zero dependencies for clean testability.Testing
6 unit tests in
__test__/backups/redact-credentials.test.ts:All tests pass, Biome lint clean.