CVE-2025-0495 - Secrets Leakage in Docker Buildx Cache Configuration

In early 2025, a significant vulnerability was discovered in Buildx, a popular Docker CLI plugin that enhances Docker’s build process using BuildKit. Identified as CVE-2025-0495, the issue involves the unintended exposure of sensitive secrets via OpenTelemetry traces and BuildKit daemon history when using Buildx cache backends.

This article gives a clear, exclusive overview of the bug, complete with code snippets, reference links, and an explanation of how the exploit works—and how you can avoid falling victim.

Background: What is Docker Buildx?

Buildx extends Docker CLI capabilities by leveraging BuildKit—an advanced toolkit that makes building images faster and more flexible. One key feature is support for various cache backends (like S3, Github, or local storage). This helps speed up builds by reusing intermediate layers.

To authenticate with these backends, users often provide credentials (like API keys or secrets) through CLI flags or configuration options.

The Vulnerability: How Secrets Leak

Cache backends in Buildx let you authenticate by setting secrets *directly as attribute values* in your --cache-to and --cache-from options. For instance:

docker buildx build \
  --cache-to=type=s3,access_key_id=AKIA...,secret_access_key=your-secret \
  .

If secret_access_key is set right there in the command, Buildx’s OpenTelemetry tracing will record the entire command including the secret. These traces may be:

Stored in the BuildKit daemon’s local history

Anyone with access to these logs or history records could retrieve your secrets, even long after the build is done.

Let’s say Alice runs this command

docker buildx build \
  --cache-to=type=s3,access_key_id=AKIA...,secret_access_key=top-secret-key \
  .

Suppose OpenTelemetry tracing is enabled (by default or by policy)

1. The entire command and its arguments, including secret_access_key=top-secret-key, are stored as telemetry events.

BuildKit daemon logs also store the build invocation history, again with the flag and its value.

3. Later, someone who can read these traces/logs can find top-secret-key, possibly gaining access to S3 storage and other resources.

What’s NOT Impacted

- Secrets passed via environment variables (e.g., AWS_SECRET_ACCESS_KEY=top-secret-key docker buildx build ...) are NOT leaked by this bug.
- Github cache backend secrets, if passed via environment variables or via authentication setup, are safe.

Real-World Impact

This is especially dangerous in shared environments (e.g., CI/CD servers, team workstations, cloud builders) where:

Patch Status

As of June 2024, the Buildx maintainers and BuildKit team have released patches that:

Buildx vulnerability discussion:

github.com/docker/buildx/issues/2512

BuildKit patch PR:

github.com/moby/buildkit/pull/4051

Official CVE record:

cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2025-0495

Buildx documentation:

docs.docker.com/build/buildx/cache/

OpenTelemetry:

opentelemetry.io

Summary

CVE-2025-0495 is a reminder that secrets should never be typed directly into commands—or anywhere they might end up in logs or telemetry. Update your tools and review your processes today to keep your build secrets safe.

Timeline

Published on: 03/17/2025 20:15:13 UTC