Skip to content

Commit b6e8889

Browse files
committed
70004: Added SELinux notes
1 parent 61d22c3 commit b6e8889

9 files changed

+118
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Definition
2+
A state machine model for access control focusing on [[Confidentiality]].
3+
- **no read up, no write down**
4+
5+
| Policy | Description |
6+
| ------------------- | ------------------------------------------------------------------------ |
7+
| Simple Security | A subject at a given level may not read an object at a higher level. |
8+
| Star (`*`) Security | A subject at a given level may not write to any object at a lower level. |
9+
| Discretionary | Use an access matrix to specify the discretionary access control. |
10+
*[Bell–LaPadula model - Wikipedia](https://en.wikipedia.org/wiki/Bell%E2%80%93LaPadula_model)*
11+
## Attributes
12+
- Focuses on [[Confidentiality]], rather than [[Integrity]] as with the [[Biba Model]]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Definition
2+
A state machine for access control focusing on [[Integrity]].
3+
- **no write up, no read down**
4+
5+
| Property | Description |
6+
| -------------------- | ----------------------------------------------------------------------------------- |
7+
| Simple Integrity | Subject at a given integrity level must not read data at a lower level. |
8+
| Star (`*`) Integrity | Subject at a given level on integrity must not write to data at a higher level. |
9+
| Invocation Property | A process cannot request higher access, only with subjects at equal or lower level. |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Definition
2+
- Users can change access controls for resources (e.g. files) they have ownership of / permissions to modify permissions of
3+
- Implemented in standard Operating Systems (Linux, Windows, BSD, MacOS)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Access control decisions cannot be changed by normal users.
2+
- System wide set of enforced rukes
3+
- Normal (i.e. non root) users cannot change permissions ([[Control Schema]])
4+
Offers stronger guarantees than [[Discretionary Access Control]] (does not trust normal users).
5+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Definition
2+
Enforced orthogonally to [[Security Enhanced Linux#Type Enforcement]].
3+
```python
4+
f"{user}:{role}:{type}:{security_level}" with
5+
security_level = f"{sensitivity}:{category labels}"
6+
7+
# For example:
8+
"user_u:user_r:user_t:s0-s2:c1,c4.c8"
9+
```
10+
- Sensitivity labels can instantiate a [[Bell-LaPadula Model]] or [[Biba Model]].
11+
- Category labels are used for isolation (e.g. departments in a company-wide system, users on the system).
12+
## Android
13+
Encodes multiple users using category field:
14+
15+
| User | Description |
16+
| --------- | ----------------------- |
17+
| Primary | Always Running |
18+
| Secondary | Background and Network |
19+
| Guest | Only one user at a time |
20+
Used for managed profiles:
21+
- parental controls (restricted profile)
22+
- company managed profiles (work accounts, samsung KNOX)

70004 - Advanced Computer Security/SELinux_flow.svg

Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## Summary
2+
Introduced by the NSA for securing linux assets.
3+
- Enforces an admin-defined security policy ([[Mandatory Access Control]]) over all processes, objects and operations.
4+
- Can confine services and applications (even running as root) to mitigate the risks of flawed or malicious programs
5+
6+
All subjects (processes) and objects (files, ports and other resources) are associated with labels used to describe authorisation.
7+
8+
When an operation occurs (e.g. opening a file), the request is redirected to a *policy engine* which determines if the subject can perform the operation.
9+
- Deny all by default
10+
11+
![[SELinux_flow.svg]]
12+
### Advantages
13+
- Can confine the operations of privileged system daemons (reduces the impact of a daemon being misused by a malicious process)
14+
- Centralized policy configuration is easier to manage and analyse than [[Discretionary Access Control]]'s scattered configuration.
15+
### Limitations
16+
- If the vulnerability used is in the kernel.
17+
- If a security policy is permissive ([[Security Enhanced Linux]] will merely enforce the policy it is given)
18+
## Type Enforcement
19+
```python
20+
# For each subject and object
21+
f"{user}:{role}:{type}:{security level}"
22+
23+
# for example
24+
facebook = f"u:r:facebook:s0:c0" # level: s0 is sensitivity, c0 is category
25+
sys_directory = f"u:r:sysfs:s0:c0"
26+
27+
```
28+
*Note: Android uses the type field to isolate processes, and level to isolate device users*
29+
- Process types are called *domains*
30+
- *Domains*/*types* are [[Security Equivalence Classes]]
31+
- Same *domain*/*type* means same access & the subject/object is identified using this.
32+
- The security level (sensitivity and zero of more categories) os determined by [[Multi-Level Security]]
33+
![[domains_and_types.svg]]
34+
### Rules
35+
```python
36+
f"allow {domain} {type}:{class} \{{permissions}\}"
37+
"allow D1 T2:file read_write_execute"
38+
39+
f"neverallow {domain} {type}:{class} \{{permissions}\}"
40+
41+
# Disallow any system service apart from the dumpstate, shell etc of the domain attribute from executing files
42+
"neverallow {domain -appdomain -dumpstate -shell -system_server -zygote} {file_type -system_file -exec_type}:file execute"
43+
```
44+
*Note: [AVCRules - SELinux Wiki (selinuxproject.org)](https://selinuxproject.org/page/AVCRules)*
45+
- `neverallow` is used to ensure no `allow` rules are added in future that accidentally conflict (the `checkpolicy` compiler issues a warning).
46+
- The last rule in a conflict is chosen
47+
## Configuration
48+
49+
| Path | Description |
50+
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
51+
| `*.te` | Type Enforcement files (`D1.te`, `D2.te`, etc.) containing rules for a domain. |
52+
| `file_contexts` | File security contexts (labels for `\sys` at build time, `\dev, \data` at runtime). |
53+
| `mac_permissions.xml` | Assigns a seinfo tag to applications based on their signature (and optionally package name). Configuration is read during startup. |
54+
| `seapp_contexts` | Maps app UID (and optionally seinfo) to domain. |
55+
## Android
56+
Ported to android in 2012, and adopted in *permissive mode* in `4.3`, *enforcing mode* in `4.4`.
57+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## Definition
2+
A grouping of similar/equivalent elements.

70004 - Advanced Computer Security/domains_and_types.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)