Skip to content

Commit 0e51963

Browse files
authored
[MEDIUM] Patch moby-buildx for CVE-2025-0495 (#13782)
1 parent e74212b commit 0e51963

File tree

2 files changed

+111
-1
lines changed

2 files changed

+111
-1
lines changed

SPECS/moby-buildx/CVE-2025-0495.patch

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
From 4745215cea5eb7927e2ff37a57124c91355f1bd7 Mon Sep 17 00:00:00 2001
2+
From: Aninda <[email protected]>
3+
Date: Tue, 13 May 2025 08:36:18 -0400
4+
Subject: [PATCH] Address CVE-2025-0495
5+
Upstream Patch Reference: https://github.com/docker/buildx/commit/0982070af84d476b232d2d75ab551c3222592db1
6+
7+
---
8+
commands/bake.go | 12 +++++++++++-
9+
commands/build.go | 7 ++++++-
10+
util/tracing/trace.go | 7 +++----
11+
3 files changed, 20 insertions(+), 6 deletions(-)
12+
13+
diff --git a/commands/bake.go b/commands/bake.go
14+
index 129b635..a3fa1ac 100644
15+
--- a/commands/bake.go
16+
+++ b/commands/bake.go
17+
@@ -5,6 +5,7 @@ import (
18+
"encoding/json"
19+
"fmt"
20+
"os"
21+
+ "strings"
22+
23+
"github.com/containerd/containerd/platforms"
24+
"github.com/docker/buildx/bake"
25+
@@ -17,6 +18,7 @@ import (
26+
"github.com/moby/buildkit/util/appcontext"
27+
"github.com/pkg/errors"
28+
"github.com/spf13/cobra"
29+
+ "go.opentelemetry.io/otel/attribute"
30+
)
31+
32+
type bakeOptions struct {
33+
@@ -29,7 +31,15 @@ type bakeOptions struct {
34+
func runBake(dockerCli command.Cli, targets []string, in bakeOptions) (err error) {
35+
ctx := appcontext.Context()
36+
37+
- ctx, end, err := tracing.TraceCurrentCommand(ctx, "bake")
38+
+ // Convert slices to strings
39+
+ targetsStr := strings.Join(targets, ",")
40+
+ filesStr := strings.Join(in.files, ",")
41+
+
42+
+ ctx, end, err := tracing.TraceCurrentCommand(ctx, append([]string{"bake"}, targets...),
43+
+ attribute.String("builder", in.commonOptions.builder),
44+
+ attribute.String("targets", targetsStr),
45+
+ attribute.String("files", filesStr),
46+
+ )
47+
if err != nil {
48+
return err
49+
}
50+
diff --git a/commands/build.go b/commands/build.go
51+
index bfefd70..be6a41e 100644
52+
--- a/commands/build.go
53+
+++ b/commands/build.go
54+
@@ -26,6 +26,7 @@ import (
55+
"github.com/sirupsen/logrus"
56+
"github.com/spf13/cobra"
57+
"github.com/spf13/pflag"
58+
+ "go.opentelemetry.io/otel/attribute"
59+
)
60+
61+
const defaultTargetName = "default"
62+
@@ -72,7 +73,11 @@ type commonOptions struct {
63+
func runBuild(dockerCli command.Cli, in buildOptions) (err error) {
64+
ctx := appcontext.Context()
65+
66+
- ctx, end, err := tracing.TraceCurrentCommand(ctx, "build")
67+
+ ctx, end, err := tracing.TraceCurrentCommand(ctx, []string{"build", in.contextPath},
68+
+ attribute.String("builder", in.builder),
69+
+ attribute.String("context", in.contextPath),
70+
+ attribute.String("dockerfile", in.dockerfileName),
71+
+ )
72+
if err != nil {
73+
return err
74+
}
75+
diff --git a/util/tracing/trace.go b/util/tracing/trace.go
76+
index c95ad5a..13ce349 100644
77+
--- a/util/tracing/trace.go
78+
+++ b/util/tracing/trace.go
79+
@@ -2,7 +2,6 @@ package tracing
80+
81+
import (
82+
"context"
83+
- "os"
84+
"strings"
85+
86+
"github.com/moby/buildkit/util/tracing/detect"
87+
@@ -10,13 +9,13 @@ import (
88+
"go.opentelemetry.io/otel/trace"
89+
)
90+
91+
-func TraceCurrentCommand(ctx context.Context, name string) (context.Context, func(error), error) {
92+
+func TraceCurrentCommand(ctx context.Context, args []string, attrs ...attribute.KeyValue) (context.Context, func(error), error) {
93+
tp, err := detect.TracerProvider()
94+
if err != nil {
95+
return context.Background(), nil, err
96+
}
97+
- ctx, span := tp.Tracer("").Start(ctx, name, trace.WithAttributes(
98+
- attribute.String("command", strings.Join(os.Args, " ")),
99+
+ ctx, span := tp.Tracer("").Start(ctx, strings.Join(args, " "), trace.WithAttributes(
100+
+ attrs...,
101+
))
102+
103+
return ctx, func(err error) {
104+
--
105+
2.34.1
106+

SPECS/moby-buildx/moby-buildx.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Summary: A Docker CLI plugin for extended build capabilities with BuildKi
55
Name: moby-%{upstream_name}
66
# update "commit_hash" above when upgrading version
77
Version: 0.7.1
8-
Release: 24%{?dist}
8+
Release: 25%{?dist}
99
License: ASL 2.0
1010
Group: Tools/Container
1111
Vendor: Microsoft Corporation
@@ -24,6 +24,7 @@ Patch7: CVE-2022-41717.patch
2424
Patch8: CVE-2023-45288.patch
2525
Patch9: CVE-2023-48795.patch
2626
Patch10: CVE-2024-24786.patch
27+
Patch11: CVE-2025-0495.patch
2728

2829
BuildRequires: bash
2930
BuildRequires: golang
@@ -54,6 +55,9 @@ cp -aT buildx "%{buildroot}/%{_libexecdir}/docker/cli-plugins/docker-buildx"
5455
%{_libexecdir}/docker/cli-plugins/docker-buildx
5556

5657
%changelog
58+
* Tue May 13 2025 Aninda Pradhan <[email protected]> - 0.7.1-25
59+
- Fixes CVE-2025-0495, referred upstream patch from debian
60+
5761
* Thu Dec 05 2024 sthelkar <[email protected]> - 0.7.1-24
5862
- Patch CVE-2024-24786
5963

0 commit comments

Comments
 (0)