melange initramfs and source get log repository and git credentials in cleartext
Description
Impact
melange accepts credentials in apk repository, keyring and git URLs (https://user:pass@host/...). Two melange commands write those URLs to their logs, or into errors, without redacting them. Logs from melange often end up in CI output. On public repositories that output is world-readable.
This is separate from GHSA-8w38-mp5q-mp8m, which covers repository credentials that melange logs through apko. These leaks are in melange's own code.
Affected data paths
At v0.66.0:
melange initramfslogs every--repositoryand--keyringURL at info.melange source getlogs thegit-checkoutrepository URL at info (Cloning <url> to <dir>).- When that clone fails, the error repeats the URL. Go's HTTP client hides a password in it, but not a token passed as the user name (
https://TOKEN@host/...). If the URL does not parse, for example because the password has an unescaped/, the error quotes part of the password.
Affected versions
melange 0.46.0 through 0.66.0. Path 1 was added in 0.46.0, and paths 2 and 3 in 0.46.1.
Patches
Fixed in melange 0.66.1 (chainguard-dev/melange#2774). The URLs are redacted before they are logged or put in an error. A git URL loses its whole user info, so a token passed as the user name is removed too.
Workarounds
- For
melange initramfs, supply repository credentials throughHTTP_AUTHrather than in the URL. - Do not publish logs from
melange initramfsormelange source getruns that use credentialed URLs.