Skip to contentSkip to conversation

New interface to dontaudit access to cert_t

PATCH Superseded Sugar, David 2 participants 6 messages Feb 12, 2019 – Feb 20, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 New interface to dontaudit access to cert_t

I'm seeing a bunch of denials for various processes (some refpolicy domains, some my own application domains) attempting to access /etc/pki. They seem to be working OK even with the denial. Adding interface to dontaudit this stuff and calling the interface.

type=AVC msg=audit(1549932300.668:266): avc:  denied  { search } for pid=7077 comm="X" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:xserver_t:s0-s0:c0.c1023 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1549932306.553:430): avc:  denied  { search } for pid=7345 comm="clamd" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:clamd_t:s0:c1 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0
---
 policy/modules/services/clamav.te  |  1 +
 policy/modules/services/xserver.te |  1 +
 policy/modules/system/miscfiles.if | 20 ++++++++++++++++++++
 3 files changed, 22 insertions(+)
policy/modules/services/clamav.te +1 -0
index 622453e3..ad19cc7b 100644
@@ -147,6 +147,7 @@ auth_use_nsswitch(clamd_t)
 
 logging_send_syslog_msg(clamd_t)
 
+miscfiles_dontaudit_search_generic_certs(clamd_t)
 miscfiles_read_localization(clamd_t)
 
 tunable_policy(`clamd_use_jit',`
policy/modules/services/xserver.te +1 -0
index a2b08a89..da1c0c7d 100644
@@ -804,6 +804,7 @@ locallogin_use_fds(xserver_t)
 logging_send_syslog_msg(xserver_t)
 logging_send_audit_msgs(xserver_t)
 
+miscfiles_dontaudit_search_generic_certs(xserver_t)
 miscfiles_read_localization(xserver_t)
 miscfiles_read_fonts(xserver_t)
 
policy/modules/system/miscfiles.if +20 -0
index 93c1f9c1..cecdb406 100644
@@ -131,6 +131,26 @@ interface(`miscfiles_read_generic_certs',`
 	read_lnk_files_pattern($1, cert_t, cert_t)
 ')
 
+########################################
+## <summary>
+##	Do not audit attempts to search
+##	on a generic certs directory.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain to not audit.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`miscfiles_dontaudit_search_generic_certs',`
+	gen_require(`
+		type cert_t;
+	')
+
+	dontaudit $1 cert_t:dir search;
+')
+
 ########################################
 ## <summary>
 ##	Manage generic SSL/TLS certificates.
Signature · 1 line
2.20.1
#1 lore raw
Quoted 7 lines · David

I'm seeing a bunch of denials for various processes (some refpolicy domains, some my own application domains) attempting to access /etc/pki. They seem to be working OK even with the denial. Adding interface to dontaudit this stuff and calling the interface.

type=AVC msg=audit(1549932300.668:266): avc:  denied  { search } for pid=7077 comm="X" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:xserver_t:s0-s0:c0.c1023 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1549932306.553:430): avc:  denied  { search } for pid=7345 comm="clamd" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:clamd_t:s0:c1 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0

My guess is there is some common library between them (maybe glibc) which is triggering this. It seems like this might potentially cover up legitimate access. It's just hard to tell by just dir searches.

Quoted 63 lines
---
  policy/modules/services/clamav.te  |  1 +
  policy/modules/services/xserver.te |  1 +
  policy/modules/system/miscfiles.if | 20 ++++++++++++++++++++
  3 files changed, 22 insertions(+)
policy/modules/services/clamav.te +1 -0
index 622453e3..ad19cc7b 100644
@@ -147,6 +147,7 @@ auth_use_nsswitch(clamd_t)
 
  logging_send_syslog_msg(clamd_t)
 
+miscfiles_dontaudit_search_generic_certs(clamd_t)
  miscfiles_read_localization(clamd_t)
 
  tunable_policy(`clamd_use_jit',`
policy/modules/services/xserver.te +1 -0
index a2b08a89..da1c0c7d 100644
@@ -804,6 +804,7 @@ locallogin_use_fds(xserver_t)
  logging_send_syslog_msg(xserver_t)
  logging_send_audit_msgs(xserver_t)
 
+miscfiles_dontaudit_search_generic_certs(xserver_t)
  miscfiles_read_localization(xserver_t)
  miscfiles_read_fonts(xserver_t)
 
policy/modules/system/miscfiles.if +20 -0
index 93c1f9c1..cecdb406 100644
@@ -131,6 +131,26 @@ interface(`miscfiles_read_generic_certs',`
  	read_lnk_files_pattern($1, cert_t, cert_t)
  ')
 
+########################################
+## <summary>
+##	Do not audit attempts to search
+##	on a generic certs directory.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain to not audit.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`miscfiles_dontaudit_search_generic_certs',`
+	gen_require(`
+		type cert_t;
+	')
+
+	dontaudit $1 cert_t:dir search;
+')
+
  ########################################
  ## <summary>
  ##	Manage generic SSL/TLS certificates.
Signature · 1 line
Chris PeBenito
#2 lore raw
Quoted 15 lines · Chris PeBenito
Quoted 5 lines · David

I'm seeing a bunch of denials for various processes (some refpolicy domains, some my own application domains) attempting to access /etc/pki.  They seem to be working OK even with the denial.  Adding interface to dontaudit this stuff and calling the interface.

Quoted 8 lines

type=AVC msg=audit(1549932300.668:266): avc:  denied  { search } for pid=7077 comm="X" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:xserver_t:s0-s0:c0.c1023 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0 type=AVC msg=audit(1549932306.553:430): avc:  denied  { search } for pid=7345 comm="clamd" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:clamd_t:s0:c1 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0

Quoted 4 lines

My guess is there is some common library between them (maybe glibc) which is triggering this.  It seems like this might potentially cover up legitimate access.  It's just hard to tell by just dir searches.

Digging into this I have found a few things, and please note that I am not seeing this denial in permissive.

Looking at strace for clamd I see an attempt to open the (non-existent) file /etc/pki/tls/legacy-settings. I think this would explain the denial on dir search.

If I create that file (even empty) labeled cert_t I see denials (in permissive) for clamd_t cert_t:file { getattr open read }.

audit2allow suggests the boolean 'authlogin_nsswitch_use_ldap' should resolve the issue (for clamd_t). This makes sense as clamd uses the interface auth_use_nsswitch(clamd_t).

So, assuming that I don't want to enable 'authlogin_nsswitch_use_ldap' is there a way to quiet this denial?

Maybe this has to do with dropping from root to the clamscan user.

Would it be acceptable to apply the patch to miscfiles.if for use in my application domains but not accept the patches for clamav and xserver?

Quoted 63 lines
Quoted 61 lines

---
  policy/modules/services/clamav.te  |  1 + policy/modules/services/xserver.te |  1 + policy/modules/system/miscfiles.if | 20 ++++++++++++++++++++

  3 files changed, 22 insertions(+)
policy/modules/services/clamav.te +1 -0
index 622453e3..ad19cc7b 100644
@@ -147,6 +147,7 @@ auth_use_nsswitch(clamd_t)
   logging_send_syslog_msg(clamd_t)
+miscfiles_dontaudit_search_generic_certs(clamd_t)
   miscfiles_read_localization(clamd_t)

  tunable_policy(clamd_use_jit',

policy/modules/services/xserver.te +1 -0
index a2b08a89..da1c0c7d 100644
@@ -804,6 +804,7 @@ locallogin_use_fds(xserver_t)
   logging_send_syslog_msg(xserver_t)
   logging_send_audit_msgs(xserver_t)
+miscfiles_dontaudit_search_generic_certs(xserver_t)
   miscfiles_read_localization(xserver_t)
   miscfiles_read_fonts(xserver_t)
policy/modules/system/miscfiles.if +20 -0
index 93c1f9c1..cecdb406 100644
@@ -131,6 +131,26 @@ interface(`miscfiles_read_generic_certs',`
       read_lnk_files_pattern($1, cert_t, cert_t)
   ')
+########################################
+## <summary>
+##    Do not audit attempts to search
+##    on a generic certs directory.
+## </summary>
+## <param name="domain">
+##    <summary>
+##    Domain to not audit.
+##    </summary>
+## </param>
+## <rolecap/>
+#
+interface(`miscfiles_dontaudit_search_generic_certs',`
+    gen_require(`
+        type cert_t;
+    ')
+
+    dontaudit $1 cert_t:dir search;
+')
+
   ########################################
   ## <summary>
   ##    Manage generic SSL/TLS certificates.
 
#3 lore raw
Quoted 33 lines · David
Quoted 15 lines · Chris PeBenito
Quoted 5 lines · David

I'm seeing a bunch of denials for various processes (some refpolicy domains, some my own application domains) attempting to access /etc/pki.  They seem to be working OK even with the denial.  Adding interface to dontaudit this stuff and calling the interface.

Quoted 8 lines

type=AVC msg=audit(1549932300.668:266): avc:  denied  { search } for pid=7077 comm="X" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:xserver_t:s0-s0:c0.c1023 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0 type=AVC msg=audit(1549932306.553:430): avc:  denied  { search } for pid=7345 comm="clamd" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:clamd_t:s0:c1 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0

Quoted 4 lines

My guess is there is some common library between them (maybe glibc) which is triggering this.  It seems like this might potentially cover up legitimate access.  It's just hard to tell by just dir searches.

Digging into this I have found a few things, and please note that I am not seeing this denial in permissive.

Looking at strace for clamd I see an attempt to open the (non-existent) file /etc/pki/tls/legacy-settings. I think this would explain the denial on dir search.

If I create that file (even empty) labeled cert_t I see denials (in permissive) for clamd_t cert_t:file { getattr open read }.

Quoted 6 lines

audit2allow suggests the boolean 'authlogin_nsswitch_use_ldap' should resolve the issue (for clamd_t). This makes sense as clamd uses the interface auth_use_nsswitch(clamd_t).

So, assuming that I don't want to enable 'authlogin_nsswitch_use_ldap' is there a way to quiet this denial?

The dontaudit could go in the else block for that tunable.

Signature · 1 line
Chris PeBenito
#4 lore raw
Quoted 34 lines · Chris PeBenito
Quoted 33 lines · David
Quoted 15 lines · Chris PeBenito
Quoted 5 lines · David

I'm seeing a bunch of denials for various processes (some refpolicy domains, some my own application domains) attempting to access /etc/pki.  They seem to be working OK even with the denial.  Adding interface to dontaudit this stuff and calling the interface.

Quoted 8 lines

type=AVC msg=audit(1549932300.668:266): avc:  denied  { search } for pid=7077 comm="X" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:xserver_t:s0-s0:c0.c1023 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0 type=AVC msg=audit(1549932306.553:430): avc:  denied  { search } for pid=7345 comm="clamd" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:clamd_t:s0:c1 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0

Quoted 4 lines

My guess is there is some common library between them (maybe glibc) which is triggering this.  It seems like this might potentially cover up legitimate access.  It's just hard to tell by just dir searches.

Digging into this I have found a few things, and please note that I am not seeing this denial in permissive.

Looking at strace for clamd I see an attempt to open the (non-existent) file /etc/pki/tls/legacy-settings.  I think this would explain the denial on dir search.

If I create that file (even empty) labeled cert_t I see denials (in permissive) for clamd_t cert_t:file { getattr open read }.

Quoted 9 lines
Quoted 6 lines

audit2allow suggests the boolean 'authlogin_nsswitch_use_ldap' should resolve the issue (for clamd_t).  This makes sense as clamd uses the interface auth_use_nsswitch(clamd_t).

So, assuming that I don't want to enable 'authlogin_nsswitch_use_ldap' is there a way to quiet this denial?

The dontaudit could go in the else block for that tunable.

That works for me. In this case though, should I leave the interface as proposed before or would it be more preferable to don't audit access to cert_t files along with directories?

So change the interface to miscfiles_dontaudit_read_generic_certs and include dontaudit rules for list_dir_perms, read_file_perms, read_lnk_file_perms.

#5 lore raw
Quoted 57 lines · David
Quoted 55 lines · Chris PeBenito
Quoted 53 lines · David
Quoted 20 lines · Chris PeBenito
Quoted 8 lines · David

I'm seeing a bunch of denials for various processes (some refpolicy
domains, some my own application domains) attempting to access
/etc/pki. They seem to be working OK even with the denial. Adding
interface to dontaudit this stuff and calling the interface.

Quoted 10 lines

type=AVC msg=audit(1549932300.668:266): avc: denied { search } for
pid=7077 comm="X" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:xserver_t:s0-s0:c0.c1023 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0 type=AVC msg=audit(1549932306.553:430): avc: denied { search } for
pid=7345 comm="clamd" name="pki" dev="dm-1" ino=138 scontext=system_u:system_r:clamd_t:s0:c1 tcontext=system_u:object_r:cert_t:s0 tclass=dir permissive=0

Quoted 7 lines

My guess is there is some common library between them (maybe glibc)
which is triggering this. It seems like this might potentially cover up
legitimate access. It's just hard to tell by just dir searches.

Digging into this I have found a few things, and please note that I am
not seeing this denial in permissive.

Looking at strace for clamd I see an attempt to open the (non- existent)
file /etc/pki/tls/legacy-settings. I think this would explain the
denial on dir search.

If I create that file (even empty) labeled cert_t I see denials (in
permissive) for clamd_t cert_t:file { getattr open read }.

audit2allow suggests the boolean 'authlogin_nsswitch_use_ldap' should
resolve the issue (for clamd_t). This makes sense as clamd uses the
interface auth_use_nsswitch(clamd_t).

So, assuming that I don't want to enable
'authlogin_nsswitch_use_ldap'
is there a way to quiet this denial?

Quoted 7 lines
Quoted 2 lines

The dontaudit could go in the else block for that tunable.

That works for me. In this case though, should I leave the interface as
proposed before or would it be more preferable to don't audit access to
cert_t files along with directories?

The latter is preferable.

Signature · 1 line
Chris PeBenito