Skip to content

Commit 91ef9b2

Browse files
Patch docker-buildx for CVE-2025-0495 [Medium] (#13768)
1 parent 98835ba commit 91ef9b2

File tree

2 files changed

+103
-1
lines changed

2 files changed

+103
-1
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
From 57f85577943734ab47924d1f2595de12a8613fbf Mon Sep 17 00:00:00 2001
2+
From: Tonis Tiigi <tonistiigi@gmail.com>
3+
Date: Mon, 3 Feb 2025 22:14:55 -0800
4+
Subject: [PATCH] otel: avoid tracing raw os arguments
5+
6+
User might pass a value that they don't expect to
7+
be kept in trace storage. For example some cache backends
8+
allow passing authentication tokens with a flag.
9+
10+
Instead use known primary config values as attributes
11+
of the root span.
12+
13+
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
14+
Modified patch to apply to AzureLinux
15+
Modified-by: Sandeep Karambelkar <skarambelkar@microsoft.com>
16+
Upstream Patch: https://github.com/docker/buildx/commit/18ccba072076ddbfb0aeedd6746d7719b0729b58
17+
Upstream PR: https://github.com/docker/buildx/pull/3068
18+
Only first commit is applicable from https://github.com/docker/buildx/pull/3068/commits
19+
---
20+
commands/bake.go | 7 ++++++-
21+
commands/build.go | 6 +++++-
22+
util/tracing/trace.go | 7 +++----
23+
3 files changed, 14 insertions(+), 6 deletions(-)
24+
25+
diff --git a/commands/bake.go b/commands/bake.go
26+
index cb23066..3fc0b74 100644
27+
--- a/commands/bake.go
28+
+++ b/commands/bake.go
29+
@@ -26,6 +26,7 @@ import (
30+
"github.com/moby/buildkit/util/progress/progressui"
31+
"github.com/pkg/errors"
32+
"github.com/spf13/cobra"
33+
+ "go.opentelemetry.io/otel/attribute"
34+
)
35+
36+
type bakeOptions struct {
37+
@@ -42,7 +43,11 @@ type bakeOptions struct {
38+
}
39+
40+
func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in bakeOptions, cFlags commonFlags) (err error) {
41+
- ctx, end, err := tracing.TraceCurrentCommand(ctx, "bake")
42+
+ ctx, end, err := tracing.TraceCurrentCommand(ctx, append([]string{"bake"}, targets...),
43+
+ attribute.String("builder", in.builder),
44+
+ attribute.StringSlice("targets", targets),
45+
+ attribute.StringSlice("files", in.files),
46+
+ )
47+
if err != nil {
48+
return err
49+
}
50+
diff --git a/commands/build.go b/commands/build.go
51+
index 6f151d4..e4d88c4 100644
52+
--- a/commands/build.go
53+
+++ b/commands/build.go
54+
@@ -271,7 +271,11 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions)
55+
mp := dockerCli.MeterProvider(ctx)
56+
defer metricutil.Shutdown(ctx, mp)
57+
58+
- ctx, end, err := tracing.TraceCurrentCommand(ctx, "build")
59+
+ ctx, end, err := tracing.TraceCurrentCommand(ctx, []string{"build", options.contextPath},
60+
+ attribute.String("builder", options.builder),
61+
+ attribute.String("context", options.contextPath),
62+
+ attribute.String("dockerfile", options.dockerfileName),
63+
+ )
64+
if err != nil {
65+
return err
66+
}
67+
diff --git a/util/tracing/trace.go b/util/tracing/trace.go
68+
index c95ad5a..13ce349 100644
69+
--- a/util/tracing/trace.go
70+
+++ b/util/tracing/trace.go
71+
@@ -2,7 +2,6 @@ package tracing
72+
73+
import (
74+
"context"
75+
- "os"
76+
"strings"
77+
78+
"github.com/moby/buildkit/util/tracing/detect"
79+
@@ -10,13 +9,13 @@ import (
80+
"go.opentelemetry.io/otel/trace"
81+
)
82+
83+
-func TraceCurrentCommand(ctx context.Context, name string) (context.Context, func(error), error) {
84+
+func TraceCurrentCommand(ctx context.Context, args []string, attrs ...attribute.KeyValue) (context.Context, func(error), error) {
85+
tp, err := detect.TracerProvider()
86+
if err != nil {
87+
return context.Background(), nil, err
88+
}
89+
- ctx, span := tp.Tracer("").Start(ctx, name, trace.WithAttributes(
90+
- attribute.String("command", strings.Join(os.Args, " ")),
91+
+ ctx, span := tp.Tracer("").Start(ctx, strings.Join(args, " "), trace.WithAttributes(
92+
+ attrs...,
93+
))
94+
95+
return ctx, func(err error) {
96+
--
97+
2.45.3
98+

SPECS/docker-buildx/docker-buildx.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Summary: A Docker CLI plugin for extended build capabilities with BuildKi
44
Name: docker-buildx
55
# update "commit_hash" above when upgrading version
66
Version: 0.14.0
7-
Release: 4%{?dist}
7+
Release: 5%{?dist}
88
License: ASL 2.0
99
Group: Tools/Container
1010
Vendor: Microsoft Corporation
@@ -14,6 +14,7 @@ Source0: https://github.com/docker/buildx/archive/refs/tags/v%{version}.t
1414
Patch0: CVE-2024-45337.patch
1515
Patch1: CVE-2024-45338.patch
1616
Patch2: CVE-2025-22869.patch
17+
Patch3: CVE-2025-0495.patch
1718

1819
BuildRequires: bash
1920
BuildRequires: golang
@@ -47,6 +48,9 @@ install -m 755 buildx "%{buildroot}%{_libexecdir}/docker/cli-plugins/docker-buil
4748
%{_libexecdir}/docker/cli-plugins/docker-buildx
4849

4950
%changelog
51+
* Tue May 13 2025 Sandeep Karambelkar <skarambelkar@microsoft.com> - 0.14.0-5
52+
- Fix CVE-2025-0495 with upstream patch modified to apply for azurelinux package
53+
5054
* Mon Mar 03 2025 Kanishk Bansal <kanbansal@microsoft.com> - 0.14.0-4
5155
- Fix CVE-2025-22869 with an upstream patch
5256

0 commit comments

Comments
 (0)