CVE-2021-38197: Github.com/gen2brain/go unarr Tarslip Vulnerability

CRITICAL
Advisory Identifier: GHSA-v9j4-cp63-qv62
CVSS 9.8
CWE-22
Published
Advisory Summary

CVE-2021-38197 is a CRITICAL (CVSS 9.8) tarslip vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Github.com/gen2brain/go unarr libraries in the Go ecosystem. The issue involves tarslip in go-unarr. Remediation is available by upgrading affected packages to version 0.1.4.

CVE-2021-38197 at a Glance

CVE Identifier CVE-2021-38197
GHSA Identifier GHSA-v9j4-cp63-qv62
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Github.com/gen2brain/go unarr
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2021-38197

To remediate this vulnerability, upgrade all affected Github.com/gen2brain/go unarr dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/gen2brain/go-unarr fixed: 0.1.4
Upgrade github.com/gen2brain/go-unarr to 0.1.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/gen2brain/go-unarr

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-38197, inspect your project dependencies for Github.com/gen2brain/go unarr:

inspect dependencies for github.com/gen2brain/go-unarr

Analyze the terminal output to locate any version of Github.com/gen2brain/go unarr in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.1.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Github.com/gen2brain/go unarr, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

unarr.go in go-unarr (aka Go bindings for unarr) 0.1.1 allows Directory Traversal via ../ in a pathname within a TAR archive.

CVE-2021-38197 Affected Github.com/gen2brain/go unarr Versions

1 component(s)
Fixed Versions:
0.1.4
Product / Package Ecosystem Affected Versions Fixed Version
github.com/gen2brain/go-unarr
Go
< 0.1.4
0.1.4

References

Frequently Asked Questions

What is CVE-2021-38197?
CVE-2021-38197 is a security vulnerability in Github.com/gen2brain/go unarr involving Tarslip in go-unarr under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Github.com/gen2brain/go unarr versions are affected?
Affected versions include releases prior to 0.1.4 across affected packages: github.com/gen2brain/go-unarr.
What version fixes CVE-2021-38197?
Upgrading to 0.1.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/gen2brain/go-unarr affected?
Yes, github.com/gen2brain/go-unarr is affected in releases prior to 0.1.4. Upgrade your dependency to 0.1.4 or later.
What is the CVSS score of CVE-2021-38197?
CVE-2021-38197 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-38197?
CVE-2021-38197 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check Go dependencies for CVE-2021-38197?
Run the dependency tree command: 'inspect dependencies for github.com/gen2brain/go-unarr'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-v9j4-cp63-qv62",
  "modified" : "2021-08-30T21:24:59Z",
  "published" : "2021-09-01T18:32:02Z",
  "aliases" : [ "CVE-2021-38197" ],
  "summary" : "Tarslip in go-unarr",
  "details" : "unarr.go in go-unarr (aka Go bindings for unarr) 0.1.1 allows Directory Traversal via ../ in a pathname within a TAR archive.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/gen2brain/go-unarr"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.1.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-38197"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gen2brain/go-unarr/issues/21"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gen2brain/go-unarr/commit/239ec404d348280b50bbf671327709e8857fc5f4"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gen2brain/go-unarr/releases/tag/v0.1.4"
  }, {
    "type" : "PACKAGE",
    "url" : "github.com/gen2brain/go-unarr"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-30T21:24:59Z",
    "nvd_published_at" : "2021-08-08T16:15:00Z"
  }
}