Rotate credentials and remove logs that may contain passwords
Use this procedure after upgrading CD to 5.19.1 if you ran affected plans on CD 5.0.0 through 5.19.0.
Upgrade CD to 5.19.1 before rotating credentials. You need access to the Bolt runner and Hiera data, and root access to the CD hosts. Check your log-retention policy before removing system logs.
Credential rotation is the remediation. Removing logs only removes local copies; credentials may also remain in support bundles or forwarded logs. Passwords were visible in the host process list only while the commands ran, so no process-list cleanup is needed. For affected logs and exposure conditions, see Database and root admin passwords can appear in plaintext in logs.
- Upgrade CD to 5.19.1 before changing any passwords. Earlier versions can write the new passwords to logs during the next plan run.
- Rotate the
cd4peandquerydatabase passwords:- If you use a managed database, set new values for
database.managed.cd4pe_db_passwordanddatabase.managed.query_db_passwordin Hiera, then run:Copybolt plan run cd4peadm::apply_configurationThe plan updates the database roles and services.
- If you use an external database, change the role passwords on the PostgreSQL server first. Then update
database.external.cd4pe_db_passwordanddatabase.external.query_db_passwordin Hiera and runbolt plan run cd4peadm::apply_configuration.
- If you use a managed database, set new values for
- Set a new
root_passwordvalue in Hiera and runbolt plan run cd4peadm::apply_configurationto rotate the CD root admin password. - This step only applies if you’ve run the external migration but are still using a managed database. If you ran an external-database migration plan as a non-root Bolt user, rotate the managed PostgreSQL superuser password. The
apply_configurationplan does not rotate this password. Replace<runtime>withdockerorpodman, then run the command and enter the new password at the prompt:Copy<runtime> exec -it postgres psql -U postgres -c '\password postgres'Update
database.managed.admin_db_passwordin Hiera to match the new password. - On the Bolt runner, delete
bolt-debug.logfrom the Bolt project directory and remove old support bundles under<bolt project>/downloads/cd4pe/supportbundle-*. - If you use a managed database, clean up
postgresql.logon the database host. The log is in/var/lib/docker/volumes/postgres-logs/_data/for Docker or/var/lib/containers/storage/volumes/postgres-logs/_data/for Podman. Change to the directory for your runtime before running these commands. - Clean up host system logs only if Bolt connected as a non-root user and escalated with
run-asor sudo, or if the host has anexecveaudit rule:- For authentication logs, find files that contain the credentials and redact the matching values. Run the redaction command for each file returned by
grep:Copygrep -lE 'PGPASSWORD=|CD4PE_ROOT_PASSWORD=|CD4PE_ROOT_EMAIL=' /var/log/secure* /var/log/auth.log*
sed -i -E 's/((PGPASSWORD|CD4PE_ROOT_PASSWORD|CD4PE_ROOT_EMAIL)=)[^ ]*/\1[REDACTED]/g' <file> - Individual systemd journal entries cannot be edited. The following commands rotate the journal and delete all archived journal history. Check this against your retention policy first:Copy
journalctl --rotate
journalctl --vacuum-time=1s - Audit log commands are hex-encoded. Check for matching records, then rotate the audit log and remove old files only as your policy allows:Copy
ausearch -i -m USER_CMD,EXECVE | grep -E 'PGPASSWORD=|CD4PE_ROOT_PASSWORD=|CD4PE_ROOT_EMAIL='
service auditd rotate
- For authentication logs, find files that contain the credentials and redact the matching values. Run the redaction command for each file returned by
- Ask the teams that own forwarded logs, such as a SIEM or log aggregator, and any recipients of shared support bundles to purge or restrict matching copies.
You have rotated the affected credentials and removed the local log copies. Log cleanup does not remove copies in support bundles or forwarded logging systems, and it does not replace credential rotation.