Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id v48JaQDC025668 for ; Mon, 8 May 2017 15:36:26 -0400 Received: by mail-qt0-f170.google.com with SMTP id m91so58802065qte.3 for ; Mon, 08 May 2017 12:36:24 -0700 (PDT) From: Karl MacMillan Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_BA47C1C6-D30A-4668-BC9B-813F3298A8C0" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Announcing SPAN: SELinux Policy Analysis Notebook Date: Mon, 8 May 2017 15:36:21 -0400 In-Reply-To: <20170508093229.GB3701@julius> Cc: selinux@tycho.nsa.gov To: Dominick Grift References: <20170506140358.GA21008@julius> <20170506161956.GA20145@julius> <20170506171920.GB20145@julius> <590F3B98.406@quarksecurity.com> <20170507154759.GA31890@julius> <590F78BA.5040800@quarksecurity.com> <20170508085555.GA3701@julius> <20170508093229.GB3701@julius> List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: --Apple-Mail=_BA47C1C6-D30A-4668-BC9B-813F3298A8C0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On May 8, 2017, at 5:32 AM, Dominick Grift = wrote: >=20 > On Mon, May 08, 2017 at 10:55:55AM +0200, Dominick Grift wrote: >> On Sun, May 07, 2017 at 03:42:50PM -0400, Joshua Brindle wrote: >>> Dominick Grift wrote: >>>> On Sun, May 07, 2017 at 11:22:00AM -0400, Joshua Brindle wrote:the >>>>> Dominick Grift wrote: >>>>> >>>>>=20 >>>>>> The idea is nice, unfortunately its inflexible and it has = hard-references to reference policy all-over. It has potential but it is = still rough. >>>>>>=20 >>>>> Of course, it is an analysis of a refpolicy-based policy. If you = want to >>>>> analyze a different policy (e.g., Android or home-rolled) you will = have to >>>>> change out all of the type sets, etc. >>>>>=20 >>>>> You can't make a magic generic analysis script without knowing how = key parts >>>>> of the system work and what types are associated with those = components. >>>>=20 >>>> What do you mean? that for example that hard-coded array of = "trusted" types. Is that not just redundant. >>>>=20 >>>=20 >>> you mean the example trusted types? I'm not sure I understand your = concern. >>>=20 >>>> Can't i just create that array myself and use it to exlude rules = with types in that array? That was one does not have to hard-code it. >>>>=20 >>>=20 >>> It is python, you can do anything you want. The example notebook is = a >>> starting point, anyone doing an analysis would probably make major = changes >>> for their analysis, which is the point. You modify the notebook to = build a >>> usable analysis between the starting policy and the policy you are >>> analyzing. >>>=20 >>> I've thought about trying this on an Android policy but haven't made = it a >>> priority. >>>=20 >>>> Also with regard to hardcoding the refpolicy file system = (ps.load_policy_source). I mean if youre just going to `grep -r` then = why do we have to assume anything there and hard code file suffixed, = directory structures etc etc? >>>=20 >>>=20 >>=20 >> ahh.. sorry. I just noticed that it can be overriden: >>=20 >> p, ps, bp, bps =3D = se.load_policies_from_config("policy_paths.config") >>=20 >> so i suppose i should be able to add that file to the notebook dir = and specify my own paths. >>=20 >> although that still doesnt deal with any file suffixes? (.cil) >=20 >=20 > take for example: = https://github.com/QuarkSecurity/SPAN/blob/master/span/span.py#L331 = >=20 > "domain" is a reference policy type attribute >=20 > One should expand on the "policy_paths.config" concept and allow us, = via configuration files, to override all the variables (attributes, = suffixes, paths, identifiers, etc) >=20 > So that the variables can we adjusted without the need to = reinstall/recompile a modified SPAN >=20 > Or just rename to RPAN (reference policy analysis notebook) I think it=E2=80=99s best to think of these as having three basic = layers: 1. Basic tools for SELinux policy analysis in Jupyter - these are usable = for any policy and make no assumptions about the presence of any types, = attributes, object classes, or permissions. So things like the rule = searching and information flow analysis fit into this group. This is a = large part of the value of SPAN. 2. Higher-level policy analysis methods - these are things like the = domain_types method and the domain / type summaries. These make some = minimal assumptions about attributes like domain. I=E2=80=99ll just = mention that these assumptions are very minimal and have been around for = a _long_ time. Domain long pre-dates the reference policy, for example. = More than attributes this layer is tied to the Linux object classes and = permissions. 3. Example notebooks - the two example notebooks are just that - = examples. They probably provide a useful starting point, but as Josh = points out, should simply be modified for your specific use case. So the question, then, is should the second layer (the higher-level = policy analysis methods) be made configurable. Honestly I think it would = be more work than just creating your own versions for a policy that = breaks the assumptions. To me, that=E2=80=99s the great advantage of = this versus other analysis tools. It=E2=80=99s so simple to create quick = tools that meet your needs. And given that the vast majority of Linux = and Android systems meet the assumptions I think that this is a = reasonable approach. Thanks - Karl >=20 >>=20 >> --=20 >> Key fingerprint =3D 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B = 6B02 >> = https://sks-keyservers.net/pks/lookup?op=3Dget&search=3D0x3B6C5F1D2C7B6B02= = >> Dominick Grift >=20 >=20 >=20 > --=20 > Key fingerprint =3D 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 > https://sks-keyservers.net/pks/lookup?op=3Dget&search=3D0x3B6C5F1D2C7B6B= 02 = > Dominick Grift --Apple-Mail=_BA47C1C6-D30A-4668-BC9B-813F3298A8C0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On May 8, 2017, at 5:32 AM, Dominick Grift <dac.override@gmail.com> wrote:

