Vulnerabilities in pkg:golang/github.com/goreleaser/nfpm

PACKAGE
Advisory Identifier: GHSA-w7jw-q4fg-qc4c
Advisory Summary

CVE-2023-32698 is a HIGH (CVSS 7.1) nfpm has incorrect default permissions vulnerability (CWE-276: Incorrect Default Permissions) affecting Github.com/goreleaser/nfpm/v2 libraries in the Go ecosystem. The issue involves nfpm has incorrect default permissions. Remediation is available by upgrading affected packages to version 2.29.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/goreleaser/nfpm

1 Known Advisory Record(s)

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

Advisory ID CVE / NVD Severity Summary
GHSA-w7jw-q4fg-qc4c CVE-2023-32698 HIGH nfpm has incorrect default permissions

CVE-2023-32698 at a Glance

CVE Identifier CVE-2023-32698
GHSA Identifier GHSA-w7jw-q4fg-qc4c
Severity HIGH
CVSS v3.1 Base Score 7.1
CWE Classification CWE-276: Incorrect Default Permissions
Affected Product Github.com/goreleaser/nfpm/v2
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.1

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

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

How to Fix CVE-2023-32698

To remediate this vulnerability, upgrade all affected Github.com/goreleaser/nfpm/v2 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/goreleaser/nfpm/v2 fixed: 2.29.0
Upgrade github.com/goreleaser/nfpm/v2 to 2.29.0
github.com/goreleaser/nfpm fixed: Latest secure release
Upgrade github.com/goreleaser/nfpm to Latest secure release
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/goreleaser/nfpm/v2

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-32698, inspect your project dependencies for Github.com/goreleaser/nfpm/v2:

inspect dependencies for github.com/goreleaser/nfpm/v2

Analyze the terminal output to locate any version of Github.com/goreleaser/nfpm/v2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.29.0), 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-276: Incorrect Default Permissions, where during installation, installed file permissions are set to allow anyone to modify those files. In Github.com/goreleaser/nfpm/v2, 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

### Summary When building packages directly from source control, file permissions on the checked-in files are not maintained. ### Details When building packages directly from source control, file permissions on the checked-in files are not maintained. When nfpm packaged the files (without extra config for enforcing its own permissions) files could go out with bad permissions (chmod 666 or 777). ### PoC Create a default nfpm structure. Within the test folder, create 3 files named `chmod-XXX.sh`. Each script has file permissions set corresponding with their file names (`chmod-777.sh` = `chmod 777`). Below each file and permissions can be seen. ```console $ ls -lart test total 24 -rwxrwxrwx 1 user group 11 May 19 13:15 chmod-777.sh -rw-rw-rw- 1 user group 11 May 19 13:16 chmod-666.sh drwxr-xr-x 5 user group 160 May 19 13:19 . -rw-rw-r-- 1 user group 11 May 19 13:19 chmod-664.sh drwxr-xr-x 10 user group 320 May 19 13:29 .. ``` Below is the snippet nfpm configuration file of the contents of the package. The test folder and files has no extra config for enforcing permissions. ```yaml contents: - src: foo-binary dst: /usr/bin/bar - src: bar-config.conf dst: /etc/foo-binary/bar-config.conf type: config - src: test dst: /etc/test/scripts ``` The next step is to create a deb package. ```console $ nfpm package -p deb # Create dep package using deb packager... created package: foo_1.0.0_arm64.deb ``` When on a Ubuntu VM, install the foo package which was created ```console $ sudo dpkg -i foo_1.0.0_arm64.deb # Installing deb package within Ubuntu Selecting previously unselected package foo. (Reading database ... 67540 files and directories currently installed.) Preparing to unpack foo_1.0.0_arm64.deb ... Unpacking foo (1.0.0) ... Setting up foo (1.0.0) ... ``` Looking at `/etc/test/scripts` and viewing the permissions. Permissions are passed exactly the same as the source. ```console $ ls -lart /etc/test/scripts total 20 -rwxrwxrwx 1 root root 11 May 22 12:15 chmod-777.sh -rw-rw-rw- 1 root root 11 May 22 12:16 chmod-666.sh -rw-rw-r-- 1 root root 11 May 22 12:19 chmod-664.sh drwxr-xr-x 3 root root 4096 May 22 13:00 .. drwxr-xr-x 2 root root 4096 May 22 13:00 . ``` ## Solution To prevent world-writable files from making it into the packages, add the ability to override the default permissions of packaged files using a umask config option in the packaging spec file. This feature in nfpm would allow applying a global umask across any files being packaged, therefore, with the correct configuration, preventing world-writable files without needing to list permissions on each and every file in the package ### Impact Vulnerability is https://cwe.mitre.org/data/definitions/276.html https://www.first.org/cvss/calculator/3.0#CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N Anyone using nfpm for creating packages and not checking/setting file permissions before packaging could result in bad permissions for files/folders.

CVE-2023-32698 Affected Github.com/goreleaser/nfpm/v2 Versions

2 component(s)
Fixed Versions:
2.29.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/goreleaser/nfpm/v2
Go
≥ 2.0.0
< 2.29.0
2.29.0
github.com/goreleaser/nfpm
Go
≥ 0.1.0
≤ 1.10.3

References

Frequently Asked Questions

