Skip to contentSkip to conversation

Collecting ideas for audit2allow improvement

DISCUSSION Jan Zarsky 6 participants 12 messages Jun 14, 2017 – Jun 28, 2017 1 message not in the archive SELinux security module

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jan Zarsky

author
#1 lore raw

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis. I collected ideas from my colleagues from RedHat SELinux team and I would also like to hear your ideas - what would you improve to make audit2allow smarter or easier to use.

Ideas collected so far:

* offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)
* offer multiple solutions to a problem (example: 1) add allow rule for execute + execute_no_trans or 2) add allow rule for execute
+ type_transition rule)
* interactive mode: ask questions and choose best solution
* warn when solution touches trusted computing base (rules you should not be adding)
* suggest alternate labels for content, example: httpd_t not allowed to write to user_home_t, might suggest that changing the label to httpd_user_content_t
* output to CIL (add option for this)
* if the AVC talks about execute permission then offer also type_transition rule
* idea for a tool for automatic policy generation: On a test system you install application, turn the SELinux to permissive and run a full test suit. You collect all the AVCs in say Elasticsearch (can use common logging ViaQ project for that) and then there is a tool that searches the AVC, groups them and creates a policy out of them.
* add option to open bugzilla
* output to Ansible playbook/role task (add option for this)

I would also like to know which feature would you appreciate the most.

Thanks

Jan Zarsky

#2 lore raw
Quoted 9 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis. I collected ideas from my colleagues from RedHat SELinux team and I would also like to hear your ideas - what would you improve to make audit2allow smarter or easier to use.

Ideas collected so far:

Quoted 12 lines

* offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)
* offer multiple solutions to a problem (example: 1) add allow rule for execute + execute_no_trans or 2) add allow rule for execute
+ type_transition rule)
* interactive mode: ask questions and choose best solution
* warn when solution touches trusted computing base (rules you should not be adding)
* suggest alternate labels for content, example: httpd_t not allowed to write to user_home_t, might suggest that changing the label to httpd_user_content_t
* output to CIL (add option for this)

This would definitely be helpful and should be relatively straightforward.

Jim

Quoted 16 lines

* if the AVC talks about execute permission then offer also type_transition rule
* idea for a tool for automatic policy generation: On a test system you install application, turn the SELinux to permissive and run a full test suit. You collect all the AVCs in say Elasticsearch (can use common logging ViaQ project for that) and then there is a tool that searches the AVC, groups them and creates a policy out of them.
* add option to open bugzilla
* output to Ansible playbook/role task (add option for this)

I would also like to know which feature would you appreciate the most.

Thanks

Jan Zarsky

Signature · 2 lines
James Carter <[email protected]>
National Security Agency
#3 lore raw
Quoted 23 lines · On Wed, Jun 14, 2017 at 09:58:43AM -0400, jwcart2 wrote:
Quoted 9 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis. I collected ideas from my colleagues from RedHat SELinux team and I would also like to hear your ideas - what would you improve to make audit2allow smarter or easier to use.

Ideas collected so far:

Quoted 12 lines

* offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)
* offer multiple solutions to a problem (example: 1) add allow rule for execute + execute_no_trans or 2) add allow rule for execute
+ type_transition rule)
* interactive mode: ask questions and choose best solution
* warn when solution touches trusted computing base (rules you should not be adding)
* suggest alternate labels for content, example: httpd_t not allowed to write to user_home_t, might suggest that changing the label to httpd_user_content_t
* output to CIL (add option for this)

Quoted 3 lines

This would definitely be helpful and should be relatively straightforward.

Jim

I will second that. I actually think this is the only compelling improvement in the whole list.

Except this (which isnt in the list):

https://twitter.com/evilSnobu/status/871787143781285889

Granted, its about sealert but it applies to audit2allow as well. Do not overwhelm users: they will get intimidated. The idea is that things should improve security not to just dump a long list of (mostly terrible) options on unsuspecting users

Focus on making audit2allow more enjoyable to use. Waste no time on impossible missions, remove all the functionality that tries to do the impossible and does it terribly.

Stick with the basics, its a helper tool, its not some magic tool that can make security decisions on your behalf, and it never will be

Quoted 22 lines
Quoted 17 lines

* if the AVC talks about execute permission then offer also type_transition rule
* idea for a tool for automatic policy generation: On a test system you install application, turn the SELinux to permissive and run a full test suit. You collect all the AVCs in say Elasticsearch (can use common logging ViaQ project for that) and then there is a tool that searches the AVC, groups them and creates a policy out of them.
* add option to open bugzilla
* output to Ansible playbook/role task (add option for this)

I would also like to know which feature would you appreciate the most.

Thanks

Jan Zarsky

Signature · 2 lines
James Carter <[email protected]>
National Security Agency
Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
#4 lore raw
In reply to Jan Zarsky
Quoted 10 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis.
I collected ideas from my colleagues from RedHat SELinux team and I would also
like to hear your ideas - what would you improve to make audit2allow smarter or
easier to use.

Quoted 4 lines

Ideas collected so far:

  * offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)

The hard part here is knowing when it is sufficient. Might require further kernel patches to get to the point where it is completely unambiguous from the audit messages alone. You could perhaps default to only allowing dac_read_search and only allow dac_override if you see that dac_read_search is already allowed and you are still getting a dac_override denial.

Quoted 4 lines

  * offer multiple solutions to a problem (example: 1) add allow rule for
    execute + execute_no_trans or 2) add allow rule for execute
    + type_transition rule)

Is this type_transition to an existing type that already exists, or defining a new type and transitioning to it, or both? Generating new domains and types dynamically is one of the major gaps in current audit2allow, and to date has only been supported in separate tools like sepolicy generate.

Quoted 8 lines

  * interactive mode: ask questions and choose best solution
  * warn when solution touches trusted computing base (rules you should not be
    adding)
  * suggest alternate labels for content, example: httpd_t not allowed to write
    to user_home_t, might suggest that changing the label to httpd_user_content_t

This seems more along the lines of what setroubleshoot does, and tends to be policy-specific. We need to preserve the usability of audit2allow for other policies (e.g. Android, DSSP), so any policy-specific logic needs to be encapsulated, configuration-driven, and optional.

Quoted 1 line

  * output to CIL (add option for this)

This would definitely be useful, as generating .te files just adds overhead at this point and makes audit2allow depend on having checkmodule and semodule_package installed. In fact, I think we should move to generating CIL by default and just provide an option for generating .te files for backward compat.

Quoted 4 lines

  * if the AVC talks about execute permission then offer also type_transition
    rule
  * idea for a tool for automatic policy generation: On a test system

Quoted 8 lines

