Skip to content

fix(backup): redact S3 credentials from logs and error output#4648

Open
rafaumeu wants to merge 1 commit into
Dokploy:canaryfrom
rafaumeu:fix/redact-s3-credentials
Open

fix(backup): redact S3 credentials from logs and error output#4648
rafaumeu wants to merge 1 commit into
Dokploy:canaryfrom
rafaumeu:fix/redact-s3-credentials

Conversation

@rafaumeu

Copy link
Copy Markdown

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 dokploy access — can recover S3 credentials.

Two leak points identified:

  1. getBackupCommand() in utils.ts — logs the full rcloneCommand (including --s3-access-key-id and --s3-secret-access-key flags) via logger.info on every run
  2. keepLatestNBackups() in index.ts — surfaces the rclone command (with credentials) via console.error(error) on failure

Solution

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.info in getBackupCommand()rcloneCommand is now redacted before logging
  • console.error in keepLatestNBackups() — error string is now redacted before output

The 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:

  • Redacts access key from rclone command
  • Redacts secret access key from rclone command
  • Redacts both credentials simultaneously
  • Does not modify non-credential flags (region, endpoint, etc.)
  • Handles commands with no credentials (no-op)
  • Handles error strings containing credentials

All tests pass, Biome lint clean.

…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
@rafaumeu rafaumeu requested a review from Siumauricio as a code owner June 16, 2026 18:44
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: S3 backup credentials (access key + secret) logged in plaintext to Dokploy service stdout

1 participant