Detecting, Reporting and Mitigating System Vulnerabilities for Go
Tags: go, security
Published: 2020-06-01 21:57:05

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/iqg9777n2wezwiwlqz9e.jpg)

Go Module vulnerabilities frustrate the lives of many Go developers and can turn a simple project into a battle of endurance between the dev and their patience. With the process of CI/CD [shifting left](https://jfrog.com/webinar/shift-left-with-artifactory-pro-x/) more and more, it’s becoming even more pertinent for developers to be able to track and report vulnerabilities as early as possible. [JFrog GoCenter](https://search.gocenter.io/) can help [track and mitigate these vulnerabilities](https://jfrog.com/blog/detecting-reporting-and-mitigating-vulnerabilities-for-go-modules/) and make the lives of Go developers easier.

###**Reporting Vulnerabilities**###
 
Vulnerabilities are monitored consistently throughout the development lifecycle of any system/application and should be reported by anyone who finds the issue so that it’s remediation can be tracked and shared among common organizations. Known vulnerabilities are tracked and classified using the **Common Vulnerability and Exposures (CVE)** - [a list](https://www.jfrog.com/confluence/display/JFROG/Fixed+Security+Vulnerabilities) of publicly disclosed information security vulnerabilities and exposures. Each CVE contains a standard identifier number (CVE ID), a status indicator, a brief description of the vulnerability and references related to vulnerability reports and advisories. 

CVE isn't a vulnerability database - instead, CVE is designed to allow vulnerability databases and other tools to be linked together and facilitates comparisons between security tools and services. The [**National Vulnerability Database (NVD)**](https://nvd.nist.gov/) is a free, public database that uses the CVE list identifiers and includes fix information, scoring and other pertinent information for each vulnerability.

Detected vulnerabilities must be reported to one of the **CVE Numbering Authorities (CNA)** accompanied by detailed documentation explaining the impact of the vulnerability and at least one codebase that it affects before it can be recognized as a common vulnerability and assigned a CVE ID. For reference, the format for the **CVE ID = CVE prefix + Year + Arbitrary Digits**. Below is an example of a CVE ID entry:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xnwkx3svewfs8wun085z.png)

###**The Data Complexity of Securing Go Modules**###

Securing Go modules can be a tricky task, specifically because of the relationship between Go modules and Go packages. Once the security data for a Go module is received, it’s difficult to correlate that data to a specific module version. This is because security vulnerabilities exist on the package level but are reported on the module level. This can leave the impression that the entire module is vulnerable, but that’s often not the case. More than likely, your module will remain secure unless you consume the vulnerable package data. 

Let’s use **CVE-2020-10660** as an example. Below is an excerpt from the version 1.3.4 changelog detailing the effects of this vulnerability: 

[gopkg.in/hashicorp/vault.v0](http://gopkg.in/hashicorp/vault.v0) and [github.com/hashicorp/vault](http://github.com/hashicorp/vault), have both been affected by **CVE-2020-10660** in HashiCorp Vault and Vault Enterprise versions 0.9.0 through 1.3.3. While using these packages they may, under certain circumstances, have an entity's group membership inadvertently include groups that the entity no longer has permissions to. 

Another vulnerability was identified in Vault Enterprise such that, under certain circumstances, existing nested-path policies may give access to namespaces created after-the-fact. Luckily, there was a change made to fix these vulnerabilities in version 1.3.4.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ea763ujf9p5o06n6ngnz.png)

Looking above, the fix was made within [**“github.com/hashicorp/vault/vault”**](https://search.gocenter.io/github.com/hashicorp/vault?version=v0.10.0). The module [istio.io/istio](https://search.gocenter.io/github.com/istio/istio?version=v0.0.0-20191015182630-149c2fc74f0a&tab=overview) has a dependency on “github.com/hashicorp/vault/vault” in its go.mod file. Normally, you would assume that the security of istio.io/istio would be compromised, but it’s only using [**“github.com/hashicorp/vault/api”**](https://github.com/hashicorp/vault/tree/master/api) package, so its code is not affected by the vulnerability. See the source code below.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f33oywyis916uitf14sh.png)

###**Mitigating your Software Vulnerabilities**###

Now that you understand the process of how Go Module vulnerabilities are reported and some details around the security complexities, let’s see how to mitigate these threats in future development.

To start, let’s look at the [github/hashicorp/vault](https://search.gocenter.io/github.com/hashicorp/vault?version=v0.10.1&tab=readme)

Using CVE data, [JFrog Xray](https://jfrog.com/xray/) is able to scan all the dependencies in a go.mod file held by GoCenter and identify every vulnerability. GoCenter exposes this Xray data on the [**Dependencies tab**](https://search.gocenter.io/github.com/hashicorp/vault?version=v0.10.1&tab=dependencies) to provide you detailed information about vulnerable components at every level of your dependency tree. You’ll see a warning triangle next to each vulnerable module. You can then click on the vulnerable module and be routed to that page. From there, click on the [**Version tab**](https://search.gocenter.io/github.com/hashicorp/vault?version=v0.10.1&tab=versions) to look for a secure version of that module so that you can upgrade that in your go.mod file.

Once all components and dependencies have been identified, their information is cross-referenced with other vulnerability feeds and databases to alert you of any potential threats. Basic [Xray vulnerability scanning for Go modules is available for free on  GoCenter](https://jfrog.com/blog/gocenter-reveals-go-module-vulnerabilities-with-xray/), shown in the [**Security tab**](https://search.gocenter.io/github.com/hashicorp/vault?version=v0.10.1&tab=security):

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ro5fzqx3h8p8jop9s7kk.png)

###**Keeping your Software Secure with GoCenter**###

GoCenter is a public GOPROXY and central repository with over 700,000 Go module versions. When using GoCenter as your GOPROXY, you can be sure that the version of code downloaded is the correct version from the correct source code. GoCenter as your GOPROXY works seamlessly with Go commands and has the advantage of being secure, fast, available and storage efficient. 

Many Golang developers can also bring GoCenter’s vulnerability information directly into their IDE, using the free [JFrog extension for VS Code](https://jfrog.com/blog/free-go-module-vulnerability-scanning-in-visual-studio-code/).

With the CI/CD cycle shifted to the left more and more, GoCenter’s security features can help you identify whether or not there are vulnerable dependencies in the public Go module versions you are importing.