Userspace AVC auditing on policy load
Quoted 75 lines · Chris PeBenito
Quoted 73 lines · Dominick Grift
Quoted 69 lines · Chris PeBenito
Quoted 38 lines · Stephen Smalley
Quoted 30 lines · Chris PeBenito
Quoted 22 lines · Chris PeBenito
I was looking into this dbus-broker audit message, which has the wrong audit type:
audit[422]:
USER_AVCpid=422 uid=999 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t msg='avc: received policyload notice
(seqno=2)This is due to dbus-broker setting their avc log callback to send
USER_AVCaudit
messages for everything that comes to the libselinux log callback. I think the
right thing to do there is to change it to emitUSER_SELINUX_ERRaudit messages
if the log message isSELINUX_ERROR, otherwise log the message using their
regular method (stderr I think).Quoted 5 lines
But the question became, why is the userspace AVC not simply emitting its own
USER_MAC_POLICY_LOADaudit message instead of sending a message to the log
callback?Quoted 6 lines
Ok, I missed that there is a
SELINUX_AVClog type and that's how the userspace
denial messages are sent out. How about addingSELINUX_POLICYLOADandSELINUX_ENFORCElog types so that callers can emit appropriate audit messages?Quoted 4 lines
Do we need two different new types or just one? Otherwise, I don't
have a problem with adding new ones as long as it doesn't break existing applications.Regarding the risk of breaking existing applications, I did some checking on some userspace AVC users and what they do in their log
callback:* systemd only audits
SELINUX_AVCandSELINUX_ERRORmessages and ignores others(as Petr noted)
* xorg-server auditsSELINUX_AVCcorrectly but auditsSELINUX_INFOas
USER_MAC_POLICY_LOADand everything else it ignores the type
and
audits asAUDIT_USER_SELINUX_ERR
* dbus-broker ignores type and audits everything asUSER_AVC
* dbus-service ignores type and audits everything as USER AVC
* pam:pam_rootokignores type and audits everything asUSER_AVC
* sepgsql custom AVC implementation (this was news to me)
* shadow-utils only auditsSELINUX_AVCandSELINUX_ERRORmessages and
others go to syslog
* cronie: no callback setThat's all the ones I could think of. Which ones am I missing?
Quoted 7 lines
Quoted 2 lines
Probably libreswan, AFAIK that one might also still be using
avc_has_perm()instead ofselinux_check_access().You're correct, it is still use
avc_has_perm(). There is no log callback set here.
ipsec-tools (racoon) is another. I did patches for this and LibreSwan a few years ago, they never went far:
ipsec-tools: https://marc.info/?l=ipsec-tools-devel&m=149441917501329&w=2
LibreSwan: https://lists.libreswan.org/pipermail/swan-dev/2017-May/001860.html
Quoted 84 lines · Richard Haines
Quoted 75 lines · Chris PeBenito
Quoted 73 lines · Dominick Grift
Quoted 69 lines · Chris PeBenito
Quoted 38 lines · Stephen Smalley
Quoted 30 lines · Chris PeBenito
Quoted 22 lines · Chris PeBenito
I was looking into this dbus-broker audit message, which has the wrong audit type:
audit[422]:
USER_AVCpid=422 uid=999 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t msg='avc: received policyload notice
(seqno=2)This is due to dbus-broker setting their avc log callback to send
USER_AVCaudit
messages for everything that comes to the libselinux log callback. I think the
right thing to do there is to change it to emitUSER_SELINUX_ERRaudit messages
if the log message isSELINUX_ERROR, otherwise log the message using their
regular method (stderr I think).Quoted 5 lines
But the question became, why is the userspace AVC not simply emitting its own
USER_MAC_POLICY_LOADaudit message instead of sending a message to the log
callback?Quoted 6 lines
Ok, I missed that there is a
SELINUX_AVClog type and that's how the userspace
denial messages are sent out. How about addingSELINUX_POLICYLOADandSELINUX_ENFORCElog types so that callers can emit appropriate audit messages?Quoted 4 lines
Do we need two different new types or just one? Otherwise, I don't
have a problem with adding new ones as long as it doesn't break existing applications.Regarding the risk of breaking existing applications, I did some checking on some userspace AVC users and what they do in their log
callback:* systemd only audits
SELINUX_AVCandSELINUX_ERRORmessages and ignores others(as Petr noted)
* xorg-server auditsSELINUX_AVCcorrectly but auditsSELINUX_INFOas
USER_MAC_POLICY_LOADand everything else it ignores the type
and
audits asAUDIT_USER_SELINUX_ERR
* dbus-broker ignores type and audits everything asUSER_AVC
* dbus-service ignores type and audits everything as USER AVC
* pam:pam_rootokignores type and audits everything asUSER_AVC
* sepgsql custom AVC implementation (this was news to me)
* shadow-utils only auditsSELINUX_AVCandSELINUX_ERRORmessages and
others go to syslog
* cronie: no callback setThat's all the ones I could think of. Which ones am I missing?
Quoted 7 lines
Quoted 2 lines
Probably libreswan, AFAIK that one might also still be using
avc_has_perm()instead ofselinux_check_access().You're correct, it is still use
avc_has_perm(). There is no log callback set here.
Quoted 9 lines
ipsec-tools (racoon) is another. I did patches for this and LibreSwan a few years ago, they never went far:
ipsec-tools:
https://marc.info/?l=ipsec-tools-devel&m=149441917501329&w=2
LibreSwan:
https://lists.libreswan.org/pipermail/swan-dev/2017-May/001860.html
Looking at the libreswan thread, the situation changed significantly since avc_has_perm() is just no longer supported AFAIK. So labeled-ipsec is currently just broken. Also RHEL6 is EOL so that should not be an issue.
Maybe it is possible to revive that thread?
Signature · 4 lines
gpg --locate-keys [email protected] Key fingerprint = FCD2 3660 5D6B 9D27 7FC6 E0FF DA7E 521F 10F6 4098 https://sks-keyservers.net/pks/lookup?op=get&search=0xDA7E521F10F64098 Dominick Grift
Quoted 84 lines · Richard Haines
Quoted 75 lines · Chris PeBenito
Quoted 73 lines · Dominick Grift
Quoted 69 lines · Chris PeBenito
Quoted 38 lines · Stephen Smalley
Quoted 30 lines · Chris PeBenito
Quoted 22 lines · Chris PeBenito
I was looking into this dbus-broker audit message, which has the wrong audit type:
audit[422]:
USER_AVCpid=422 uid=999 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t msg='avc: received policyload notice
(seqno=2)This is due to dbus-broker setting their avc log callback to send
USER_AVCaudit
messages for everything that comes to the libselinux log callback. I think the
right thing to do there is to change it to emitUSER_SELINUX_ERRaudit messages
if the log message isSELINUX_ERROR, otherwise log the message using their
regular method (stderr I think).Quoted 5 lines
But the question became, why is the userspace AVC not simply emitting its own
USER_MAC_POLICY_LOADaudit message instead of sending a message to the log
callback?Quoted 6 lines
Ok, I missed that there is a
SELINUX_AVClog type and that's how the userspace
denial messages are sent out. How about addingSELINUX_POLICYLOADandSELINUX_ENFORCElog types so that callers can emit appropriate audit messages?Quoted 4 lines
Do we need two different new types or just one? Otherwise, I don't
have a problem with adding new ones as long as it doesn't break existing applications.Regarding the risk of breaking existing applications, I did some checking on some userspace AVC users and what they do in their log
callback:* systemd only audits
SELINUX_AVCandSELINUX_ERRORmessages and ignores others(as Petr noted)
* xorg-server auditsSELINUX_AVCcorrectly but auditsSELINUX_INFOas
USER_MAC_POLICY_LOADand everything else it ignores the type
and
audits asAUDIT_USER_SELINUX_ERR
* dbus-broker ignores type and audits everything asUSER_AVC
* dbus-service ignores type and audits everything as USER AVC
* pam:pam_rootokignores type and audits everything asUSER_AVC
* sepgsql custom AVC implementation (this was news to me)
* shadow-utils only auditsSELINUX_AVCandSELINUX_ERRORmessages and
others go to syslog
* cronie: no callback setThat's all the ones I could think of. Which ones am I missing?
Quoted 7 lines
Quoted 2 lines
Probably libreswan, AFAIK that one might also still be using
avc_has_perm()instead ofselinux_check_access().You're correct, it is still use
avc_has_perm(). There is no log callback set here.
Quoted 9 lines
ipsec-tools (racoon) is another. I did patches for this and LibreSwan a few years ago, they never went far:
ipsec-tools:
https://marc.info/?l=ipsec-tools-devel&m=149441917501329&w=2
LibreSwan:
https://lists.libreswan.org/pipermail/swan-dev/2017-May/001860.html
I visited #swan and reminded the maintainers of the libreswan patch, they are going to address your patch.
ipsec-tools is dead and have CVE's and so not sure if there is any point to that.
Signature · 4 lines
gpg --locate-keys [email protected] Key fingerprint = FCD2 3660 5D6B 9D27 7FC6 E0FF DA7E 521F 10F6 4098 https://sks-keyservers.net/pks/lookup?op=get&search=0xDA7E521F10F64098 Dominick Grift