Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shadow files are user readable #4401

Closed
champtar opened this issue May 9, 2023 · 3 comments · Fixed by #4911
Closed

shadow files are user readable #4401

champtar opened this issue May 9, 2023 · 3 comments · Fixed by #4911
Labels
difficulty/medium medium complexity/difficutly issue priority/medium triaged This issue was triaged

Comments

@champtar
Copy link

champtar commented May 9, 2023

Scanning my system using oscap / cis profile,
shadow files have incorrect permissions

Host system details
Alma 8.7 based OS

Expected vs actual behavior

# ls -l /etc/*shadow*
-r--------. 1 root root 225 Dec  5 09:18 /etc/gshadow
-r--------. 1 root root 213 Oct 25  2022 /etc/gshadow-
-r--------. 1 root root 436 Apr 18 11:37 /etc/shadow
-r--------. 1 root root 397 Oct 25  2022 /etc/shadow-

Expected:
shadow files should have mode 0000

Steps to reproduce it
The shadow files in /usr/etc have mode 0400 on purpose 334f0b8
This seems to be a side effect

chmod 0000 /etc/*shadow* doesn't break my system

Maybe we can fix it using tmpfile.d config

$ cat /usr/lib/tmpfiles.d/rpm-ostree-shadow.conf
z /etc/shadow 0000 root root -
z /etc/shadow- 0000 root root -
z /etc/gshadow 0000 root root -
z /etc/gshadow- 0000 root root -

see also #1045

Would you like to work on the issue?
No

@cgwalters
Copy link
Member

Ultimately what we want I think is for the shadow files to not exist in the ostree commit at all. Instead we should generate them on first boot if they don't exist. This may require OS level work.

@cgwalters cgwalters added the triaged This issue was triaged label May 18, 2023
@cgwalters cgwalters changed the title shadow files are user readeable shadow files are user readable May 18, 2023
@champtar
Copy link
Author

Instead we should generate them on first boot if they don't exist. This may require OS level work.

We could have rpm-ostree generate them when missing when 'unpacking' a commit

@champtar
Copy link
Author

champtar commented May 26, 2023

this triggers SELinux

(typeattributeset cil_gen_require systemd_tmpfiles_t)
(typeattributeset cil_gen_require shadow_t)
(allow systemd_tmpfiles_t shadow_t (file (getattr setattr relabelfrom relabelto)))

@cgwalters cgwalters added priority/medium difficulty/medium medium complexity/difficutly issue labels May 31, 2023
travier pushed a commit to travier/rpm-ostree that referenced this issue Apr 9, 2024
Because of how our composes work, we need to manually inject
passwd-related things before installing packages. A somewhat recent
regression in that area made it so that the `/etc/shadow` and
`/etc/gshadow` files were created with default permissions (0644), which
meant they were world readable.

Fix this by explicitly setting their modes to 0. Ideally, we would rely
on the canonical permissions set in the `setup` package here, but it's
tricky to fix that without reworking how we install `setup` and handle
`passwd` treefile options.

Fixes fdb879c ("passwd: sync `etc/{,g}shadow` according to
`etc/{passwd,group}`").

Fixes coreos#4401
lukewarmtemp pushed a commit to lukewarmtemp/rpm-ostree that referenced this issue Apr 15, 2024
Because of how our composes work, we need to manually inject
passwd-related things before installing packages. A somewhat recent
regression in that area made it so that the `/etc/shadow` and
`/etc/gshadow` files were created with default permissions (0644), which
meant they were world readable.

Fix this by explicitly setting their modes to 0. Ideally, we would rely
on the canonical permissions set in the `setup` package here, but it's
tricky to fix that without reworking how we install `setup` and handle
`passwd` treefile options.

Fixes fdb879c ("passwd: sync `etc/{,g}shadow` according to
`etc/{passwd,group}`").

Fixes coreos#4401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/medium medium complexity/difficutly issue priority/medium triaged This issue was triaged
Projects
None yet
2 participants