Vulnerabilities in pkg:golang/github.com/datacharmer/dbdeployer

PACKAGE
Advisory Identifier: GHSA-47wr-426j-fr82
Advisory Summary

CVE-2020-26277 is a MODERATE (CVSS 6.1) symbolic links vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting Github.com/datacharmer/dbdeployer libraries in the Go ecosystem. The issue involves symbolic links in an unpacking routine may enable attackers to read and/or write to arbitrary locations in dbdeployer. Remediation is available by upgrading affected packages to version 1.58.2.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/datacharmer/dbdeployer

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:golang/github.com/datacharmer/dbdeployer. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-47wr-426j-fr82 CVE-2020-26277 MODERATE Symbolic links in an unpacking routine may enable attackers to read and/or write to arbitrary locations in dbdeployer

CVE-2020-26277 at a Glance

CVE Identifier CVE-2020-26277
GHSA Identifier GHSA-47wr-426j-fr82
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-59: Improper Link Resolution Before File Access ('Link Following')
Affected Product Github.com/datacharmer/dbdeployer
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 6.1

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

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

How to Fix CVE-2020-26277

To remediate this vulnerability, upgrade all affected Github.com/datacharmer/dbdeployer 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/datacharmer/dbdeployer fixed: 1.58.2
Upgrade github.com/datacharmer/dbdeployer to 1.58.2
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/datacharmer/dbdeployer

How to Check if You Are Affected

To determine whether your application is affected by CVE-2020-26277, inspect your project dependencies for Github.com/datacharmer/dbdeployer:

inspect dependencies for github.com/datacharmer/dbdeployer

Analyze the terminal output to locate any version of Github.com/datacharmer/dbdeployer in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.58.2), 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-59: Improper Link Resolution Before File Access ('Link Following'), where the product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. In Github.com/datacharmer/dbdeployer, 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

### Impact _Users unpacking a tarball through dbdeployer may use a maliciously packaged tarball that contains symlinks to files external to the target. In such scenario, an attacker could induce dbdeployer to write into a system file, thus altering the computer defences._ ### Mitigating factors For the attach to succeed, the following factors need to contribute: * The user is logged in as root. While dbdeployer is usable as root, it was designed to run as unprivileged user. * The user has taken a tarball from a non secure source, without testing the checksum. When the tarball is retrieved through dbdeployer, the checksum is compared before attempting to unpack. ### Analysis An attacker could inject a symbolic link into the tarball, so that a file could result into `fake_file -> /etc/passwd` or some equally important file. As it is now, dbdeployer would create the symlink as defined, with a local file `fake_file` linked to `/etc/passwd`. The danger here is that any process with the privileges to write to both `fake_file` and `/etc/passwd` could overwrite the system file. Even without malicious intent, this could result in the system to become unusable. As noted above, the user must have write privileges to the target file to do the damage. ### Remedies It has been suggested that the extract procedure use `filepath.EvalSymlinks` to determine whether the target is within the extraction directory. Unfortunately, this approach is unavailable in this context, because it would prevent legitimate patterns from being carried out. A simple case is a file `mysql-8.0.22-macos10.15-x86_64/bin/libprotobuf-lite.3.11.4.dylib` with a linkName `../lib/libprotobuf-lite.3.11.4.dylib`, if the linked file has not been created yet, `filepath.EvalSymlinks` would fail, as it acts on existing files only. An alternative method is comparing the depth (how many directories) of the file name with the depth of the link name. If the link name has a higher depth than the local file, we block the operation with an appropriate error: ``` Unpacking tarball exploit/mysql-8.0.22-macos10.15-x86_64.tar.gz to $HOME/opt/mysql/test8.0.22 ...... link '../../../../../../../../../../etc' points outside target directory exit status 1 ``` As an additional fortifier, we can check whether the link points to an existing file, calculate its absolute name, and compare it with the absolute name of the extraction directory. A link to a full path (such as `/etc/passwd`) would fail this test, and trigger an error. The same check can be applied to a link to a non existing file with absolute path. ### Patches Patched in release 1.58.2 ### For more information If you have any questions or comments about this advisory: * Open an issue in [dbdeployer](https://github.com/datacharmer/dbdeployer)

CVE-2020-26277 Affected Github.com/datacharmer/dbdeployer Versions

1 component(s)
Fixed Versions:
1.58.2
Product / Package Ecosystem Affected Versions Fixed Version
github.com/datacharmer/dbdeployer
Go
< 1.58.2
1.58.2