On Mon, May 08, 2017 at = 10:55:55AM +0200, Dominick Grift wrote:
On Sun, May 07, 2017 at = 03:42:50PM -0400, Joshua Brindle wrote:
Dominick Grift wrote:
On Sun, May 07, 2017 at 11:22:00AM -0400, = Joshua Brindle wrote:the
Dominick Grift wrote:
<snip>

The idea = is nice, unfortunately its inflexible and it has hard-references to = reference policy all-over. It has potential but it is still rough.

Of course, it is an analysis of a = refpolicy-based policy. If you want to
analyze a different = policy (e.g., Android or home-rolled) you will have to
change out all of the type sets, etc.

You can't make a magic generic analysis script without = knowing how key parts
of the system work and what types = are associated with those components.

What do you mean? that for example that hard-coded array of = "trusted" types. Is that not just redundant.


you mean the example trusted = types? I'm not sure I understand your concern.

Can't i just create that = array myself and use it to exlude rules with types in that array? That = was one does not have to hard-code it.


It is python, you can do anything = you want. The example notebook is a
starting point, anyone = doing an analysis would probably make major changes
for = their analysis, which is the point. You modify the notebook to build = a
usable analysis between the starting policy and the = policy you are
analyzing.

I've = thought about trying this on an Android policy but haven't made it a
priority.

Also with regard to hardcoding the refpolicy = file system (ps.load_policy_source). I mean if youre just going to `grep = -r` then why do we have to assume anything there and hard code file = suffixed, directory structures etc etc?



ahh.. sorry. I = just noticed that it can be overriden:

p, = ps, bp, bps =3D se.load_policies_from_config("policy_paths.config")

so i suppose i should be able to add that file = to the notebook dir and specify my own paths.

although that still doesnt deal with any file suffixes? = (.cil)


take for example: https://github.com/QuarkSecurity/SPAN/blob/master/span/span.py#= L331

"domain" is a reference policy = type attribute

One should expand on the = "policy_paths.config" concept and allow us, via configuration files, to = override all the variables (attributes, suffixes, paths, identifiers, = etc)

So that the variables can we = adjusted without the need to reinstall/recompile a modified = SPAN

Or just rename to RPAN = (reference policy analysis notebook)

I think = it=E2=80=99s best to think of these as having three basic = layers:

1. Basic tools for SELinux = policy analysis in Jupyter - these are usable for any policy and make no = assumptions about the presence of any types, attributes, object classes, = or permissions. So things like the rule searching and information flow = analysis fit into this group. This is a large part of the value of = SPAN.

2. Higher-level policy = analysis methods - these are things like the domain_types method and the = domain / type summaries. These make some minimal assumptions about = attributes like domain. I=E2=80=99ll just mention that these assumptions = are very minimal and have been around for a _long_ time. Domain long = pre-dates the reference policy, for example. More than attributes this = layer is tied to the Linux object classes and permissions.

3. Example notebooks - the two example notebooks = are just that - examples. They probably provide a useful starting point, = but as Josh points out, should simply be modified for your specific use = case.

So the question, then, is = should the second layer (the higher-level policy analysis methods) be = made configurable. Honestly I think it would be more work than just = creating your own versions for a policy that breaks the assumptions. To = me, that=E2=80=99s the great advantage of this versus other analysis = tools. It=E2=80=99s so simple to create quick tools that meet your = needs. And given that the vast majority of Linux and Android systems = meet the assumptions I think that this is a reasonable = approach.

Thanks - Karl



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



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

= --Apple-Mail=_BA47C1C6-D30A-4668-BC9B-813F3298A8C0--