you
    install application, turn the SELinux to permissive and run a full test
    suit. You collect all the AVCs in say Elasticsearch (can use common logging
    ViaQ project for that) and then there is a tool that searches the AVC,
    groups them and creates a policy out of them.

This seems similar to sepolicy generate. We don't want to bring in many extra dependencies to audit2allow, but being able to dynamically generate new domains and types would IMHO be useful.

Quoted 1 line

  * add option to open bugzilla

Need to be careful here since not all SELinux users are Red Hat users.

Quoted 1 line

  * output to Ansible playbook/role task (add option for this)

Another improvement:

* Add ability to generate ioctl whitelisting rules, see for example:
http://jeffvanderstoep.blogspot.com/2016/02/collecting-ioctl-command-denials-for.html
but note that the syntax has changed to e.g.
allowxperm <sourcedomain> <targetdomain>:<class> ioctl { <list of ioctl command values> };

Quoted 2 lines

I would also like to know which feature would you appreciate the most.

You should likely study the tooling and workflow used by other security projects, e.g. AppArmor, TOMOYO, grsecurity, for policy learning and generation.

#5 lore raw
Quoted 16 lines · Stephen Smalley
Quoted 10 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis.
I collected ideas from my colleagues from RedHat SELinux team and I would also
like to hear your ideas - what would you improve to make audit2allow smarter or
easier to use.

Quoted 4 lines

Ideas collected so far:

  * offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)

Quoted 6 lines

The hard part here is knowing when it is sufficient. Might require further kernel patches to get to the point where it is completely unambiguous from the audit messages alone. You could perhaps default to only allowing dac_read_search and only allow dac_override if you see that dac_read_search is already allowed and you are still getting a dac_override denial.

This should not be an issue anymore. Becuase now (linux v4.12) dac_read_search is first checked
so translating a rule for dac_read_search will always be the most secure option. It might not be enough but youll notice if it isnt. Just rerun it again and you'll end up with dac_override if needed.

Quoted 11 lines
Quoted 5 lines

  * offer multiple solutions to a problem (example: 1) add allow rule for
    execute + execute_no_trans or 2) add allow rule for execute
    + type_transition rule)

Is this type_transition to an existing type that already exists, or defining a new type and transitioning to it, or both? Generating new domains and types dynamically is one of the major gaps in current audit2allow, and to date has only been supported in separate tools like sepolicy generate.

