Skip to content

Commit a2300b1

Browse files
authored
Patch CVE-2024-3817 in terraform's vendored go-getter (#8862)
1 parent 698c5f4 commit a2300b1

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From aa98faf317f26cd461740fd79bf67abb9890fa07 Mon Sep 17 00:00:00 2001
2+
From: Mark Collao <[email protected]>
3+
Date: Fri, 12 Apr 2024 14:06:23 -0500
4+
Subject: [PATCH] escape user provide string to git
5+
6+
Modified to apply to vendored code by: Daniel McIlvaney <[email protected]>
7+
- Adjusted paths to work for vendored version
8+
- Removed test code since it is not included in vendor trace
9+
---
10+
vendor/github.com/hashicorp/go-getter/get_git.go | 4 ++--
11+
1 file changed, 2 insertions(+), 2 deletions(-)
12+
13+
diff --git a/vendor/github.com/hashicorp/go-getter/get_git.go b/vendor/github.com/hashicorp/go-getter/get_git.go
14+
index db89ede..5227db7 100644
15+
--- a/vendor/github.com/hashicorp/go-getter/get_git.go
16+
+++ b/vendor/github.com/hashicorp/go-getter/get_git.go
17+
@@ -200,7 +200,7 @@ func (g *GitGetter) clone(ctx context.Context, dst, sshKeyFile string, u *url.UR
18+
args = append(args, "--depth", strconv.Itoa(depth))
19+
args = append(args, "--branch", ref)
20+
}
21+
- args = append(args, u.String(), dst)
22+
+ args = append(args, "--", u.String(), dst)
23+
24+
cmd := exec.CommandContext(ctx, "git", args...)
25+
setupGitEnv(cmd, sshKeyFile)
26+
@@ -289,7 +289,7 @@ func findDefaultBranch(ctx context.Context, dst string) string {
27+
// default branch. "master" is returned if no HEAD symref exists.
28+
func findRemoteDefaultBranch(ctx context.Context, u *url.URL) string {
29+
var stdoutbuf bytes.Buffer
30+
- cmd := exec.CommandContext(ctx, "git", "ls-remote", "--symref", u.String(), "HEAD")
31+
+ cmd := exec.CommandContext(ctx, "git", "ls-remote", "--symref", "--", u.String(), "HEAD")
32+
cmd.Stdout = &stdoutbuf
33+
err := cmd.Run()
34+
matches := lsRemoteSymRefRegexp.FindStringSubmatch(stdoutbuf.String())
35+
--
36+
2.33.8

SPECS/terraform/terraform.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Infrastructure as code deployment management tool
22
Name: terraform
33
Version: 1.3.2
4-
Release: 13%{?dist}
4+
Release: 14%{?dist}
55
License: MPLv2.0
66
Vendor: Microsoft Corporation
77
Distribution: Mariner
@@ -28,10 +28,11 @@ Source0: https://github.com/hashicorp/terraform/archive/refs/tags/v%{vers
2828
# - For the value of "--mtime" use the date "2021-04-26 00:00Z" to simplify future updates.
2929
Source1: %{name}-%{version}-vendor.tar.gz
3030
Patch0: CVE-2023-44487.patch
31+
Patch1: CVE-2024-3817.patch
3132

3233
%global debug_package %{nil}
3334
%define our_gopath %{_topdir}/.gopath
34-
BuildRequires: golang <= 1.18.8
35+
BuildRequires: golang
3536

3637
%description
3738
Terraform is an infrastructure as code deployment management tool
@@ -61,6 +62,9 @@ install -p -m 755 -t %{buildroot}%{_bindir} ./terraform
6162
%{_bindir}/terraform
6263

6364
%changelog
65+
* Mon Apr 22 2024 Daniel McIlvaney <[email protected]> - 1.3.2-14
66+
- Patch CVE-2024-3817 in vendored hashicorp/go-getter
67+
6468
* Thu Feb 01 2024 Daniel McIlvaney <[email protected]> - 1.3.2-13
6569
- Address CVE-2023-44487 by patching vendored golang.org/x/net
6670

0 commit comments

Comments
 (0)