Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS13N2p3LXE0ZmctcWM0Y84AAzdN

nfpm has incorrect default permissions

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.

$ 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.

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.

$ 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

$ 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.

$ 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.

Permalink: https://github.com/advisories/GHSA-w7jw-q4fg-qc4c
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS13N2p3LXE0ZmctcWM0Y84AAzdN
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 12 months ago
Updated: 6 months ago


CVSS Score: 7.1
CVSS vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N

Identifiers: GHSA-w7jw-q4fg-qc4c, CVE-2023-32698
References: Repository: https://github.com/goreleaser/nfpm
Blast Radius: 24.8

Affected Packages

go:github.com/goreleaser/nfpm
Dependent packages: 166
Dependent repositories: 3,149
Downloads:
Affected Version Ranges: >= 0.1.0, < 2.29.0
Fixed in: 2.29.0
All affected versions: 0.1.0, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.5.7, 0.5.8, 0.5.9, 0.5.10, 0.5.11, 0.5.12, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.7.0, 0.7.1, 0.7.2, 0.8.0, 0.8.1, 0.8.2, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.9.6, 0.9.7, 0.10.0, 0.11.0, 0.12.0, 0.13.0, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.1.7, 1.1.8, 1.1.9, 1.1.10, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1, 1.5.0, 1.6.0, 1.7.0, 1.8.0, 1.9.0, 1.10.0, 1.10.1, 1.10.2, 1.10.3
All unaffected versions:
go:github.com/goreleaser/nfpm/v2
Dependent packages: 146
Dependent repositories: 408
Downloads:
Affected Version Ranges: >= 2.0.0, < 2.29.0
Fixed in: 2.29.0
All affected versions: 2.0.0, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4, 2.2.5, 2.3.0, 2.3.1, 2.4.0, 2.5.0, 2.5.1, 2.6.0, 2.7.0, 2.7.1, 2.8.0, 2.9.0, 2.9.1, 2.9.2, 2.10.0, 2.11.0, 2.11.1, 2.11.2, 2.11.3, 2.12.0, 2.12.1, 2.12.2, 2.13.0, 2.14.0, 2.15.0, 2.15.1, 2.16.0, 2.17.0, 2.18.0, 2.18.1, 2.19.0, 2.19.1, 2.19.2, 2.20.0, 2.21.0, 2.22.0, 2.22.1, 2.22.2, 2.23.0, 2.24.0, 2.25.0, 2.25.1, 2.26.0, 2.27.0, 2.27.1, 2.28.0
All unaffected versions: 2.29.0, 2.30.0, 2.30.1, 2.31.0, 2.32.0, 2.33.0, 2.33.1, 2.34.0, 2.35.0, 2.35.1, 2.35.2