-
Bug
-
Resolution: Done-Errata
-
Normal
-
rhel-8.9.0, rhel-9.4
-
None
-
selinux-policy-38.1.41-1.el9
-
None
-
Moderate
-
rhel-sst-security-selinux
-
ssg_security
-
20
-
None
-
QE ack
-
False
-
-
Yes
-
Red Hat Enterprise Linux
-
None
-
-
Pass
-
Automated
-
Bug Fix
-
-
Done
-
None
What were you trying to do that didn't work?
A customer wrote a service that executes nodejs /usr/bin/npm start command.
With RHEL8 and later, this fails because /usr/bin/npm is a symlink to /usr/lib/node_modules/npm/bin/npm-cli.js which is labeled with lib_t:
# ls -lZ /usr/bin/npm /usr/lib/node_modules/npm/bin/npm-cli.js lrwxrwxrwx. 1 root root system_u:object_r:bin_t:s0 38 Mar 5 07:14 /usr/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js -rwxr-xr-x. 1 root root system_u:object_r:lib_t:s0 50 Aug 9 2023 /usr/lib/node_modules/npm/bin/npm-cli.js
This hence prevents the transition from init_t to unconfined_service_t to occur, since there is no transition for lib_t context, which is the context of the target of the symlink /usr/bin/npm.
IMHO this is a bug in the policy, every location under /usr/lib/ having /bin/ directory should be labeled with bin_t by default.
Checking the policy, we can already see such locations, e.g.:
/usr/lib/ccache/bin(/.*)? all files system_u:object_r:bin_t:s0 /usr/lib/debug/bin(/.*)? regular file system_u:object_r:bin_t:s0 /usr/lib/debug/usr/bin(/.*)? regular file system_u:object_r:bin_t:s0 /usr/lib/erlang/erts.*/bin(/.*)? all files system_u:object_r:bin_t:s0 /usr/lib/libreoffice(/.*)?/bin(/.*)? all files system_u:object_r:bin_t:s0 /usr/lib/mailman/bin(/.*)? all files system_u:object_r:bin_t:s0 /usr/lib/news/bin(/.*)? all files system_u:object_r:bin_t:s0 /usr/lib/portage/bin(/.*)? all files system_u:object_r:bin_t:s0 /usr/lib/qt.*/bin(/.*)? all files system_u:object_r:bin_t:s0 /usr/lib/xen/bin(/.*)? all files system_u:object_r:bin_t:s0
There is even 2 specific locations for programs, but none for /bin/:
/usr/lib/.*/program(/.*)? all files system_u:object_r:bin_t:s0 /usr/lib/.*/scripts(/.*)? all files system_u:object_r:bin_t:s0
IMHO a new generic rule similar to the ones above should be added to the policy, and specific ones (e.g. for "portage", "qt", etc.) removed and replaced by this one below:
/usr/lib/.*/bin(/.*)? all files system_u:object_r:bin_t:s0
Please provide the package NVR for which bug is seen:
selinux-policy-3.14.3-128.el8_9.1.noarch
selinux-policy-38.1.35-2.el9_4.noarch
How reproducible:
Always
Steps to reproduce
- Install nodejs
- Create a custom service starting nodejs
[Service] ExecStart=/usr/bin/npm start
- Start the service
Expected results
Starts properly
Actual results
Fails to start
- is cloned by
-
RHEL-56350 [rhel-10] nodejs executables in /usr/lib/node_modules/npm/bin are not properly labeled
- In Progress
- links to
-
RHBA-2024:130707 selinux-policy bug fix and enhancement update