What is CVE-2023-32698?
CVE-2023-32698 is a security vulnerability in Github.com/goreleaser/nfpm/v2 involving nfpm has incorrect default permissions under CWE-276: Incorrect Default Permissions.
Which Github.com/goreleaser/nfpm/v2 versions are affected?
Affected versions include releases prior to 2.29.0 across affected packages: github.com/goreleaser/nfpm/v2, github.com/goreleaser/nfpm.
What version fixes CVE-2023-32698?
Upgrading to 2.29.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/goreleaser/nfpm/v2 affected?
Yes, github.com/goreleaser/nfpm/v2 is affected in releases prior to 2.29.0. Upgrade your dependency to 2.29.0 or later.
Is github.com/goreleaser/nfpm affected?
Yes, github.com/goreleaser/nfpm is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2023-32698?
CVE-2023-32698 has a CVSS v3.1 base score of 7.1 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2023-32698?
CVE-2023-32698 is classified under CWE-276: Incorrect Default Permissions (During installation, installed file permissions are set to allow anyone to modify those files.).
How can I check Go dependencies for CVE-2023-32698?
Run the dependency tree command: 'inspect dependencies for github.com/goreleaser/nfpm/v2'. 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-w7jw-q4fg-qc4c",
  "modified" : "2024-05-20T21:52:23Z",
  "published" : "2023-05-24T17:30:16Z",
  "aliases" : [ "CVE-2023-32698" ],
  "summary" : "nfpm has incorrect default permissions",
  "details" : "### Summary\nWhen building packages directly from source control, file permissions on the checked-in files are not maintained. \n\n### Details\nWhen building packages directly from source control, file permissions on the checked-in files are not maintained. When nfpm packaged the files (without extra config for enforcing its own permissions) files could go out with bad permissions (chmod 666 or 777).\n\n### PoC\nCreate a default nfpm structure. \n\nWithin the test folder, create 3 files named `chmod-XXX.sh`. Each script has file \npermissions set corresponding with their file names (`chmod-777.sh` = `chmod 777`). Below each \nfile and permissions can be seen.\n\n```console\n$ ls -lart test \ntotal 24\n-rwxrwxrwx   1 user  group   11 May 19 13:15 chmod-777.sh\n-rw-rw-rw-   1 user  group   11 May 19 13:16 chmod-666.sh\ndrwxr-xr-x   5 user  group  160 May 19 13:19 .\n-rw-rw-r--   1 user  group   11 May 19 13:19 chmod-664.sh\ndrwxr-xr-x  10 user  group  320 May 19 13:29 ..\n```\n\nBelow is the snippet nfpm configuration file of the contents of the package. The test folder \nand files has no extra config for enforcing permissions. \n\n```yaml\ncontents:\n- src: foo-binary\n  dst: /usr/bin/bar\n- src: bar-config.conf\n  dst: /etc/foo-binary/bar-config.conf\n  type: config\n- src: test\n  dst: /etc/test/scripts\n```\n\nThe next step is to create a deb package.\n\n```console\n$ nfpm package -p deb # Create dep package\nusing deb packager...\ncreated package: foo_1.0.0_arm64.deb\n```\n\nWhen on a Ubuntu VM, install the foo package which was created\n\n```console\n$ sudo dpkg -i foo_1.0.0_arm64.deb # Installing deb package within Ubuntu\nSelecting previously unselected package foo.\n(Reading database ... 67540 files and directories currently installed.)\nPreparing to unpack foo_1.0.0_arm64.deb ...\nUnpacking foo (1.0.0) ...\nSetting up foo (1.0.0) ...\n```\n\nLooking at `/etc/test/scripts` and viewing the permissions. Permissions are passed exactly the same as the source.\n\n```console\n$ ls -lart /etc/test/scripts\ntotal 20\n-rwxrwxrwx 1 root root   11 May 22 12:15 chmod-777.sh\n-rw-rw-rw- 1 root root   11 May 22 12:16 chmod-666.sh\n-rw-rw-r-- 1 root root   11 May 22 12:19 chmod-664.sh\ndrwxr-xr-x 3 root root 4096 May 22 13:00 ..\ndrwxr-xr-x 2 root root 4096 May 22 13:00 .\n```\n\n\n## Solution\nTo prevent world-writable files from making it into the packages, add the ability to override the default permissions of packaged files using a umask config option in the packaging spec file. This feature in nfpm would allow applying a global umask across any files being packaged, therefore, with the correct configuration, preventing world-writable files without needing to list permissions on each and every file in the package\n\n\n### Impact\n\nVulnerability is https://cwe.mitre.org/data/definitions/276.html\nhttps://www.first.org/cvss/calculator/3.0#CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N\n\nAnyone using nfpm for creating packages and not checking/setting file permissions before packaging could result in bad permissions for files/folders.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/goreleaser/nfpm/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.29.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/goreleaser/nfpm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.1.0"
      }, {
        "last_affected" : "1.10.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/goreleaser/nfpm/security/advisories/GHSA-w7jw-q4fg-qc4c"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-32698"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/goreleaser/nfpm/commit/ed9abdf63d5012cc884f2a83b4ab2b42b3680d30"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/goreleaser/nfpm"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/goreleaser/nfpm/releases/tag/v2.29.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-276" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-05-24T17:30:16Z",
    "nvd_published_at" : "2023-05-30T04:15:10Z"
  }
}