-
Notifications
You must be signed in to change notification settings - Fork 256
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
Further restriction of child processes capabilities (part 3) #7731
Conversation
3eb7325
to
b5f9d43
Compare
b5f9d43
to
cff0a26
Compare
20fd7bb
to
4b7116d
Compare
To be rebased on top of #7703 |
4b7116d
to
55c669c
Compare
Note: currently Fedora selinux policy ( https://github.com/fedora-selinux/selinux-policy/blob/8dfcddb1f7227bbdf98776f795be53cf50734b04/policy/modules/contrib/sssd.fc#L19 ) denies attempt to raise permitted capability to effective set:
|
|
55c669c
to
4e2ecd2
Compare
@sumit-bose, @justin-stephenson, this is ready for review. Just keep in mind selinux should be in permissive mode to test this (until fedora-selinux/selinux-policy#2455 is fixed). |
:packaging:*Important note for downstream maintainers.* A set of capabilities required by privileged binaries was further reduced to: ``` krb5_child cap_dac_read_search,cap_setgid,cap_setuid=p ldap_child cap_dac_read_search=p selinux_child cap_setgid,cap_setuid=p sssd_pam cap_dac_read_search=p ``` Keep in mind that even with limited set of fine graned capabilities, usual precautions still should be taken while packaging binaries with file capabilities: it's very important to make sure that those are executable only by root/sssd service user. For this reason upstream spec file packages it as: ``` -rwxr-x---. 1 root sssd ``` Failing to do so (i.e. allowing non-privileged users to execute those binaries) can impose systems installing the package to a security risk.
4e2ecd2
to
b41c1f4
Compare
A rebase and updated commit message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack,
-- Before PR
(2024-12-09 10:44:04): [selinux_child[564215]] [main] (0x0400): [RID#16] selinux_child started.
(2024-12-09 10:44:04): [selinux_child[564215]] [main] (0x2000): [RID#16] Running with effective IDs: [0][0].
(2024-12-09 10:44:04): [selinux_child[564215]] [main] (0x2000): [RID#16] Running with real IDs [0][0].
(2024-12-09 10:44:04): [selinux_child[564215]] [main] (0x0400): [RID#16] context initialized
(2024-12-09 10:44:04): [selinux_child[564215]] [unpack_buffer] (0x2000): [RID#16] seuser length: 7
(2024-12-09 10:44:04): [selinux_child[564215]] [unpack_buffer] (0x2000): [RID#16] seuser: staff_u
(2024-12-09 10:44:04): [selinux_child[564215]] [unpack_buffer] (0x2000): [RID#16] mls_range length: 14
(2024-12-09 10:44:04): [selinux_child[564215]] [unpack_buffer] (0x2000): [RID#16] mls_range: s0-s0:c0.c1023
(2024-12-09 10:44:04): [selinux_child[564215]] [unpack_buffer] (0x2000): [RID#16] username length: 5
(2024-12-09 10:44:04): [selinux_child[564215]] [unpack_buffer] (0x2000): [RID#16] username: alice
(2024-12-09 10:44:04): [selinux_child[564215]] [main] (0x0400): [RID#16] performing selinux operations
(2024-12-09 10:44:04): [selinux_child[564215]] [seuser_needs_update] (0x2000): [RID#16] sss_get_seuser: ret: 0 seuser: staff_u mls: s0-s0:c0.c1023
(2024-12-09 10:44:04): [selinux_child[564215]] [sss_seuser_exists] (0x0400): [RID#16] seuser exists: yes
(2024-12-09 10:44:04): [selinux_child[564215]] [seuser_needs_update] (0x0400): [RID#16] The SELinux user does not need an update
(2024-12-09 10:44:04): [selinux_child[564215]] [pack_buffer] (0x0400): [RID#16] result [0]
(2024-12-09 10:44:04): [selinux_child[564215]] [prepare_response] (0x4000): [RID#16] r->size: 4
(2024-12-09 10:44:04): [selinux_child[564215]] [main] (0x0400): [RID#16] selinux_child completed successfully
-- After PR
(2024-12-09 10:46:13): [selinux_child[565166]] [sss_log_process_caps] (0x0100): [RID#16] Starting under ruid=0, euid=0, suid=0 : rgid=0, egid=0, sgid=0
(2024-12-09 10:46:13): [selinux_child[565166]] [sss_log_process_caps] (0x0100): [RID#16] With following capabilities:
CAP_SETGID: effective = 0 , permitted = *1*, inheritable = 0 , bounding = *1*
CAP_SETUID: effective = 0 , permitted = *1*, inheritable = 0 , bounding = *1*
(2024-12-09 10:46:13): [selinux_child[565166]] [main] (0x0400): [RID#16] context initialized
(2024-12-09 10:46:13): [selinux_child[565166]] [unpack_buffer] (0x2000): [RID#16] seuser length: 7
(2024-12-09 10:46:13): [selinux_child[565166]] [unpack_buffer] (0x2000): [RID#16] seuser: staff_u
(2024-12-09 10:46:13): [selinux_child[565166]] [unpack_buffer] (0x2000): [RID#16] mls_range length: 14
(2024-12-09 10:46:13): [selinux_child[565166]] [unpack_buffer] (0x2000): [RID#16] mls_range: s0-s0:c0.c1023
(2024-12-09 10:46:13): [selinux_child[565166]] [unpack_buffer] (0x2000): [RID#16] username length: 5
(2024-12-09 10:46:13): [selinux_child[565166]] [unpack_buffer] (0x2000): [RID#16] username: alice
(2024-12-09 10:46:13): [selinux_child[565166]] [sss_log_process_caps] (0x0100): [RID#16] Performing selinux operations under ruid=0, euid=0, suid=0 : rgid=0, egid=0, sgid=0
(2024-12-09 10:46:13): [selinux_child[565166]] [sss_log_process_caps] (0x0100): [RID#16] With following capabilities:
(nothing)
(2024-12-09 10:46:13): [selinux_child[565166]] [seuser_needs_update] (0x2000): [RID#16] sss_get_seuser: ret: 0 seuser: staff_u mls: s0-s0:c0.c1023
(2024-12-09 10:46:13): [selinux_child[565166]] [sss_seuser_exists] (0x0400): [RID#16] seuser exists: yes
(2024-12-09 10:46:13): [selinux_child[565166]] [seuser_needs_update] (0x0400): [RID#16] The SELinux user does not need an update
(2024-12-09 10:46:13): [selinux_child[565166]] [sss_log_process_caps] (0x0100): [RID#16] Sending response under ruid=0, euid=0, suid=0 : rgid=0, egid=0, sgid=0
(2024-12-09 10:46:13): [selinux_child[565166]] [sss_log_process_caps] (0x0100): [RID#16] With following capabilities:
(nothing)
(2024-12-09 10:46:13): [selinux_child[565166]] [pack_buffer] (0x0400): [RID#16] result [0]
(2024-12-09 10:46:13): [selinux_child[565166]] [prepare_response] (0x4000): [RID#16] r->size: 4
(2024-12-09 10:46:13): [selinux_child[565166]] [main] (0x0400): [RID#16] selinux_child completed successfully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
thank you for the patches, works well in my tests after taking care of the current issues with the SELinux policy.
bye,
Sumit
Pushed PR: #7731
|
SSSD is being reworked [1] to not rely on effective capabilities but to raise a permitted capability when needed, and drop it completely when not needed anymore. [1] SSSD/sssd#7731 The commit addresses the following AVC denial: type=AVC msg=audit(1733309927.245:4711): avc: denied { setcap } for pid=43967 comm="selinux_child" scontext=system_u:system_r:sssd_selinux_manager_t:s0 tcontext=system_u:system_r:sssd_selinux_manager_t:s0 tclass=process permissive=1 type=SYSCALL msg=audit(1733309927.245:4711): arch=c000003e syscall=126 success=yes exit=0 a0=55795759750c a1=557957597514 a2=557957597514 a3=80 items=0 ppid=41662 pid=43967 auid=4294967295 uid=990 gid=986 euid=990 suid=990 fsuid=990 egid=986 sgid=986 fsgid=986 tty=(none) ses=4294967295 comm="selinux_child" exe="/usr/libexec/sssd/selinux_child" subj=system_u:system_r:sssd_selinux_manager_t:s0 key=(null)ARCH=x86_64 SYSCALL=capset AUID="unset" UID="sssd" GID="sssd" EUID="sssd" SUID="sssd" FSUID="sssd" EGID="sssd" SGID="sssd" FSGID="sssd" type=CAPSET msg=audit(1733309927.245:4711): pid=43967 cap_pi=0000000000000080 cap_pp=00000000000000c0 cap_pe=0000000000000080 cap_pa=0 Resolves: fedora-selinux#2455 Resolves: rhbz#2331486
SSSD is being reworked [1] to not rely on effective capabilities but to raise a permitted capability when needed, and drop it completely when not needed anymore. [1] SSSD/sssd#7731 The commit addresses the following AVC denial: type=AVC msg=audit(1733309927.245:4711): avc: denied { setcap } for pid=43967 comm="selinux_child" scontext=system_u:system_r:sssd_selinux_manager_t:s0 tcontext=system_u:system_r:sssd_selinux_manager_t:s0 tclass=process permissive=1 type=SYSCALL msg=audit(1733309927.245:4711): arch=c000003e syscall=126 success=yes exit=0 a0=55795759750c a1=557957597514 a2=557957597514 a3=80 items=0 ppid=41662 pid=43967 auid=4294967295 uid=990 gid=986 euid=990 suid=990 fsuid=990 egid=986 sgid=986 fsgid=986 tty=(none) ses=4294967295 comm="selinux_child" exe="/usr/libexec/sssd/selinux_child" subj=system_u:system_r:sssd_selinux_manager_t:s0 key=(null)ARCH=x86_64 SYSCALL=capset AUID="unset" UID="sssd" GID="sssd" EUID="sssd" SUID="sssd" FSUID="sssd" EGID="sssd" SGID="sssd" FSGID="sssd" type=CAPSET msg=audit(1733309927.245:4711): pid=43967 cap_pi=0000000000000080 cap_pp=00000000000000c0 cap_pe=0000000000000080 cap_pa=0 Resolves: fedora-selinux#2455 Resolves: rhbz#2331486
SSSD is being reworked [1] to not rely on effective capabilities but to raise a permitted capability when needed, and drop it completely when not needed anymore. [1] SSSD/sssd#7731 The commit addresses the following AVC denial: type=AVC msg=audit(1733309927.245:4711): avc: denied { setcap } for pid=43967 comm="selinux_child" scontext=system_u:system_r:sssd_selinux_manager_t:s0 tcontext=system_u:system_r:sssd_selinux_manager_t:s0 tclass=process permissive=1 type=SYSCALL msg=audit(1733309927.245:4711): arch=c000003e syscall=126 success=yes exit=0 a0=55795759750c a1=557957597514 a2=557957597514 a3=80 items=0 ppid=41662 pid=43967 auid=4294967295 uid=990 gid=986 euid=990 suid=990 fsuid=990 egid=986 sgid=986 fsgid=986 tty=(none) ses=4294967295 comm="selinux_child" exe="/usr/libexec/sssd/selinux_child" subj=system_u:system_r:sssd_selinux_manager_t:s0 key=(null)ARCH=x86_64 SYSCALL=capset AUID="unset" UID="sssd" GID="sssd" EUID="sssd" SUID="sssd" FSUID="sssd" EGID="sssd" SGID="sssd" FSGID="sssd" type=CAPSET msg=audit(1733309927.245:4711): pid=43967 cap_pi=0000000000000080 cap_pp=00000000000000c0 cap_pe=0000000000000080 cap_pa=0 Resolves: fedora-selinux#2455 Resolves: rhbz#2331486
SSSD is being reworked [1] to not rely on effective capabilities but to raise a permitted capability when needed, and drop it completely when not needed anymore. [1] SSSD/sssd#7731 The commit addresses the following AVC denial: type=AVC msg=audit(1733309927.245:4711): avc: denied { setcap } for pid=43967 comm="selinux_child" scontext=system_u:system_r:sssd_selinux_manager_t:s0 tcontext=system_u:system_r:sssd_selinux_manager_t:s0 tclass=process permissive=1 type=SYSCALL msg=audit(1733309927.245:4711): arch=c000003e syscall=126 success=yes exit=0 a0=55795759750c a1=557957597514 a2=557957597514 a3=80 items=0 ppid=41662 pid=43967 auid=4294967295 uid=990 gid=986 euid=990 suid=990 fsuid=990 egid=986 sgid=986 fsgid=986 tty=(none) ses=4294967295 comm="selinux_child" exe="/usr/libexec/sssd/selinux_child" subj=system_u:system_r:sssd_selinux_manager_t:s0 key=(null)ARCH=x86_64 SYSCALL=capset AUID="unset" UID="sssd" GID="sssd" EUID="sssd" SUID="sssd" FSUID="sssd" EGID="sssd" SGID="sssd" FSGID="sssd" type=CAPSET msg=audit(1733309927.245:4711): pid=43967 cap_pi=0000000000000080 cap_pp=00000000000000c0 cap_pe=0000000000000080 cap_pa=0 Resolves: #2455 Resolves: rhbz#2331486
SSSD is being reworked [1] to not rely on effective capabilities but to raise a permitted capability when needed, and drop it completely when not needed anymore. [1] SSSD/sssd#7731 The commit addresses the following AVC denial: type=AVC msg=audit(1733309927.245:4711): avc: denied { setcap } for pid=43967 comm="selinux_child" scontext=system_u:system_r:sssd_selinux_manager_t:s0 tcontext=system_u:system_r:sssd_selinux_manager_t:s0 tclass=process permissive=1 type=SYSCALL msg=audit(1733309927.245:4711): arch=c000003e syscall=126 success=yes exit=0 a0=55795759750c a1=557957597514 a2=557957597514 a3=80 items=0 ppid=41662 pid=43967 auid=4294967295 uid=990 gid=986 euid=990 suid=990 fsuid=990 egid=986 sgid=986 fsgid=986 tty=(none) ses=4294967295 comm="selinux_child" exe="/usr/libexec/sssd/selinux_child" subj=system_u:system_r:sssd_selinux_manager_t:s0 key=(null)ARCH=x86_64 SYSCALL=capset AUID="unset" UID="sssd" GID="sssd" EUID="sssd" SUID="sssd" FSUID="sssd" EGID="sssd" SGID="sssd" FSGID="sssd" type=CAPSET msg=audit(1733309927.245:4711): pid=43967 cap_pi=0000000000000080 cap_pp=00000000000000c0 cap_pe=0000000000000080 cap_pa=0 Resolves: RHEL-70822
SSSD is being reworked [1] to not rely on effective capabilities but to raise a permitted capability when needed, and drop it completely when not needed anymore. [1] SSSD/sssd#7731 The commit addresses the following AVC denial: type=AVC msg=audit(1733309927.245:4711): avc: denied { setcap } for pid=43967 comm="selinux_child" scontext=system_u:system_r:sssd_selinux_manager_t:s0 tcontext=system_u:system_r:sssd_selinux_manager_t:s0 tclass=process permissive=1 type=SYSCALL msg=audit(1733309927.245:4711): arch=c000003e syscall=126 success=yes exit=0 a0=55795759750c a1=557957597514 a2=557957597514 a3=80 items=0 ppid=41662 pid=43967 auid=4294967295 uid=990 gid=986 euid=990 suid=990 fsuid=990 egid=986 sgid=986 fsgid=986 tty=(none) ses=4294967295 comm="selinux_child" exe="/usr/libexec/sssd/selinux_child" subj=system_u:system_r:sssd_selinux_manager_t:s0 key=(null)ARCH=x86_64 SYSCALL=capset AUID="unset" UID="sssd" GID="sssd" EUID="sssd" SUID="sssd" FSUID="sssd" EGID="sssd" SGID="sssd" FSGID="sssd" type=CAPSET msg=audit(1733309927.245:4711): pid=43967 cap_pi=0000000000000080 cap_pp=00000000000000c0 cap_pe=0000000000000080 cap_pa=0 Resolves: RHEL-70822
Minimizes capabilities required by 'selinux_child'.