Skip to main content
Menu
Advisories

Repository credentials still logged in cleartext after the fix for GHSA-v6mg-7f7p-qmqp

GHSA-8W38-MP5Q-MP8MPublished Updated GitHub

Description

Impact

apko accepts HTTP basic-auth credentials in repository URLs (https://user:pass@host/...). The fix for GHSA-v6mg-7f7p-qmqp (CVE-2024-36127, commit 2c0533e4) redacted those URLs only when the image configuration is marshalled to YAML. Log statements and error messages that format repository URLs directly still write the username and password in cleartext.

Logs from apko, and from tools that embed it such as melange, often end up in CI output. On public repositories that output is world-readable.

Affected data paths

At main 0408833b:

  1. (*APK).InitRuntimeOnlyKeys logs the runtime-only repository URL at warn. Key discovery rejects any URL that contains user info (canonicalHTTPOrigin), so for a credentialed runtime-only repository this line fires on every build, with no network failure needed.
  2. (*ImageConfiguration).Summarize logs build, runtime-only and main repositories at info. melange calls Summarize on every build.
  3. Package fetch errors include the raw URL: package_getter.go, httpStatusError.Error and transport.go. They reach the warn-level retry log and the final error on any 5xx or 429 response.
  4. debug level: (*APK).SetRepositories, (*APK).fetchChainguardKeys and the key-discovery lines in apko lock.
  5. The redact() helper itself did not redact a URL that fails to parse, for example one whose password contains an unescaped /, ? or #, as base64 tokens often do. Such URLs kept their credentials in every redacted log line and error, including path 1.
  6. The on-disk package and index cache. Each repository's cache directory was named after its URL, password included. Cache paths appear in debug logs and errors, and the password stays on disk in the directory name. CI jobs that save or upload the apk cache directory publish it.
  7. Trace spans. On a package cache miss, the span name contained the full package URL, so anyone exporting apko traces received the password.

Attack prerequisites

  1. A build configures at least one repository URL with embedded credentials.
  2. The attacker can read the build's log output, for example the CI logs of a public repository.

Paths 1 to 3 need only the default log level.

Affected versions

apko releases through 1.5.5, and melange releases through 0.66.0, which log repositories through apko's Summarize.

Reproduction

Against main at 0408833b, with the repository https://apkuser:SUPERSECRET@127.0.0.1:1/os:

  1. Call InitRuntimeOnlyKeys with a logger at info level. The warn line contains SUPERSECRET.
  2. Call Summarize on an ImageConfiguration that lists the repository, at info level. The output contains SUPERSECRET, while yaml.Marshal of the same configuration does not.
  3. Call SetRepositories and fetchChainguardKeys at debug level. Both lines contain SUPERSECRET.

Patches

Fixed in apko 1.5.6. Every repository and key URL is now redacted before it is logged or put in an error, and URLs that fail to parse are fully redacted. melange users should upgrade to melange 0.66.1 or later.

After upgrading, delete any apk cache directory filled from repository URLs with credentials in them; their names contain the password. Online builds refill the cache automatically. Offline builds that use a cache filled by an earlier release fail until it is refilled with the fixed release.

Workarounds

  • Supply repository credentials through HTTP_AUTH rather than in the repository URL.
  • Do not publish apko or melange build logs from builds that use credentialed repository URLs.

Affected versions

References

GitHub · chainguard-dev/apko