-
Notifications
You must be signed in to change notification settings - Fork 3
pam_tcb: Add support for user authentication with SELinux. #10
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
base: main
Are you sure you want to change the base?
Conversation
I wonder wouldn't we better off if the code was written as if selinux is always enabled? |
Well, we would lose the sanity checks on systems without SELinux. Otherwise I don't see any. |
This sounds dangerous:
Also, how would |
These sanity checks make sense even if selinux is enabled, they just have to be adjusted so that |
You mean sth like this, I guess:
|
I mean something like this (completely untested):
|
That solution works, tested on Fedora 36 (Rawhide) with a little tweak to the SELinux policy ( But Before I start to implement that, I'd like to hear your oppinions towards it, @ldv-alt and @solardiz, as we have two options here:
After that is done, I will proceed with implementing the change pw step adjustments. |
@besser82 Out of the two options you list, I prefer adding a command-line option to That said, I am not yet sure the rest of this proposal is entirely right. I'll need to take a closer look. Also, how does |
From looking at the refpolicy and the fedora targeted policy
I will push the reworked changes as outlined by @ldv, when I'm done with the check acct changes, will make more sense to review afterwards.
They use two helper binaries: |
c8858c8
to
0f39f93
Compare
0f39f93
to
1d98de0
Compare
I'm sorry, I won't be able to review anything till November. |
@ldv-alt Do you have some time to spend on this, yet? Don't feel to be pushed, I'm just asking to be able to do some planning. |
On Wed, Nov 17, 2021 at 11:48:42AM -0800, Björn Esser wrote:
@ldv-alt Do you have some time to spend on this, yet? Don't feel to be pushed, I'm just asking to be able to do some planning.
I'll look at this as soon as I get strace 5.15 released, hopefully this weekend.
|
7bc0bd2
to
2ea4c9c
Compare
Thank you, @besser82! I'm sorry we still haven't reviewed this for real. Regarding communicating more status info from the helper program (assuming that we have to, which I'm not sure of), maybe we should continue with more magic values, not a mere enum, because of the recent extension of Rowhammer to target spilled registers, IIRC as demonstrated and patched for sudo. In fact, I worry that Linux-PAM pam_unix and its helper is probably susceptible. So especially when implementing something like this anew, we need to do so with awareness. |
This is not a request for you to amend any commits yet. I think we should first review the actual functionality in its simpler form, since you already implemented it, and then decide on possible hardening. Also, it may be reasonable to keep simpler implementation in commits history, to separate actual logic from defensive programming. |
By the way, pam_unix ended up invoking the helper unconditionally, see linux-pam/linux-pam#686. |
Right. I was very surprised to notice such behavior on Rocky Linux 9 some months ago (an RH patch? I don't recall right now) and I vaguely recall finding (in upstream Linux-PAM commits and issues) the sort of discussion I now see on that PR you reference above. This feels like high risk to me. I think both projects should either reduce usage of the helper or at least harden its interface. |
Hmm, what's the risk in using the helper? Isn't running this code in a separate process an advantage? |
My primary concern is that process exit codes were not meant to communicate authentication/authorization results. They may not be reliable enough for that. Neither historically (e.g., a library may just happen to exit with the same code as a program was using for something else) nor especially today (when Rowhammer can flip bits in spilled registers even within a process, and perhaps even easier for an integer that passes through so many places). So we should use hardened/redundant magic values.
Yes, it can be an advantage - in terms of getting fresh ASLR each time and in terms of not leaving temporary data in the parent process address space. |
2ea4c9c
to
fa4b72d
Compare
This is needed if e.g. SELinux prevents access to file storing the hashed user password. Signed-off-by: Björn Esser <[email protected]>
Refactor the function to be non-static and to allow for more versatile use. Signed-off-by: Björn Esser <[email protected]>
The tcb_chkpwd helper binary is now able to also perform verifications for the expiration of user accounts. Signed-off-by: Björn Esser <[email protected]>
…unt. Perform verification through an external helper binary to possibly gain higher privileges if the verification fails for insufficient credentials in the first time. Signed-off-by: Björn Esser <[email protected]>
fa4b72d
to
cefb11f
Compare
It may take some time until I can get back to this PR, as there have been a lot of changes in the SELinux policy, which require me to write a seperate module for tcb, defining special types for the |
NSA Security-Enhanced Linux (SELinux) is an implementation of a flexible mandatory access control architecture in the Linux operating system. Background information and technical documentation about SELinux can be found at https://github.com/SELinuxProject.
With SELinux running in enforced mode even read-access to the shadow files, which the hashed user passwords are stored
in, is restricted to processes that have at least been granted
shadow_t:file read
capabilites by the SELinux policy. For thatreason the login authentication of a user must always be performed by the
tcb_chkpwd
helper binary.SELINUX_ENABLED
.The needed changes have already been applied to the SELinux reference-policy in SELinuxProject/refpolicy@bc88a1c.