CVE-2026-141356 — Chainguard Apko, Melange — CWE-522 · CWE-532
apko versions before 1.5.6 and melange versions before 0.66.1 can expose HTTP Basic Authentication credentials embedded in APK repository URLs. Affected builds can write usernames and passwords in cleartext to logs and error messages, including at the default log level. apko can also expose these credentials in package and index cache directory names and exported trace spans. Anyone with access to this output may obtain the credentials. The earlier fix for CVE-2024-36127 redacted repository URLs during YAML serialization, leaving these other exposure paths open.
apko versions before 1.5.6 and melange versions before 0.66.1 can expose HTTP Basic Authentication credentials embedded in APK repository URLs. Affected builds can write usernames and passwords in cleartext to logs and error messages, including at the default log level. apko can also expose these credentials in package and index cache directory names and exported trace spans. Anyone with access to this output may obtain the credentials. The earlier fix for CVE-2024-36127 redacted repository URLs during YAML serialization, leaving these other exposure paths open.
🎯 What is this vulnerability?
This vulnerability is a Sensitive Information Exposure flaw (CWE-522) and Insertion of Sensitive Information into Log File (CWE-532) in the apko and melange build tools used by the Chainguard ecosystem.
The core technical failure is the lack of comprehensive credential sanitization across all output channels. While a previous fix (for CVE-2024-36127) addressed credential leakage during YAML serialization, it failed to sanitize credentials in:
1. Log Output: Usernames and passwords embedded in APK repository URLs (e.g., https://user:[email protected]/image) are written in cleartext to standard logs and error messages, even at default log levels.
2. Filesystem Artifacts: Credentials are exposed in the names of package and index cache directories.
3. Observability Data: Credentials are included in exported OpenTelemetry trace spans.
The CVSS vector AV:N/AC:L/AT:P/PR:N/UI:N/VC:H indicates that an attacker with network access and physical access to the build environment (or access to the artifacts produced by the build, such as logs, cache directories, or tracing backends) can obtain high-value credentials without requiring prior authentication or user interaction. The "Physical" attack vector here is interpreted in the context of CI/CD infrastructure as access to the build agent's filesystem, log aggregation systems, or monitoring dashboards.
⚡ Attack Chain
1. Discovery & Reconnaissance
An attacker targets a CI/CD pipeline or build environment that usesapko or melange to build container images.
- Vector A (Log Aggregation): The attacker compromises the log aggregation system (e.g., ELK, Splunk, Datadog) or has read access to the build agent's local log files.
- Vector B (Cache Directory): The attacker gains read access to the build agent's filesystem, specifically targeting the cache directories used by
apko. - Vector C (Tracing Backend): The attacker has access to the OpenTelemetry collector or backend (e.g., Jaeger, Zipkin) where trace spans are exported.
2. Exploitation
The attacker searches for patterns indicating embedded credentials in URLs.Scenario A: Log File Analysis (Illustrative)
The attacker greps the build logs for HTTP Basic Auth patterns.
# Illustrative command to find exposed credentials in logs
grep -E "https?://[^:]+:[^@]+@" /var/log/apko/build.log
# Output example:
# [INFO] Fetching image from https://admin:[email protected]/base-image:latestScenario B: Cache Directory Enumeration (Illustrative)
The attacker lists the cache directory where apko stores package indices. The directory names may contain the URL or parts of it.
# Illustrative command to inspect cache directories
ls -la /var/cache/apko/
# Output example:
# drwxr-xr-x 2 root root 4096 Dec 3 10:00 https://admin:[email protected]Scenario C: Trace Span Inspection (Illustrative)
The attacker queries the tracing backend for spans containing sensitive attributes.
# Illustrative query to Jaeger API
curl -s "http://jaeger:16686/api/traces?service=apko" | jq '.data[] | select(.spans[].tags[] | .key == "url" and (.value | contains("://"))) | .spans[].tags[] | select(.key == "url") | .value'
# Output example:
# "https://admin:[email protected]/base-image:latest"3. Post-exploitation
Once the credentials (username and password) for the internal container registry are extracted: 1. Registry Compromise: The attacker uses the stolen credentials to authenticate to the internal container registry (registry.internal.corp).
2. Image Tampering: The attacker can push malicious images to the registry, potentially overwriting legitimate base images or injecting backdoors into new builds.
3. Lateral Movement: If the registry credentials are reused across other services (e.g., artifact repositories, cloud provider APIs), the attacker can pivot to those systems.
4. Supply Chain Attack: By pushing a malicious base image, the attacker can compromise all downstream applications that use that base image, leading to widespread RCE in production environments.🌍 Real World Impact
🛡️ Remediation & Mitigation
Exact Affected Versions & Upgrade Recommendation
Action:
# For apko
go install github.com/chainguard-dev/apko/cmd/[email protected]
# For melange
go install github.com/chainguard-dev/melange/cmd/[email protected]Actionable Workarounds
1. Avoid Embedding Credentials in URLs: * Use environment variables or secret managers (e.g., HashiCorp Vault, AWS Secrets Manager) to inject credentials at runtime, rather than hardcoding them in repository URLs. * Use.netrc files or registry configuration files that are securely managed and not logged.2. Restrict Access to Logs and Caches:
* Ensure that log files and cache directories are accessible only to the build user and root.
* Rotate and purge logs after build completion to minimize the window of exposure.
3. Sanitize Tracing Data:
* Configure OpenTelemetry exporters to filter out sensitive attributes (e.g., URLs with credentials) before exporting spans.
* Use a custom processor to redact any string matching the pattern https?://[^:]+:[^@]+@.
4. WAF/ModSecurity Rule (Illustrative):
* While WAFs are not typically deployed on build agents, if logs are exposed via a web interface, a rule can be added to block access to log files containing credential patterns.
# ModSecurity Rule to block access to log files with embedded credentials
SecRule REQUEST_URI "@rx \.(log|txt)$" \
"id:1001,phase:1,deny,status:403,msg:'Access to log files blocked'"Detection: IoCs
1. Log Patterns: * Search for URLs with embedded credentials in build logs:https?://[^:]+:[^@]+@* Example: https://user:[email protected]
2. Filesystem Artifacts:
* Check for cache directories with names containing URL patterns:
find /var/cache/apko -type d -name "*://*"3. Tracing Data:
* Query tracing backends for spans containing URLs with credentials:
SELECT * FROM traces WHERE attributes LIKE '%://%@%'⚠️ Urgency
apko and melange to the fixed versions and audit their build environments for any previously exposed credentials.[🤖 CVE Professor AI Security Engine]
FOFA Query