CVE-2020-15229: Github.com/sylabs/singularity Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-7gcp-w6ww-2xv9
CVSS 8.2
CWE-22
Published
Advisory Summary

CVE-2020-15229 is a HIGH (CVSS 8.2) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Github.com/sylabs/singularity libraries in the Go ecosystem. The issue involves path traversal and files overwrite with unsquashfs in singularity. Remediation is available by upgrading affected packages to version 3.6.4.

CVE-2020-15229 at a Glance

CVE Identifier CVE-2020-15229
GHSA Identifier GHSA-7gcp-w6ww-2xv9
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Github.com/sylabs/singularity
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 8.2

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:R/S:C/C:L/I:H/A:N).

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

How to Fix CVE-2020-15229

To remediate this vulnerability, upgrade all affected Github.com/sylabs/singularity 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/sylabs/singularity fixed: 3.6.4
Upgrade github.com/sylabs/singularity to 3.6.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/sylabs/singularity

How to Check if You Are Affected

To determine whether your application is affected by CVE-2020-15229, inspect your project dependencies for Github.com/sylabs/singularity:

inspect dependencies for github.com/sylabs/singularity

Analyze the terminal output to locate any version of Github.com/sylabs/singularity in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.6.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/sylabs/singularity, 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 Due to insecure handling of path traversal and the lack of path sanitization within `unsquashfs` (a distribution provided utility used by Singularity), it is possible to overwrite/create any files on the host filesystem during the extraction of a crafted squashfs filesystem. Squashfs extraction occurs automatically for unprivileged execution of Singularity (either `--without-suid` installation or with `allow setuid = no`) when a user attempts to run an image which: - is a local SIF image or a single file containing a squashfs filesystem - is pulled from remote sources `library://` or `shub://` Image build is also impacted in a more serious way as it is often performed by the root user, allowing an attacker to overwrite/create files leading to a system compromise. Bootstrap methods `library`, `shub` and `localimage` trigger a squashfs extraction. ### Patches This issue is addressed in Singularity 3.6.4. All users are advised to upgrade to 3.6.4 especially if they use Singularity mainly for building image as root user. ### Workarounds There is no solid workaround except to temporarily avoid use of unprivileged mode with single file images, in favor of sandbox images instead. Regarding image build, temporarily avoid building from `library` and `shub` sources, and as much as possible use `--fakeroot` or a VM to limit potential impact. ### For more information General questions about the impact of the advisory / changes made in the 3.6.0 release can be asked in the: * [Singularity Slack Channel](https://bit.ly/2m0g3lX) * [Singularity Mailing List](https://groups.google.com/a/lbl.gov/forum/??sdf%7Csort:date#!forum/singularity) Any sensitive security concerns should be directed to: security@sylabs.io See our Security Policy here: https://sylabs.io/security-policy

CVE-2020-15229 Affected Github.com/sylabs/singularity Versions

1 component(s)
Fixed Versions:
3.6.4
Product / Package Ecosystem Affected Versions Fixed Version
github.com/sylabs/singularity
Go
≥ 3.1.1
< 3.6.4
3.6.4

References

Frequently Asked Questions

What is CVE-2020-15229?
CVE-2020-15229 is a security vulnerability in Github.com/sylabs/singularity involving Path traversal and files overwrite with unsquashfs in singularity under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Github.com/sylabs/singularity versions are affected?
Affected versions include releases prior to 3.6.4 across affected packages: github.com/sylabs/singularity.
What version fixes CVE-2020-15229?
Upgrading to 3.6.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/sylabs/singularity affected?
Yes, github.com/sylabs/singularity is affected in releases prior to 3.6.4. Upgrade your dependency to 3.6.4 or later.
What is the CVSS score of CVE-2020-15229?
CVE-2020-15229 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N.
What CWE is associated with CVE-2020-15229?
CVE-2020-15229 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-2020-15229?
Run the dependency tree command: 'inspect dependencies for github.com/sylabs/singularity'. 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-7gcp-w6ww-2xv9",
  "modified" : "2021-05-21T22:17:06Z",
  "published" : "2021-05-24T16:59:53Z",
  "aliases" : [ "CVE-2020-15229" ],
  "summary" : "Path traversal and files overwrite with unsquashfs in singularity",
  "details" : "### Impact\n\nDue to insecure handling of path traversal and the lack of path sanitization within `unsquashfs` (a distribution provided utility used by Singularity), it is possible to overwrite/create any files on the host filesystem during the extraction of a crafted squashfs filesystem.\n\nSquashfs extraction occurs automatically for unprivileged execution of Singularity (either `--without-suid` installation or with `allow setuid = no`) when a user attempts to run an image which:\n\n- is a local SIF image or a single file containing a squashfs filesystem\n- is pulled from remote sources `library://` or `shub://`\n\nImage build is also impacted in a more serious way as it is often performed by the root user, allowing an attacker to overwrite/create files leading to a system compromise.  Bootstrap methods `library`, `shub` and `localimage` trigger a squashfs extraction.\n\n### Patches\n\nThis issue is addressed in Singularity 3.6.4.\n\nAll users are advised to upgrade to 3.6.4 especially if they use Singularity mainly for building image as root user.\n\n### Workarounds\n\nThere is no solid workaround except to temporarily avoid use of unprivileged mode with single file images, in favor of sandbox images instead. Regarding image build, temporarily avoid building from `library` and `shub` sources, and as much as possible use `--fakeroot` or a VM to limit potential impact.\n\n### For more information\n\nGeneral questions about the impact of the advisory / changes made in the 3.6.0 release can be asked in the:\n\n* [Singularity Slack Channel](https://bit.ly/2m0g3lX)\n* [Singularity Mailing List](https://groups.google.com/a/lbl.gov/forum/??sdf%7Csort:date#!forum/singularity)\n\nAny sensitive security concerns should be directed to: security@sylabs.io\n\nSee our Security Policy here: https://sylabs.io/security-policy",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/sylabs/singularity"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.1.1"
      }, {
        "fixed" : "3.6.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/hpcng/singularity/security/advisories/GHSA-7gcp-w6ww-2xv9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-15229"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hpcng/singularity/pull/5611"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hpcng/singularity/commit/eba3dea260b117198fdb6faf41f2482ab2f8d53e"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hpcng/singularity/blob/v3.6.4/CHANGELOG.md#security-related-fixes"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2020-10/msg00070.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2020-10/msg00071.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2020-11/msg00009.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-21T22:17:06Z",
    "nvd_published_at" : "2020-10-14T19:15:00Z"
  }
}