One should be extremely careful here. "execute" does not automatically imply "execute_no_trans". That assumption can lead to disaster (https://www.cvedetails.com/cve/CVE-2015-1815/)

Quoted 10 lines
Quoted 9 lines

  * interactive mode: ask questions and choose best solution
  * warn when solution touches trusted computing base (rules you should not be
    adding)
  * suggest alternate labels for content, example: httpd_t not allowed to write
    to user_home_t, might suggest that changing the label to httpd_user_content_t

Quoted 4 lines

This seems more along the lines of what setroubleshoot does, and tends to be policy-specific. We need to preserve the usability of audit2allow for other policies (e.g. Android, DSSP), so any policy-specific logic needs to be encapsulated, configuration-driven, and optional.

setroubleshoot is not smart enough to suggest httpd_user_content_t, instead it suggest you allow full access to /home/* by toggling the boolean that grants access to user home content.

I know this from experience. There was a bug in fedora's apache_user_content_template for more than a year and hardly anyone noticed it, probably because setroubleshoot would have just suggested you allow full access to user home content.

Quoted 47 lines
Quoted 2 lines

  * output to CIL (add option for this)

This would definitely be useful, as generating .te files just adds overhead at this point and makes audit2allow depend on having checkmodule and semodule_package installed. In fact, I think we should move to generating CIL by default and just provide an option for generating .te files for backward compat.

Quoted 4 lines

  * if the AVC talks about execute permission then offer also type_transition
    rule
  * idea for a tool for automatic policy generation: On a test system

Quoted 8 lines

you
    install application, turn the SELinux to permissive and run a full test
    suit. You collect all the AVCs in say Elasticsearch (can use common logging
    ViaQ project for that) and then there is a tool that searches the AVC,
    groups them and creates a policy out of them.

This seems similar to sepolicy generate. We don't want to bring in many extra dependencies to audit2allow, but being able to dynamically generate new domains and types would IMHO be useful.

Quoted 1 line

  * add option to open bugzilla

Need to be careful here since not all SELinux users are Red Hat users.

Quoted 1 line

  * output to Ansible playbook/role task (add option for this)

Another improvement:

* Add ability to generate ioctl whitelisting rules, see for example:
http://jeffvanderstoep.blogspot.com/2016/02/collecting-ioctl-command-denials-for.html
but note that the syntax has changed to e.g.
allowxperm <sourcedomain> <targetdomain>:<class> ioctl { <list of ioctl command values> };

Quoted 2 lines

I would also like to know which feature would you appreciate the most.

You should likely study the tooling and workflow used by other security projects, e.g. AppArmor, TOMOYO, grsecurity, for policy learning and generation.

Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
#6 lore raw
Quoted 50 lines · Dominick Grift
Quoted 16 lines · Stephen Smalley
Quoted 10 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis.
I collected ideas from my colleagues from RedHat SELinux team and I would also
like to hear your ideas - what would you improve to make audit2allow smarter or
easier to use.

Quoted 4 lines

Ideas collected so far:

  * offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)

Quoted 6 lines

The hard part here is knowing when it is sufficient. Might require further kernel patches to get to the point where it is completely unambiguous from the audit messages alone. You could perhaps default to only allowing dac_read_search and only allow dac_override if you see that dac_read_search is already allowed and you are still getting a dac_override denial.

This should not be an issue anymore. Becuase now (linux v4.12) dac_read_search is first checked
so translating a rule for dac_read_search will always be the most secure option. It might not be enough but youll notice if it isnt. Just rerun it again and you'll end up with dac_override if needed.

Quoted 11 lines
Quoted 5 lines

  * offer multiple solutions to a problem (example: 1) add allow rule for
    execute + execute_no_trans or 2) add allow rule for execute
    + type_transition rule)

Is this type_transition to an existing type that already exists, or defining a new type and transitioning to it, or both? Generating new domains and types dynamically is one of the major gaps in current audit2allow, and to date has only been supported in separate tools like sepolicy generate.

One should be extremely careful here. "execute" does not automatically imply "execute_no_trans". That assumption can lead to disaster (https://www.cvedetails.com/cve/CVE-2015-1815/)

Quoted 10 lines
Quoted 9 lines

  * interactive mode: ask questions and choose best solution
  * warn when solution touches trusted computing base (rules you should not be
    adding)
  * suggest alternate labels for content, example: httpd_t not allowed to write
    to user_home_t, might suggest that changing the label to httpd_user_content_t

Quoted 8 lines
Quoted 4 lines

This seems more along the lines of what setroubleshoot does, and tends to be policy-specific. We need to preserve the usability of audit2allow for other policies (e.g. Android, DSSP), so any policy-specific logic needs to be encapsulated, configuration-driven, and optional.

setroubleshoot is not smart enough to suggest httpd_user_content_t, instead it suggest you allow full access to /home/* by toggling the boolean that grants access to user home content.

I know this from experience. There was a bug in fedora's apache_user_content_template for more than a year and hardly anyone noticed it, probably because setroubleshoot would have just suggested you allow full access to user home content.

https://bugzilla.redhat.com/show_bug.cgi?id=1457406

Quoted 53 lines
Quoted 48 lines
Quoted 3 lines

  * output to CIL (add option for this)

This would definitely be useful, as generating .te files just adds overhead at this point and makes audit2allow depend on having checkmodule and semodule_package installed. In fact, I think we should move to generating CIL by default and just provide an option for generating .te files for backward compat.

Quoted 4 lines

  * if the AVC talks about execute permission then offer also type_transition
    rule
  * idea for a tool for automatic policy generation: On a test system

Quoted 8 lines

you
    install application, turn the SELinux to permissive and run a full test
    suit. You collect all the AVCs in say Elasticsearch (can use common logging
    ViaQ project for that) and then there is a tool that searches the AVC,
    groups them and creates a policy out of them.

This seems similar to sepolicy generate. We don't want to bring in many extra dependencies to audit2allow, but being able to dynamically generate new domains and types would IMHO be useful.

Quoted 1 line

  * add option to open bugzilla

Need to be careful here since not all SELinux users are Red Hat users.

Quoted 1 line

  * output to Ansible playbook/role task (add option for this)

Another improvement:

* Add ability to generate ioctl whitelisting rules, see for example:
http://jeffvanderstoep.blogspot.com/2016/02/collecting-ioctl-command-denials-for.html
but note that the syntax has changed to e.g.
allowxperm <sourcedomain> <targetdomain>:<class> ioctl { <list of ioctl command values> };

Quoted 2 lines

I would also like to know which feature would you appreciate the most.

You should likely study the tooling and workflow used by other security projects, e.g. AppArmor, TOMOYO, grsecurity, for policy learning and generation.

Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
#7 lore raw
Quoted 44 lines · Dominick Grift
Quoted 43 lines · Dominick Grift
Quoted 13 lines · Stephen Smalley
Quoted 12 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis.
I collected ideas from my colleagues from RedHat SELinux team and I would also
like to hear your ideas - what would you improve to make audit2allow smarter or
easier to use.

Ideas collected so far:

Quoted 8 lines
Quoted 2 lines

* offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)

The hard part here is knowing when it is sufficient. Might require further kernel patches to get to the point where it is completely unambiguous from the audit messages alone. You could perhaps default to only allowing dac_read_search and only allow dac_override if you see that dac_read_search is already allowed and you are still getting a dac_override denial.

This should not be an issue anymore. Becuase now (linux v4.12) dac_read_search is first checked
so translating a rule for dac_read_search will always be the most secure option. It might not be enough but youll notice if it isnt. Just rerun it again and you'll end up with dac_override if needed.

Quoted 9 lines
Quoted 4 lines

* offer multiple solutions to a problem (example: 1) add allow rule
for
execute + execute_no_trans or 2) add allow rule for execute
+ type_transition rule)

Is this type_transition to an existing type that already exists, or defining a new type and transitioning to it, or both? Generating new domains and types dynamically is one of the major gaps in current audit2allow, and to date has only been supported in separate tools like sepolicy generate.

One should be extremely careful here. "execute" does not automatically imply "execute_no_trans". That assumption can lead to disaster (https://www.cvedetails.com/cve/CVE-2015-1815/)

Quoted 8 lines
Quoted 8 lines

* interactive mode: ask questions and choose best solution
* warn when solution touches trusted computing base (rules you
should not be
adding)
* suggest alternate labels for content, example: httpd_t not
allowed to write
to user_home_t, might suggest that changing the label to httpd_user_content_t

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

This seems more along the lines of what setroubleshoot does, and tends to be policy-specific. We need to preserve the usability of audit2allow for other policies (e.g. Android, DSSP), so any policy-specific logic needs to be encapsulated, configuration-driven, and optional.

setroubleshoot is not smart enough to suggest httpd_user_content_t, instead it suggest you allow full access to /home/* by toggling the boolean that grants access to user home content.

I know this from experience. There was a bug in fedora's apache_user_content_template for more than a year and hardly anyone noticed it, probably because setroubleshoot would have just suggested you allow full access to user home content.

https://bugzilla.redhat.com/show_bug.cgi?id=1457406

I actually think the suggest a accessible type is the best improvement. audit2allow has defaulted for years to suggesting adding allow rules, usually the worst solution. Later we added boolean support, which was better but as you point out the not a great solution in a lot of cases. Most AVC's are caused by mislabeled files or processes. Having audit2allow attempt to examine the policy and figure out which types would have been allowed with some simple sorting rules might be a big improvement.

Avc denying httpd_t ability to write to httpd_sys_content_t.

audit2allow should examine policy and figure out which domains httpd_t can write to with the current policy settings. Then it should sort the solutions based on the characters of the sources context. Perhaps chopping a characters off, maybe down to 3.

sesearch -A -s httpd_t -p write -c | cut -f1 -d ":" | cut -d" " -f 3
| sort -u | grep httpd
httpd_cache_t
httpdcontent
httpd_lock_t
httpd_squirrelmail_t
httpd_sys_rw_content_t
httpd_t
httpd_tmpfs_t
httpd_tmp_t
httpd_user_rw_content_t
httpd_var_lib_t
httpd_var_run_t

Now eliminate the non file types, removes httpd_t.

That would give the user a much better chance of solving the problem without becoming policy specific.

Now if you wanted to become a little more smart, you could look at the second field of the label, and have a table that says "var" indicates the path begins with /var and "tmp" indicates a directory that ends with tmp. But users could probably determine this.

Sort by types starting with httpd, http, htt

#8 lore raw
Quoted 49 lines · Daniel Walsh
Quoted 48 lines · Dominick Grift
Quoted 47 lines · Dominick Grift
Quoted 13 lines · Stephen Smalley
Quoted 12 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis.
I collected ideas from my colleagues from RedHat SELinux team and I would also
like to hear your ideas - what would you improve to make audit2allow smarter or
easier to use.

Ideas collected so far:

Quoted 8 lines
Quoted 2 lines

* offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)

The hard part here is knowing when it is sufficient. Might require further kernel patches to get to the point where it is completely unambiguous from the audit messages alone. You could perhaps default to only allowing dac_read_search and only allow dac_override if you see that dac_read_search is already allowed and you are still getting a dac_override denial.

This should not be an issue anymore. Becuase now (linux v4.12) dac_read_search is first checked
so translating a rule for dac_read_search will always be the most secure option. It might not be enough but youll notice if it isnt. Just rerun it again and you'll end up with dac_override if needed.

Quoted 9 lines
Quoted 4 lines

* offer multiple solutions to a problem (example: 1) add allow rule
for
execute + execute_no_trans or 2) add allow rule for execute
+ type_transition rule)

Is this type_transition to an existing type that already exists, or defining a new type and transitioning to it, or both? Generating new domains and types dynamically is one of the major gaps in current audit2allow, and to date has only been supported in separate tools like sepolicy generate.

One should be extremely careful here. "execute" does not automatically imply "execute_no_trans". That assumption can lead to disaster (https://www.cvedetails.com/cve/CVE-2015-1815/)

Quoted 12 lines
Quoted 8 lines

* interactive mode: ask questions and choose best solution
* warn when solution touches trusted computing base (rules you
should not be
adding)
* suggest alternate labels for content, example: httpd_t not
allowed to write
to user_home_t, might suggest that changing the label to httpd_user_content_t

This seems more along the lines of what setroubleshoot does, and tends to be policy-specific. We need to preserve the usability of audit2allow for other policies (e.g. Android, DSSP), so any policy-specific logic needs to be encapsulated, configuration-driven, and optional.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

setroubleshoot is not smart enough to suggest httpd_user_content_t, instead it suggest you allow full access to /home/* by toggling the boolean that grants access to user home content.

I know this from experience. There was a bug in fedora's apache_user_content_template for more than a year and hardly anyone noticed it, probably because setroubleshoot would have just suggested you allow full access to user home content.

https://bugzilla.redhat.com/show_bug.cgi?id=1457406

I actually think the suggest a accessible type is the best improvement. audit2allow has defaulted for years to suggesting adding allow rules, usually the worst solution. Later we added boolean support, which was better but as you point out the not a great solution in a lot of cases.

The "best" improvement. I agree, but that say's more about the overal state of things than about the quality of this particular improvement.

The guy in the tweet was overwhelmed and intimidated by the large list of "accessible" types returned by setroubleshoot (and audit2allow would probably do the same) Also things arent as simple, its not just about "what type grants the access needed to my domain". Other domains access to that type should also be considered.

Quoted 3 lines

Most AVC's are caused by mislabeled files or processes. Having audit2allow attempt to examine the policy and figure out which types would have been allowed with some simple sorting rules might be a big improvement.

audit2allow INHO shouldnt "examine" the policy (at least not in any significant way) because it cannot do it right. audit2allow should just stick with the basics + audit2why.

audit2why is the only functionality that works reasonably well. provided that some of the more recent "improvements" to audit2why get removed.

Quoted 22 lines

Avc denying httpd_t ability to write to httpd_sys_content_t.

audit2allow should examine policy and figure out which domains httpd_t can write to with the current policy settings. Then it should sort the solutions based on the characters of the sources context. Perhaps chopping a characters off, maybe down to 3.

sesearch -A -s httpd_t -p write -c | cut -f1 -d ":" | cut -d" " -f 3 |
sort -u | grep httpd
httpd_cache_t
httpdcontent
httpd_lock_t
httpd_squirrelmail_t
httpd_sys_rw_content_t
httpd_t
httpd_tmpfs_t
httpd_tmp_t
httpd_user_rw_content_t
httpd_var_lib_t
httpd_var_run_t

Quoted 4 lines

Now eliminate the non file types, removes httpd_t.

That would give the user a much better chance of solving the problem without becoming policy specific.

It cannot do this right. If you look to be bugzilla i pasted above:

All that was needed was to allow the httpd_t domain access to read dirs with the httpd_sys_content_t type. sealert couldnt figure this out
and instead it suggested that he toggle the "httpd_use_user_content" boolean instead, which would grant httpd_t broad access to user home content, and defeat the purpose of "httpd_user_content_t"

Quoted 10 lines

Now if you wanted to become a little more smart, you could look at the second field of the label, and have a table that says "var" indicates the path begins with /var and "tmp" indicates a directory that ends with tmp. But users could probably determine this.

Sort by types starting with httpd, http, htt

The audience that uses this functionality get intimidated by the large lists of types that are returned and various "solutions" returned. plus often times the solutions returned are sub-optimal, but the user doesnt know this.

Seasoned users will only use audit2allow for simple things like translation of avc to raw rules (maybe resolving of interfaces but this is prone to bad results as well). quickly determining whether its a missing TE rule, boolean, or constraint. These users will use setools to do further analysis

Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
#9 lore raw
Quoted 54 lines · Dominick Grift
Quoted 53 lines · Daniel Walsh
Quoted 52 lines · Dominick Grift
Quoted 43 lines · Dominick Grift
Quoted 13 lines · Stephen Smalley
Quoted 12 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis.
I collected ideas from my colleagues from RedHat SELinux team and I would also
like to hear your ideas - what would you improve to make audit2allow smarter or
easier to use.

Ideas collected so far:

Quoted 8 lines
Quoted 2 lines

* offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)

The hard part here is knowing when it is sufficient. Might require further kernel patches to get to the point where it is completely unambiguous from the audit messages alone. You could perhaps default to only allowing dac_read_search and only allow dac_override if you see that dac_read_search is already allowed and you are still getting a dac_override denial.

This should not be an issue anymore. Becuase now (linux v4.12) dac_read_search is first checked
so translating a rule for dac_read_search will always be the most secure option. It might not be enough but youll notice if it isnt. Just rerun it again and you'll end up with dac_override if needed.

Quoted 9 lines
Quoted 4 lines

* offer multiple solutions to a problem (example: 1) add allow rule
for
execute + execute_no_trans or 2) add allow rule for execute
+ type_transition rule)

Is this type_transition to an existing type that already exists, or defining a new type and transitioning to it, or both? Generating new domains and types dynamically is one of the major gaps in current audit2allow, and to date has only been supported in separate tools like sepolicy generate.

One should be extremely careful here. "execute" does not automatically imply "execute_no_trans". That assumption can lead to disaster (https://www.cvedetails.com/cve/CVE-2015-1815/)

Quoted 8 lines
Quoted 8 lines

* interactive mode: ask questions and choose best solution
* warn when solution touches trusted computing base (rules you
should not be
adding)
* suggest alternate labels for content, example: httpd_t not
allowed to write
to user_home_t, might suggest that changing the label to httpd_user_content_t

Quoted 7 lines
Quoted 4 lines

This seems more along the lines of what setroubleshoot does, and tends to be policy-specific. We need to preserve the usability of audit2allow for other policies (e.g. Android, DSSP), so any policy-specific logic needs to be encapsulated, configuration-driven, and optional.

setroubleshoot is not smart enough to suggest httpd_user_content_t, instead it suggest you allow full access to /home/* by toggling the boolean that grants access to user home content.

I know this from experience. There was a bug in fedora's apache_user_content_template for more than a year and hardly anyone noticed it, probably because setroubleshoot would have just suggested you allow full access to user home content.

https://bugzilla.redhat.com/show_bug.cgi?id=1457406

Quoted 8 lines
Quoted 4 lines

I actually think the suggest a accessible type is the best improvement. audit2allow has defaulted for years to suggesting adding allow rules, usually the worst solution. Later we added boolean support, which was better but as you point out the not a great solution in a lot of cases.

The "best" improvement. I agree, but that say's more about the overal state of things than about the quality of this particular improvement.

The guy in the tweet was overwhelmed and intimidated by the large list of "accessible" types returned by setroubleshoot (and audit2allow would probably do the same) Also things arent as simple, its not just about "what type grants the access needed to my domain". Other domains access to that type should also be considered.

Which is why I suggested we filter it down to a list that has the same prefix. Also I think we should at least stick in the beginning to permissions that can effect the content of data, rather then just reveal the content.

write, append, add_name unlink setattr, remove_name rmdir link create ...

I think anything we can do to making it easier for the user to get a proper type, would be really helpful.

Quoted 6 lines
Quoted 3 lines

Most AVC's are caused by mislabeled files or processes. Having audit2allow attempt to examine the policy and figure out which types would have been allowed with some simple sorting rules might be a big improvement.

audit2allow INHO shouldnt "examine" the policy (at least not in any significant way) because it cannot do it right. audit2allow should just stick with the basics + audit2why.

audit2why is the only functionality that works reasonably well. provided that some of the more recent "improvements" to audit2why get removed.

audit2why does nothing to reveal the crutch of the problem, SELinux is a Labeling system, if things go wrong, most of the time the labels are wrong. audit2allow/audit2why does not consider this. THis is why you get a boolean suggestion as the first outcome.

I believe the checks should be

1. Is the target mislabeled? If yes, suggest restorecon, ( I believe it already does this)
2. If this is a modification permission, suggest a type if one exists that matches the the prefix of the source type. This helps a lot with people using default_t types, or types labeled var_log_t or var_lib_t. Somewhat with user_home_t.
3. Look for a boolean to satisfy the needs.
4. Suggest audit2allow -M mypol

There are probably a couple of other things that could happen.

Quoted 44 lines
Quoted 21 lines

Avc denying httpd_t ability to write to httpd_sys_content_t.

audit2allow should examine policy and figure out which domains httpd_t can write to with the current policy settings. Then it should sort the solutions based on the characters of the sources context. Perhaps chopping a characters off, maybe down to 3.

sesearch -A -s httpd_t -p write -c | cut -f1 -d ":" | cut -d" " -f 3 |
sort -u | grep httpd
httpd_cache_t
httpdcontent
httpd_lock_t
httpd_squirrelmail_t
httpd_sys_rw_content_t
httpd_t
httpd_tmpfs_t
httpd_tmp_t
httpd_user_rw_content_t
httpd_var_lib_t
httpd_var_run_t

Quoted 4 lines

Now eliminate the non file types, removes httpd_t.

That would give the user a much better chance of solving the problem without becoming policy specific.

It cannot do this right. If you look to be bugzilla i pasted above:

All that was needed was to allow the httpd_t domain access to read dirs with the httpd_sys_content_t type. sealert couldnt figure this out
and instead it suggested that he toggle the "httpd_use_user_content" boolean instead, which would grant httpd_t broad access to user home content, and defeat the purpose of "httpd_user_content_t"

Quoted 9 lines

Now if you wanted to become a little more smart, you could look at the second field of the label, and have a table that says "var" indicates the path begins with /var and "tmp" indicates a directory that ends with tmp. But users could probably determine this.

Sort by types starting with httpd, http, htt

The audience that uses this functionality get intimidated by the large lists of types that are returned and various "solutions" returned. plus often times the solutions returned are sub-optimal, but the user doesnt know this.

Seasoned users will only use audit2allow for simple things like translation of avc to raw rules (maybe resolving of interfaces but this is prone to bad results as well). quickly determining whether its a missing TE rule, boolean, or constraint. These users will use setools to do further analysis

#10 lore raw

----- Original Message -----

Quoted 110 lines

From: "Daniel Walsh" <[email protected]>
To: [email protected]
Sent: Monday, June 19, 2017 11:45:53 AM
Subject: Re: Collecting ideas for audit2allow improvement

Quoted 72 lines · Dominick Grift
Quoted 63 lines · Daniel Walsh
Quoted 62 lines · Dominick Grift
Quoted 61 lines · Dominick Grift
Quoted 13 lines · Stephen Smalley
Quoted 12 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis.
I collected ideas from my colleagues from RedHat SELinux team and I would also
like to hear your ideas - what would you improve to make audit2allow smarter or
easier to use.

Ideas collected so far:

Quoted 8 lines
Quoted 2 lines

* offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)

The hard part here is knowing when it is sufficient. Might require further kernel patches to get to the point where it is completely unambiguous from the audit messages alone. You could perhaps default to only allowing dac_read_search and only allow dac_override if you see that dac_read_search is already allowed and you are still getting a dac_override denial.

This should not be an issue anymore. Becuase now (linux v4.12) dac_read_search is first checked
so translating a rule for dac_read_search will always be the most secure option. It might not be enough but youll notice if it isnt. Just rerun it again and you'll end up with dac_override if needed.

Quoted 10 lines
Quoted 5 lines

* offer multiple solutions to a problem (example: 1) add allow rule
for
execute + execute_no_trans or 2) add allow rule for execute
+ type_transition rule)

Is this type_transition to an existing type that already exists, or defining a new type and transitioning to it, or both? Generating new domains and types dynamically is one of the major gaps in current audit2allow, and to date has only been supported in separate tools like sepolicy generate.

One should be extremely careful here. "execute" does not automatically imply "execute_no_trans". That assumption can lead to disaster
(https://www.cvedetails.com/cve/CVE-2015-1815/)

Quoted 8 lines
Quoted 8 lines

* interactive mode: ask questions and choose best solution
* warn when solution touches trusted computing base (rules you
should not be
adding)
* suggest alternate labels for content, example: httpd_t not
allowed to write
to user_home_t, might suggest that changing the label to httpd_user_content_t

Quoted 4 lines

This seems more along the lines of what setroubleshoot does, and tends to be policy-specific. We need to preserve the usability of audit2allow for other policies (e.g. Android, DSSP), so any policy-specific logic needs to be encapsulated, configuration-driven, and optional.

setroubleshoot is not smart enough to suggest httpd_user_content_t, instead it suggest you allow full access to /home/* by toggling the boolean that grants access to user home content.

I know this from experience. There was a bug in fedora's apache_user_content_template for more than a year and hardly anyone noticed it, probably because setroubleshoot would have just suggested you allow full access to user home content.

Quoted 5 lines
Quoted 1 line

https://bugzilla.redhat.com/show_bug.cgi?id=1457406

I actually think the suggest a accessible type is the best improvement. audit2allow has defaulted for years to suggesting adding allow rules, usually the worst solution. Later we added boolean support, which was better but as you point out the not a great solution in a lot of cases.

The "best" improvement. I agree, but that say's more about the overal state of things than about the quality of this particular improvement.

Quoted 6 lines

The guy in the tweet was overwhelmed and intimidated by the large list of "accessible" types returned by setroubleshoot (and audit2allow would probably do the same)
Also things arent as simple, its not just about "what type grants the access needed to my domain". Other domains access to that type should also be considered.

Which is why I suggested we filter it down to a list that has the same prefix. Also I think we should at least stick in the beginning to permissions that can effect the content of data, rather then just reveal the content.

write, append, add_name unlink setattr, remove_name rmdir link create ...

I think anything we can do to making it easier for the user to get a proper type, would be really helpful.

Quoted 10 lines
Quoted 4 lines

Most AVC's are caused by mislabeled files or processes. Having audit2allow
attempt to examine the policy and figure out which types would have been allowed with some simple sorting rules might be a big improvement.

audit2allow INHO shouldnt "examine" the policy (at least not in any significant way) because it cannot do it right. audit2allow should just stick with the basics + audit2why.

audit2why is the only functionality that works reasonably well. provided that some of the more recent "improvements" to audit2why get removed.

audit2why does nothing to reveal the crutch of the problem, SELinux is a Labeling system, if things go wrong, most of the time the labels are wrong. audit2allow/audit2why does not consider this. THis is why you get a boolean suggestion as the first outcome.

I believe the checks should be

Quoted 8 lines

1. Is the target mislabeled? If yes, suggest restorecon, ( I believe it already does this)
2. If this is a modification permission, suggest a type if one exists that matches the the prefix of the source type. This helps a lot with people using default_t types, or types labeled var_log_t or var_lib_t. Somewhat with user_home_t.
3. Look for a boolean to satisfy the needs.
4. Suggest audit2allow -M mypol

audit2allow along with semodule including a set priority like sealert does

# audit2allow -M mypol
# semodule -X 300 -i mypol.pp
Quoted 61 lines

There are probably a couple of other things that could happen.

Quoted 55 lines
Quoted 22 lines

Avc denying httpd_t ability to write to httpd_sys_content_t.

audit2allow should examine policy and figure out which domains httpd_t can write to with the current policy settings. Then it should sort the solutions based on the characters of the sources context. Perhaps chopping
a characters off, maybe down to 3.

sesearch -A -s httpd_t -p write -c | cut -f1 -d ":" | cut -d" " -f 3 |
sort -u | grep httpd
httpd_cache_t
httpdcontent
httpd_lock_t
httpd_squirrelmail_t
httpd_sys_rw_content_t
httpd_t
httpd_tmpfs_t
httpd_tmp_t
httpd_user_rw_content_t
httpd_var_lib_t
httpd_var_run_t

Quoted 5 lines

Now eliminate the non file types, removes httpd_t.

That would give the user a much better chance of solving the problem without
becoming policy specific.

It cannot do this right. If you look to be bugzilla i pasted above:

All that was needed was to allow the httpd_t domain access to read dirs with the httpd_sys_content_t type. sealert couldnt figure this out and instead it suggested that he toggle the "httpd_use_user_content" boolean instead, which would grant httpd_t broad access to user home content, and defeat the purpose of "httpd_user_content_t"

Quoted 9 lines

Now if you wanted to become a little more smart, you could look at the second field of the label, and have a table that says "var" indicates the path begins with /var and "tmp" indicates a directory that ends with tmp. But users could probably determine this.

Sort by types starting with httpd, http, htt

The audience that uses this functionality get intimidated by the large lists of types that are returned and various "solutions" returned. plus often times the solutions returned are sub-optimal, but the user doesnt know this.

Seasoned users will only use audit2allow for simple things like translation of avc to raw rules (maybe resolving of interfaces but this is prone to bad results as well). quickly determining whether its a missing TE rule, boolean, or constraint. These users will use setools to do further analysis

Signature · 2 lines
Simon Sekidde
gpg: 5848 958E 73BA 04D3 7C06 F096 1BA1 2DBF 94BC 377E
#11 lore raw
In reply to Daniel Walsh
Quoted 94 lines · Daniel Walsh
Quoted 54 lines · Dominick Grift
Quoted 53 lines · Daniel Walsh
Quoted 52 lines · Dominick Grift
Quoted 43 lines · Dominick Grift
Quoted 13 lines · Stephen Smalley
Quoted 12 lines · Jan Zarsky

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis.
I collected ideas from my colleagues from RedHat SELinux team and I would also
like to hear your ideas - what would you improve to make audit2allow smarter or
easier to use.

Ideas collected so far:

Quoted 8 lines
Quoted 2 lines

* offer dac_read_search when sufficient instead of dac_override (see <https://github.com/SELinuxProject/selinux/issues/31>)

The hard part here is knowing when it is sufficient. Might require further kernel patches to get to the point where it is completely unambiguous from the audit messages alone. You could perhaps default to only allowing dac_read_search and only allow dac_override if you see that dac_read_search is already allowed and you are still getting a dac_override denial.

This should not be an issue anymore. Becuase now (linux v4.12) dac_read_search is first checked
so translating a rule for dac_read_search will always be the most secure option. It might not be enough but youll notice if it isnt. Just rerun it again and you'll end up with dac_override if needed.

Quoted 9 lines
Quoted 4 lines

* offer multiple solutions to a problem (example: 1) add allow rule
for
execute + execute_no_trans or 2) add allow rule for execute
+ type_transition rule)

Is this type_transition to an existing type that already exists, or defining a new type and transitioning to it, or both? Generating new domains and types dynamically is one of the major gaps in current audit2allow, and to date has only been supported in separate tools like sepolicy generate.

One should be extremely careful here. "execute" does not automatically imply "execute_no_trans". That assumption can lead to disaster (https://www.cvedetails.com/cve/CVE-2015-1815/)

Quoted 8 lines
Quoted 8 lines

* interactive mode: ask questions and choose best solution
* warn when solution touches trusted computing base (rules you
should not be
adding)
* suggest alternate labels for content, example: httpd_t not
allowed to write
to user_home_t, might suggest that changing the label to httpd_user_content_t

Quoted 7 lines
Quoted 4 lines

This seems more along the lines of what setroubleshoot does, and tends to be policy-specific. We need to preserve the usability of audit2allow for other policies (e.g. Android, DSSP), so any policy-specific logic needs to be encapsulated, configuration-driven, and optional.

setroubleshoot is not smart enough to suggest httpd_user_content_t, instead it suggest you allow full access to /home/* by toggling the boolean that grants access to user home content.

I know this from experience. There was a bug in fedora's apache_user_content_template for more than a year and hardly anyone noticed it, probably because setroubleshoot would have just suggested you allow full access to user home content.

https://bugzilla.redhat.com/show_bug.cgi?id=1457406

Quoted 8 lines
Quoted 4 lines

I actually think the suggest a accessible type is the best improvement. audit2allow has defaulted for years to suggesting adding allow rules, usually the worst solution. Later we added boolean support, which was better but as you point out the not a great solution in a lot of cases.

The "best" improvement. I agree, but that say's more about the overal state of things than about the quality of this particular improvement.

The guy in the tweet was overwhelmed and intimidated by the large list of "accessible" types returned by setroubleshoot (and audit2allow would probably do the same) Also things arent as simple, its not just about "what type grants the access needed to my domain". Other domains access to that type should also be considered.

Which is why I suggested we filter it down to a list that has the same prefix. Also I think we should at least stick in the beginning to permissions that can effect the content of data, rather then just reveal the content.

write, append, add_name unlink setattr, remove_name rmdir link create ...

I think anything we can do to making it easier for the user to get a proper type, would be really helpful.

Quoted 6 lines
Quoted 3 lines

Most AVC's are caused by mislabeled files or processes. Having audit2allow attempt to examine the policy and figure out which types would have been allowed with some simple sorting rules might be a big improvement.

audit2allow INHO shouldnt "examine" the policy (at least not in any significant way) because it cannot do it right. audit2allow should just stick with the basics + audit2why.

audit2why is the only functionality that works reasonably well. provided that some of the more recent "improvements" to audit2why get removed.

audit2why does nothing to reveal the crutch of the problem, SELinux is a Labeling system, if things go wrong, most of the time the labels are wrong. audit2allow/audit2why does not consider this. THis is why you get a boolean suggestion as the first outcome.

I believe the checks should be

1. Is the target mislabeled? If yes, suggest restorecon, ( I believe it already does this)
2. If this is a modification permission, suggest a type if one exists that matches the the prefix of the source type. This helps a lot with people using default_t types, or types labeled var_log_t or var_lib_t. Somewhat with user_home_t.
3. Look for a boolean to satisfy the needs.
4. Suggest audit2allow -M mypol

Quoted 1 line

There are probably a couple of other things that could happen.

Call me a pessimist but I have my doubts that some code will ever be able to consistently ask SELinux the right questions on behalf of users to get the right answers for the users.

I suspect that the more sustainable approach would be to somehow enhance, or/and build on setools to make it even easier and more enjoyable to use so that people can use it to make sound decisions, rather than to rely on some code to ask the questions on the users behalf by facilitation but leave the subjective aspects to users (make it easier for users to ask the questions, but do not try to ask the questions on the users behalf)

I wish that some code could be intelligent enough to consistently suggest the best solutions, but i suppose best is subjective, and not sure whether computers are good at making rational decisions or good at rational thinking

One can literaly pour infinite resources into trying to make what seems to be impossible possible or one could spend these valuable resources to improving things that helps everyone: find ways to *improve* setools (make it more enjoyable to use and thereby stimulating people to think about security more)

Quoted 47 lines
Quoted 46 lines
Quoted 23 lines

Avc denying httpd_t ability to write to httpd_sys_content_t.

audit2allow should examine policy and figure out which domains httpd_t can write to with the current policy settings. Then it should sort the solutions based on the characters of the sources context. Perhaps chopping a characters off, maybe down to 3.

sesearch -A -s httpd_t -p write -c | cut -f1 -d ":" | cut -d" " -f 3 |
sort -u | grep httpd
httpd_cache_t
httpdcontent
httpd_lock_t
httpd_squirrelmail_t
httpd_sys_rw_content_t
httpd_t
httpd_tmpfs_t
httpd_tmp_t
httpd_user_rw_content_t
httpd_var_lib_t
httpd_var_run_t

Quoted 4 lines

Now eliminate the non file types, removes httpd_t.

That would give the user a much better chance of solving the problem without becoming policy specific.

It cannot do this right. If you look to be bugzilla i pasted above:

All that was needed was to allow the httpd_t domain access to read dirs with the httpd_sys_content_t type. sealert couldnt figure this out
and instead it suggested that he toggle the "httpd_use_user_content" boolean instead, which would grant httpd_t broad access to user home content, and defeat the purpose of "httpd_user_content_t"

Quoted 9 lines

Now if you wanted to become a little more smart, you could look at the second field of the label, and have a table that says "var" indicates the path begins with /var and "tmp" indicates a directory that ends with tmp. But users could probably determine this.

Sort by types starting with httpd, http, htt

The audience that uses this functionality get intimidated by the large lists of types that are returned and various "solutions" returned. plus often times the solutions returned are sub-optimal, but the user doesnt know this.

Seasoned users will only use audit2allow for simple things like translation of avc to raw rules (maybe resolving of interfaces but this is prone to bad results as well). quickly determining whether its a missing TE rule, boolean, or constraint. These users will use setools to do further analysis

Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
author
#12 lore raw

Thank you all for the feedback, I will now focus on studying the sources and I will try to keep you updated on my progress.

Quoted 226 lines · Daniel Walsh
Quoted 134 lines · Dominick Grift
Quoted 90 lines · Daniel Walsh
Quoted 80 lines · Dominick Grift
Quoted 79 lines · Dominick Grift
Quoted 78 lines · Stephen Smalley
Quoted 19 lines · Jan Zarsky
Quoted 12 lines

Hi,

I would like to improve SELinux audit2allow tool as my bachelor thesis.
I collected ideas from my colleagues from RedHat SELinux team and I
would also
like to hear your ideas - what would you improve to make audit2allow
smarter or
easier to use.

Quoted 6 lines

Ideas collected so far:

* offer dac_read_search when sufficient instead of dac_override
(see
<https://github.com/SELinuxProject/selinux/issues/31>)

Quoted 10 lines

The hard part here is knowing when it is sufficient. Might require
further kernel patches to get to the point where it is completely unambiguous from the audit messages alone. You could perhaps default
to only allowing dac_read_search and only allow dac_override if you see
that dac_read_search is already allowed and you are still getting a
dac_override denial.

This should not be an issue anymore. Becuase now (linux v4.12) dac_read_search is first checked
so translating a rule for dac_read_search will always be the most secure option. It might not be enough but youll notice if it isnt. Just rerun it again and you'll end up with dac_override if needed.

Quoted 6 lines
Quoted 6 lines

* offer multiple solutions to a problem (example: 1) add allow rule
for
execute + execute_no_trans or 2) add allow rule for execute
+ type_transition rule)

Quoted 8 lines

Is this type_transition to an existing type that already exists, or
defining a new type and transitioning to it, or both? Generating new
domains and types dynamically is one of the major gaps in current audit2allow, and to date has only been supported in separate tools like
sepolicy generate.

One should be extremely careful here. "execute" does not automatically imply "execute_no_trans". That assumption can lead to disaster (https://www.cvedetails.com/cve/CVE-2015-1815/)

Quoted 10 lines
Quoted 10 lines

* interactive mode: ask questions and choose best solution
* warn when solution touches trusted computing base (rules you
should not be
adding)
* suggest alternate labels for content, example: httpd_t not
allowed to write
to user_home_t, might suggest that changing the label to httpd_user_content_t

Quoted 7 lines

This seems more along the lines of what setroubleshoot does, and tends
to be policy-specific. We need to preserve the usability of audit2allow
for other policies (e.g. Android, DSSP), so any policy-specific logic
needs to be encapsulated, configuration-driven, and optional.

setroubleshoot is not smart enough to suggest httpd_user_content_t, instead it suggest you allow full access to /home/* by toggling the boolean that grants access to user home content.

I know this from experience. There was a bug in fedora's apache_user_content_template for more than a year and hardly anyone noticed it, probably because setroubleshoot would have just suggested you allow full access to user home content.

Quoted 6 lines
Quoted 1 line

https://bugzilla.redhat.com/show_bug.cgi?id=1457406

I actually think the suggest a accessible type is the best improvement.
audit2allow has defaulted for years to suggesting adding allow rules, usually the worst solution. Later we added boolean support, which was better but as you point out the not a great solution in a lot of cases.

The "best" improvement. I agree, but that say's more about the overal state of things than about the quality of this particular improvement.

Quoted 6 lines

The guy in the tweet was overwhelmed and intimidated by the large list of "accessible" types returned by setroubleshoot (and audit2allow would probably do the same)
Also things arent as simple, its not just about "what type grants the access needed to my domain". Other domains access to that type should also be considered.

Which is why I suggested we filter it down to a list that has the same prefix. Also I think we should at least stick in the beginning to permissions that can effect the content of data, rather then just reveal the
content.

write, append, add_name unlink setattr, remove_name rmdir link create ...

I think anything we can do to making it easier for the user to get a proper type, would be really helpful.

Quoted 11 lines
Quoted 5 lines

Most AVC's are caused by mislabeled files or processes. Having audit2allow
attempt to examine the policy and figure out which types would have been
allowed with some simple sorting rules might be a big improvement.

audit2allow INHO shouldnt "examine" the policy (at least not in any significant way) because it cannot do it right. audit2allow should just stick with the basics + audit2why.

audit2why is the only functionality that works reasonably well. provided that some of the more recent "improvements" to audit2why get removed.

audit2why does nothing to reveal the crutch of the problem, SELinux is a Labeling system, if things go wrong, most of the time the labels are wrong. audit2allow/audit2why does not consider this. THis is why you get a boolean suggestion as the first outcome.

I believe the checks should be

1. Is the target mislabeled? If yes, suggest restorecon, ( I believe it already does this)
2. If this is a modification permission, suggest a type if one exists that matches the the prefix of the source type. This helps a lot with people using default_t types, or types labeled var_log_t or var_lib_t. Somewhat with user_home_t.
3. Look for a boolean to satisfy the needs.
4. Suggest audit2allow -M mypol

Quoted 1 line

There are probably a couple of other things that could happen.

Call me a pessimist but I have my doubts that some code will ever be able to consistently ask SELinux the right questions on behalf of users to get the right answers for the users.

I suspect that the more sustainable approach would be to somehow enhance, or/and build on setools to make it even easier and more enjoyable to use so that people can use it to make sound decisions, rather than to rely on some code to ask the questions on the users behalf by facilitation but leave the subjective aspects to users (make it easier for users to ask the questions, but do not try to ask the questions on the users behalf)

I wish that some code could be intelligent enough to consistently suggest the best solutions, but i suppose best is subjective, and not sure whether computers are good at making rational decisions or good at rational thinking

One can literaly pour infinite resources into trying to make what seems to be impossible possible or one could spend these valuable resources to improving things that helps everyone: find ways to *improve* setools (make it more enjoyable to use and thereby stimulating people to think about security more)

Quoted 55 lines
Quoted 55 lines
Quoted 26 lines

Avc denying httpd_t ability to write to httpd_sys_content_t.

audit2allow should examine policy and figure out which domains httpd_t can
write to with the current policy settings. Then it should sort the solutions based on the characters of the sources context. Perhaps chopping
a characters off, maybe down to 3.

sesearch -A -s httpd_t -p write -c | cut -f1 -d ":" | cut -d" " -f 3 |
sort -u | grep httpd
httpd_cache_t
httpdcontent
httpd_lock_t
httpd_squirrelmail_t
httpd_sys_rw_content_t
httpd_t
httpd_tmpfs_t
httpd_tmp_t
httpd_user_rw_content_t
httpd_var_lib_t
httpd_var_run_t

Quoted 5 lines

Now eliminate the non file types, removes httpd_t.

That would give the user a much better chance of solving the problem without
becoming policy specific.

It cannot do this right. If you look to be bugzilla i pasted above:

All that was needed was to allow the httpd_t domain access to read dirs with the httpd_sys_content_t type. sealert couldnt figure this out and instead it suggested that he toggle the "httpd_use_user_content" boolean instead, which would grant httpd_t broad access to user home content, and defeat the purpose of "httpd_user_content_t"

Quoted 11 lines

Now if you wanted to become a little more smart, you could look at the second field of the label, and have a table that says "var" indicates the
path begins with /var and "tmp" indicates a directory that ends with tmp.
But users could probably determine this.

Sort by types starting with httpd, http, htt

The audience that uses this functionality get intimidated by the large lists of types that are returned and various "solutions" returned. plus often times the solutions returned are sub-optimal, but the user doesnt know this.

Quoted 7 lines
Quoted 6 lines

Seasoned users will only use audit2allow for simple things like translation of avc to raw rules (maybe resolving of interfaces but this is prone to bad results as well). quickly determining whether its a missing TE rule, boolean, or constraint. These users will use setools to do further analysis

--
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift