HashiCorp go-getter Vulnerable to Argument Injection When Fetching Remote Default Git Branches
Description
HashiCorp’s go-getter library is vulnerable to argument injection when executing Git to discover remote branches.
This vulnerability does not affect the go-getter/v2 branch and package.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
HashiCorp's go-getter library before 1.7.4 is vulnerable to argument injection when using Git to discover remote branches, allowing attackers to inject arbitrary Git arguments via a crafted URL.
Vulnerability
CVE-2024-3817 is an argument injection vulnerability in HashiCorp's go-getter library (versions 1.5.9 to 1.7.3). The flaw occurs when go-getter executes Git commands to discover remote branches of a repository. Specifically, user-provided Git URLs are not properly sanitized before being passed as arguments to the Git binary, enabling an attacker to inject additional Git arguments [2][3].
Exploitation
An attacker can exploit this vulnerability by supplying a specially crafted Git URL to an application that uses the go-getter library. No authentication is required; the attacker only needs to control the URL input. The injection occurs during the git ls-remote or git clone operations, where extra arguments appended by the attacker are executed by Git [3][4].
Impact
Successful exploitation could allow an attacker to inject arbitrary Git arguments, potentially leading to code execution, information disclosure, or other unintended behaviors, depending on the context in which go-getter is used. The impact is particularly significant in environments like Terraform or Nomad, where go-getter is used to download modules or binaries [3].
Mitigation
The vulnerability is fixed in go-getter version 1.7.4. The fix ensures that user-provided strings are properly escaped by using a -- separator before the URL in Git commands, preventing argument injection [4]. Users are advised to upgrade to 1.7.4 or later. The go-getter/v2 branch is not affected [3].
AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
github.com/hashicorp/go-getterGo | >= 1.5.9, < 1.7.4 | 1.7.4 |
Affected products
38- osv-coords37 versionspkg:apk/chainguard/conftestpkg:apk/chainguard/conftest-fipspkg:apk/chainguard/k9spkg:apk/chainguard/kubescapepkg:apk/chainguard/opentofupkg:apk/chainguard/opentofu-compatpkg:apk/chainguard/opentofu-local-provider-configpkg:apk/chainguard/terraformpkg:apk/chainguard/terraform-compatpkg:apk/chainguard/terraform-fips-1.5pkg:apk/chainguard/terraform-fips-1.5-compatpkg:apk/chainguard/terraform-fips-1.5-local-provider-configpkg:apk/chainguard/terraform-local-provider-configpkg:apk/chainguard/tflintpkg:apk/chainguard/tflint-compatpkg:apk/chainguard/tfsecpkg:apk/chainguard/zarfpkg:apk/chainguard/zotpkg:apk/wolfi/conftestpkg:apk/wolfi/k9spkg:apk/wolfi/kubescapepkg:apk/wolfi/opentofupkg:apk/wolfi/opentofu-compatpkg:apk/wolfi/opentofu-local-provider-configpkg:apk/wolfi/terraformpkg:apk/wolfi/terraform-compatpkg:apk/wolfi/terraform-local-provider-configpkg:apk/wolfi/tflintpkg:apk/wolfi/tflint-compatpkg:apk/wolfi/tfsecpkg:apk/wolfi/zarfpkg:apk/wolfi/zotpkg:golang/github.com/hashicorp/go-getterpkg:rpm/opensuse/trivy&distro=openSUSE%20Leap%2015.6pkg:rpm/opensuse/trivy&distro=openSUSE%20Leap%2016.0pkg:rpm/opensuse/trivy&distro=openSUSE%20Tumbleweedpkg:rpm/suse/trivy&distro=SUSE%20Package%20Hub%2015%20SP6
< 0.52.0-r0+ 36 more
- (no CPE)range: < 0.52.0-r0
- (no CPE)range: < 0.52.0-r0
- (no CPE)range: < 0.32.4-r3
- (no CPE)range: < 3.0.9-r0
- (no CPE)range: < 1.7.0-r0
- (no CPE)range: < 1.7.0-r0
- (no CPE)range: < 1.7.0-r0
- (no CPE)range: < 1.5.7-r8
- (no CPE)range: < 1.5.7-r8
- (no CPE)range: < 1.5.7-r9
- (no CPE)range: < 1.5.7-r9
- (no CPE)range: < 1.5.7-r9
- (no CPE)range: < 1.5.7-r8
- (no CPE)range: < 0.51.0-r0
- (no CPE)range: < 0.51.0-r0
- (no CPE)range: < 1.28.5-r3
- (no CPE)range: < 0.33.1-r1
- (no CPE)range: < 2.0.4-r0
- (no CPE)range: < 0.52.0-r0
- (no CPE)range: < 0.32.4-r3
- (no CPE)range: < 3.0.9-r0
- (no CPE)range: < 1.7.0-r0
- (no CPE)range: < 1.7.0-r0
- (no CPE)range: < 1.7.0-r0
- (no CPE)range: < 1.5.7-r8
- (no CPE)range: < 1.5.7-r8
- (no CPE)range: < 1.5.7-r8
- (no CPE)range: < 0.51.0-r0
- (no CPE)range: < 0.51.0-r0
- (no CPE)range: < 1.28.5-r3
- (no CPE)range: < 0.33.1-r1
- (no CPE)range: < 2.0.4-r0
- (no CPE)range: >= 1.5.9, < 1.7.4
- (no CPE)range: < 0.58.2-bp156.2.6.1
- (no CPE)range: < 0.66.0-bp160.1.1
- (no CPE)range: < 0.58.2-1.1
- (no CPE)range: < 0.58.2-bp156.2.6.1
- HashiCorp/Shared libraryv5Range: 1.5.9
Patches
1268c11cae8cfescape user provide string to git (#483)
2 files changed · +32 −2
get_git.go+2 −2 modified@@ -200,7 +200,7 @@ func (g *GitGetter) clone(ctx context.Context, dst, sshKeyFile string, u *url.UR args = append(args, "--depth", strconv.Itoa(depth)) args = append(args, "--branch", ref) } - args = append(args, u.String(), dst) + args = append(args, "--", u.String(), dst) cmd := exec.CommandContext(ctx, "git", args...) setupGitEnv(cmd, sshKeyFile) @@ -289,7 +289,7 @@ func findDefaultBranch(ctx context.Context, dst string) string { // default branch. "master" is returned if no HEAD symref exists. func findRemoteDefaultBranch(ctx context.Context, u *url.URL) string { var stdoutbuf bytes.Buffer - cmd := exec.CommandContext(ctx, "git", "ls-remote", "--symref", u.String(), "HEAD") + cmd := exec.CommandContext(ctx, "git", "ls-remote", "--symref", "--", u.String(), "HEAD") cmd.Stdout = &stdoutbuf err := cmd.Run() matches := lsRemoteSymRefRegexp.FindStringSubmatch(stdoutbuf.String())
get_git_test.go+30 −0 modified@@ -836,6 +836,36 @@ func TestGitGetter_subdirectory(t *testing.T) { } } +func TestGitGetter_BadRemoteUrl(t *testing.T) { + + if !testHasGit { + t.Log("git not found, skipping") + t.Skip() + } + + g := new(GitGetter) + dst := tempDir(t) + + // try an option that exists + badUrl := "--no-refs" + + u, err := url.Parse(badUrl) + if err != nil { + t.Fatal(err) + } + + err = g.Get(dst, u) + if err == nil { + t.Fatalf("get succeeded; want error") + } + + got := err.Error() + want := `repository '--no-refs' does not exist` + if !strings.Contains(got, want) { + t.Fatalf("wrong error\ngot: %s\nwant: %q", got, want) + } +} + // gitRepo is a helper struct which controls a single temp git repo. type gitRepo struct { t *testing.T
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
4- github.com/advisories/GHSA-q64h-39hv-4cf7ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-3817ghsaADVISORY
- discuss.hashicorp.com/t/hcsec-2024-09-hashicorp-go-getter-vulnerable-to-argument-injection-when-fetching-remote-default-git-branches/66040ghsaWEB
- github.com/hashicorp/go-getter/commit/268c11cae8cf0d9374783e06572679796abe9ce9ghsaWEB
News mentions
0No linked articles in our index yet.