References

Frequently Asked Questions

What is CVE-2020-26277?
CVE-2020-26277 is a security vulnerability in Github.com/datacharmer/dbdeployer involving Symbolic links in an unpacking routine may enable attackers to read and/or write to arbitrary locations in dbdeployer under CWE-59: Improper Link Resolution Before File Access ('Link Following').
Which Github.com/datacharmer/dbdeployer versions are affected?
Affected versions include releases prior to 1.58.2 across affected packages: github.com/datacharmer/dbdeployer.
What version fixes CVE-2020-26277?
Upgrading to 1.58.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/datacharmer/dbdeployer affected?
Yes, github.com/datacharmer/dbdeployer is affected in releases prior to 1.58.2. Upgrade your dependency to 1.58.2 or later.
What is the CVSS score of CVE-2020-26277?
CVE-2020-26277 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:N/I:H/A:N.
What CWE is associated with CVE-2020-26277?
CVE-2020-26277 is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following') (The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.).
How can I check Go dependencies for CVE-2020-26277?
Run the dependency tree command: 'inspect dependencies for github.com/datacharmer/dbdeployer'. 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-47wr-426j-fr82",
  "modified" : "2021-05-21T18:35:39Z",
  "published" : "2022-02-12T00:14:07Z",
  "aliases" : [ "CVE-2020-26277" ],
  "summary" : "Symbolic links in an unpacking routine may enable attackers to read and/or write to arbitrary locations in dbdeployer",
  "details" : "### Impact\n_Users unpacking a tarball through dbdeployer may use a maliciously packaged tarball that contains symlinks to files external to the target. In such scenario, an attacker could induce dbdeployer to write into a system file, thus altering the computer defences._\n\n### Mitigating factors\nFor the attach to succeed, the following factors need to contribute:\n\n* The user is logged in as root. While dbdeployer is usable as root, it was designed to run as unprivileged user.\n*  The user has taken a tarball from a non secure source, without testing the checksum. When the tarball is retrieved through dbdeployer, the checksum is compared before attempting to unpack.\n\n### Analysis\n\nAn attacker could inject a symbolic link into the tarball, so that a file could result into `fake_file -> /etc/passwd` or some equally  important file.\nAs it is now, dbdeployer would create the symlink as defined, with a local file `fake_file` linked to `/etc/passwd`. The danger here is that any process with the privileges to write to both `fake_file` and `/etc/passwd` could overwrite the system file. Even without malicious intent, this could result in the system to become unusable.\nAs noted above, the user must have write privileges to the target file to do the damage.\n\n### Remedies\n\nIt has been suggested that the extract procedure use `filepath.EvalSymlinks` to determine whether the target is within the extraction directory. Unfortunately, this approach is unavailable in this context, because it would prevent legitimate patterns from being carried out.\nA simple case is a file `mysql-8.0.22-macos10.15-x86_64/bin/libprotobuf-lite.3.11.4.dylib` with a linkName `../lib/libprotobuf-lite.3.11.4.dylib`, if the linked file has not been created yet, `filepath.EvalSymlinks` would fail, as it acts on existing files only.\n\nAn alternative method is comparing the depth (how many directories) of the file name with the depth of the link name. If the link name has a higher depth than the local file, we block the operation with an appropriate error:\n\n```\nUnpacking tarball exploit/mysql-8.0.22-macos10.15-x86_64.tar.gz to $HOME/opt/mysql/test8.0.22\n......\nlink '../../../../../../../../../../etc' points outside target directory\n\nexit status 1\n```\nAs an additional fortifier, we can check whether the link points to an existing file, calculate its absolute name, and compare it with the absolute name of the extraction directory. A link to a full path (such as `/etc/passwd`) would fail this test, and trigger an error.\n\nThe same check can be applied to a link to a non existing file with absolute path.\n\n### Patches\n\nPatched in release 1.58.2\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [dbdeployer](https://github.com/datacharmer/dbdeployer)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/datacharmer/dbdeployer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.58.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/datacharmer/dbdeployer/security/advisories/GHSA-47wr-426j-fr82"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-26277"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/datacharmer/dbdeployer/commit/548e256c1de2f99746e861454e7714ec6bc9bb10"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-59" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-21T18:35:39Z",
    "nvd_published_at" : "2020-12-21T22:15:00Z"
  }
}