The integrity analysis for the proposed TCB in Section 2.3 is performed on the SELinux example policy for Linux 2.4.19. This policy consists of over 50,000 policy statements 4. In Gokyo, the SELinux example policy comprises over 700 subject types and type attributes, over 40,000 individual permissions, and over 100,000 explicit assignments between subject types and permissions.
The integrity of the SELinux system is represented by two integrity constraints between the set of proposed TCB subject types and the set of all other subject types as shown in Figure 4. To represent this we create two subject types, TCB subject types (high integrity) and non-TCB subject types (low integrity), and aggregate the subject types into their respective group. The permissions assigned to each subject type node are automatically propagated to the aggregate subject types.
Our integrity protection goal is expressed using two constraints: (1) read-integrity constraint and (2) read-write-integrity constraint. Read-integrity constraints are violated if the low integrity subject has write permission (i.e., a permission representing the ability to modify the data in that SELinux class) to an object type and class pair that high integrity subject type has read permission to. Read-write integrity is violated if the high-integrity subject also has write permission to the object type and class pair in addition to read permission.
To implement these constraints, Gokyo assigns the invalid permissions to the high integrity set. For read-integrity, Gokyo creates a permission with all read permissions assigned for each object type and class pair that the low integrity subject can write. Similarly, for read-write-integrity, Gokyo creates a permission with all write permissions assigned for each object type and class pair that the low integrity subject can write. In this case, constraint verification takes an intersection of the invalid permissions and the ones assigned to the TCB subject types (i.e., different types of constraints may have different algorithms).
Note that it may be more efficient to test this constraint in the opposite manner by determining if the low integrity set has write permissions to object type and class pairs that the high integrity subject can read. At this point, we actually create both integrity test sets, but we should determine which is smaller and test only that one instead.
Analyzing integrity protection is basically a task of identifying all integrity conflicts and classifying them into their best legal classification. We have found that the number of conflicts that exist in the entire SELinux policy is too large to be effectively considered together. Fortunately, conflicts are independent. That is, the existence of one conflict has no effect on another. This means that a classification to eliminate one conflict cannot be undone by another conflict. For example, if we find that we can sanitize the use of a particular conflicting permission, the emergence of a conflict later does not impact this sanitization. This is true for all classifications. The one caveat is that we may find that a particular subject requires so many sanitizations that it should be trusted or excluded, but these cases are not excessive and easily handled. Usually, we determine whether a subject should be trusted or excluded before we do the hard work of figuring out a sanitization.
The result is that we can consider the conflicts in small groups, and
make classifications based on a subset of the information. Currently,
we use Gokyo in a mode in which it identifies a single conflict for
each invalid permission (i.e., constraint-generated). Sometimes,
attribute assignments result in multiple, unique conflicts, but Gokyo
only presents the attribute assignment once. Gokyo generates a log
containing all conflicts and the assignment paths between nodes
involved in the conflict, including the line numbers in which the
assignments are specified. This assists with the manual analysis
phase. However, addition metadata, such as the frequency of conflict
for a particular invalid permission, would also be useful. The log of
a constraint violation is shown below (class.conf
is SELinux
policy file, kernel.cst
is our constraint file, and
kernel.cfg
contains aggregate subject type definitions):
On constraint: kernel.cst(25) Role 151: mount_t has constraint: "integrity protected" with node: Role 882: non-mount Violating Assignments: Permission 2876: autofs_t:dir 00110000 (1) From: class.conf (60810) Perm 2876: autofs_t:dir 00110000 (2) to: class.conf (60759) Role 151: mount_t Violating Preclusions: Permission 45131: autofs_t:dir 003fffff (3) From: kernel.cst (25) Role 882: non-mount (4) to: class.conf (60759) Role 151: mount_t (5) to: class.conf (0) Perm 42608: autofs_t:dir 003e1c7e (6) to: class.conf (60639) Perm 2857: autofs_t:dir 003e1c7f (7) to: kernel.cfg (94) Role 148: automount_t (8) to: kernel.cfg (91) Role 882: non-mount
The violating assignments is the permission assigned to
mount_t
whose integrity may be violated. Line (1) indicates
where the permission was assigned to mount_t
, and line (2)
indicates where mount_t
was identified as a subject. The file
class.conf is a truncated version of policy.conf for
SELinux 2.4.19. For the violating preclusions, the path for the
assignment of the constraint-generated invalid permission is shown.
Line (3) refers to declaration of the aggregate subject type
(Gokyo-specific), and line (4) is the same as line (2). Line (5)
refers to the generated permission (no file line number because it is
generated), and line (6) shows the assignment of autofs_t
permissions to automount_t
. Lines (7) and (8) show that
automount_t
is assigned to the non-TCB aggregate.
For each conflict, Gokyo estimates the classifications based on: (1) the number of subject type conflicts (for trust); (2) whether the subject type or object type is required, see below (for excluding subject types); and (3) whether the conflict is read-integrity or read-write-integrity (for considering sanitization). Our proposal for removing object types based on whether the object type is created by only excluded subject types has not been implemented yet, so we use the object types required by our focal subject type.
For required subject types, we assumed that the purpose of our system
was to run an Apache web server. Thus, we include all Apache subject
types (i.e., those starting with httpd
) and all those subject
types that transition to an Apache subject type, directly or
indirectly. In addition to our TCB subject types, we require
dpkg_t
(i.e., the Debian package manager), rlogind
, several
user subject types. Ultimately, we will choose to exclude
rlogind
, but include user_t
in the analysis. Users may
be actively involved in script generation (e.g., for personal pages in
a corporate server). Because so few other required subject types are
found this way, we will add others later. Note that the set of
required object types includes the types accessible to the Apache
subject types only.