Skip to contentSkip to conversation

user guide draft: "Targeted Policy" review

DISCUSSION Murray McAllister 5 participants 17 messages Sep 3, 2008 – Sep 8, 2008 2 messages not in the archive SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Thanks.

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t domain type. When a subject runs in the unconfined_t domain type, SELinux rules do not apply, and only DAC rules are used.

Confined Subjects

A large number of subjects are protected, and are therefore confined by the SELinux targeted policy, including the Apache HTTP Server (httpd), Samba (samba), FTP (vsftpd), Kerberos (krb5-server), ISC BIND (bind and bind-chroot), NFS (nfs-utils), and NIS (ypserv). When a subject is confined, it runs in its own domain type, such as the httpd subject running in the httpd_t domain type. When a confined subject is compromised by an attacker, the damage an attacker can do and the data they can access is greatly limited.

The following example demonstrates how SELinux prevents the Apache HTTP Server (httpd) from reading files that are not correctly labeled, such as files intended for use by another subject. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/testfile command.

2. Run the ls -Z /var/www/html/testfile command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/testfile

By default, Linux users run unconfined on Fedora 10, which is why the testfile file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

[ What is object_r really for? ]

3. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. When the server has started, change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command succeeds.

4. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/testfile command to change the file type, to a file type that is used by Samba. Run the ls -Z /var/www/html/testfile command to verify the changes:

[ If a file has an entry in file_contexts, and is relabeled with semanage fcontext, does that update /etc/selinux/targeted/contexts/files/file_contexts with the change? I was going to try, but forgot how to change the file type with semanage]

-rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/testfile

5. Note: the current DAC permissions allow the httpd subject access to this file. Change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command fails:

HTTP request sent, awaiting response... 403 Forbidden

2008-08-22 03:48:40 ERROR 403: Forbidden.

This example demonstrates the additional security added by SELinux. Although the httpd subject had access to the object in step 5, because the object was labeled with a file type that httpd subject does not have access to, SELinux denied access. After step 5, an error such as the following is logged to /var/log/messages:

Aug 22 03:48:40 localhost setroubleshoot: SELinux is preventing httpd (httpd_t) "getattr"

to /var/www/html/testfile (samba_share_t). For complete SELinux messages. run sealert -l c05911d3-e680-4e42-8e36-fe2ab9f8e654

Also, if the audit package is installed and the auditd subject is running, a more detailed denial is logged to /var/log/audit/audit.log. These denials are discussed later.

Unconfined Subjects

Unconfined subjects run in the unconfined_t domain type. This means that SELinux policy rules do not apply, and only DAC permissions are used. When an unconfined subject is comprised, an attacker may gain access to a large number of system resources and data.

The following example demonstrates how the Apache HTTP Server (httpd) can access data intended for use by another subject, when running unconfined. Note: on Fedora 10, the httpd subject runs in the confined httpd_t domain type by default. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/test2file command.

2. Run the ls -Z /var/www/html/test2file command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/test2file

By default, Linux users run unconfined on Fedora 10, which is why the test2file file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

3. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/test2file command to change the file type, to a file type that is used by Samba. Run the ls -Z /var/www/html/test2file command to verify the changes:

-rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/test2file

4. To simulate the httpd subject running unconfined, run the /usr/sbin/setenforce 0 command as the Linux root user to temporarily disable SELinux. Confirm SELinux is disabled by running the /usr/sbin/getenforce command. When SELinux is disabled, /usr/sbin/getenforce returns Permissive:

$ getenforce
Permissive

5. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. Change into a directory where your Linux user has write access to, and run the wget http://localhost/test2file command. Unless there are any changes to the default configuration, this command succeeds.

6. Enable SELinux by running /usr/sbin/setenforce 1 command. When SELinux is enabled, /usr/sbin/getenforce returns Enforcing:

$ getenforce
Enforcing

The examples in these sections demonstrate how data can be protected from a compromised confined-subject (protected by SELinux), as well as how data is more accessible to an attacker from a compromised unconfined-subject (not protected by SELinux).

Confined and Unconfined User Domains

In progress. Introduction to restrictions on certain domains (user_t, guest_t etc).

Are there any SELinux restrictions on what users can do when they run unconfined?

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 4 lines · Murray McAllister

Hi,

Are there any SELinux restrictions on what users can do when they run unconfined?

Yes i think unconfined users cannot do execmem, execstack, execheap by default.
Otherwise they're exempted from policy enforcement i think.

Signature · 1 line
Dominick Grift <[email protected]>
#2 lore raw
In reply to Murray McAllister
Quoted 3 lines · Murray McAllister

subjects that are not targeted run in the unconfined_t domain type. When a subject runs in the unconfined_t domain type, SELinux rules do not apply, and only DAC rules are used.

I think we should keep trying to reduce the amount of jargon for users. e.g. can "domain type" be reduced to "domain" or even "label" ?

Quoted 7 lines

A large number of subjects are protected, and are therefore confined by the SELinux targeted policy, including the Apache HTTP Server (httpd), Samba (samba), FTP (vsftpd), Kerberos (krb5-server), ISC BIND (bind and bind-chroot), NFS (nfs-utils), and NIS (ypserv). When a subject is confined, it runs in its own domain type, such as the httpd subject running in the httpd_t domain type. When a confined subject is compromised by an attacker, the damage an attacker can do and the data they can access is greatly limited.

I think the above could be clarified more in terms of cause and effect, e.g. the extent of damage is limited because the attacker's access to resources is limited.

Quoted 15 lines

The following example demonstrates how SELinux prevents the Apache HTTP Server (httpd) from reading files that are not correctly labeled, such as files intended for use by another subject. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/testfile command.

2. Run the ls -Z /var/www/html/testfile command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/testfile

Quoted 6 lines

By default, Linux users run unconfined on Fedora 10, which is why the testfile file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

[ What is object_r really for? ]

Roles don't have any meaning for objects (at least, in this implementation), so object_r is just a default value for objects.

Quoted 5 lines

3. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. When the server has started, change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command succeeds.

I think it would be useful to show the sequence of commands and the output, e.g. what the user would see.

Quoted 6 lines

file. Change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command fails:

HTTP request sent, awaiting response... 403 Forbidden

2008-08-22 03:48:40 ERROR 403: Forbidden.

Perhaps also show the httpd error log entry.

Signature · 7 lines
James Morris
<[email protected]>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
Quoted 7 lines · James Morris
Quoted 3 lines · Murray McAllister

subjects that are not targeted run in the unconfined_t domain type. When a subject runs in the unconfined_t domain type, SELinux rules do not apply, and only DAC rules are used.

I think we should keep trying to reduce the amount of jargon for users. e.g. can "domain type" be reduced to "domain" or even "label" ?

I changed almost all instances of "domain type" to "domain".

Quoted 7 lines
Quoted 5 lines

3. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. When the server has started, change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command succeeds.

I think it would be useful to show the sequence of commands and the output, e.g. what the user would see.

I am adding output for each step.

Quoted 10 lines
Quoted 7 lines

file. Change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command fails:

HTTP request sent, awaiting response... 403 Forbidden

2008-08-22 03:48:40 ERROR 403: Forbidden.

Perhaps also show the httpd error log entry.

Thanks for the suggestions :)

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
In reply to Murray McAllister
Quoted 7 lines · Murray McAllister

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Thanks.

Quoted 7 lines

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t domain type. When a subject runs in the unconfined_t domain type, SELinux rules do not apply, and only DAC rules are used.

Not exactly true. SELinux rules are always applied, but the unconfined_t domain is allowed (almost) all permissions in the SELinux policy/rules.

Quoted 10 lines

Confined Subjects

A large number of subjects are protected, and are therefore confined by the SELinux targeted policy, including the Apache HTTP Server (httpd), Samba (samba), FTP (vsftpd), Kerberos (krb5-server), ISC BIND (bind and bind-chroot), NFS (nfs-utils), and NIS (ypserv). When a subject is confined, it runs in its own domain type, such as the httpd subject running in the httpd_t domain type. When a confined subject is compromised by an attacker, the damage an attacker can do and the data they can access is greatly limited.

Greatly limited might be too strong as a general statement - it is limited in accordance with the policy, and thus depends on how the policy is configured.

Quoted 15 lines

The following example demonstrates how SELinux prevents the Apache HTTP Server (httpd) from reading files that are not correctly labeled, such as files intended for use by another subject. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/testfile command.

2. Run the ls -Z /var/www/html/testfile command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/testfile

Quoted 7 lines

By default, Linux users run unconfined on Fedora 10, which is why the testfile file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

[ What is object_r really for? ]

The default role value for objects, and one that avoids any restrictions on the user, type, and level combination in the object context.

Quoted 14 lines

3. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. When the server has started, change into a directory where your Linux user has write access to, and run the wget
http://localhost/testfile command. Unless there are any changes to the default configuration, this command succeeds.

4. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/testfile command to change the file type, to a file type that is used by Samba. Run the ls -Z /var/www/html/testfile command to verify the changes:

Quoted 4 lines

[ If a file has an entry in file_contexts, and is relabeled with semanage fcontext, does that update /etc/selinux/targeted/contexts/files/file_contexts with the change? I was going to try, but forgot how to change the file type with semanage]

See the EXAMPLES section of the semanage man page.
semanage fcontext -a -t samba_share_t /var/www/html/testfile The semanage command will update the file_contexts file with the change, but does not immediately apply the label to any affected files - you need to run restorecon on the files in order to apply it.

Quoted 23 lines

-rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/testfile

5. Note: the current DAC permissions allow the httpd subject access to this file. Change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command fails:

HTTP request sent, awaiting response... 403 Forbidden

2008-08-22 03:48:40 ERROR 403: Forbidden.

This example demonstrates the additional security added by SELinux. Although the httpd subject had access to the object in step 5, because the object was labeled with a file type that httpd subject does not have access to, SELinux denied access. After step 5, an error such as the following is logged to /var/log/messages:

Aug 22 03:48:40 localhost setroubleshoot: SELinux is preventing httpd 

(httpd_t) "getattr"
to /var/www/html/testfile (samba_share_t). For complete SELinux messages. run sealert -l c05911d3-e680-4e42-8e36-fe2ab9f8e654

Quoted 8 lines

Also, if the audit package is installed and the auditd subject is running, a more detailed denial is logged to /var/log/audit/audit.log. These denials are discussed later.

Unconfined Subjects

Unconfined subjects run in the unconfined_t domain type. This means that SELinux policy rules do not apply, and only DAC permissions are used.

To be precise, the SELinux policy rules grant most permissions to the unconfined_t domain, making it _effectively_ unconstrained by SELinux even though the rules _are_ still applied.

Quoted 36 lines

When an unconfined subject is comprised, an attacker may gain access to a large number of system resources and data.

The following example demonstrates how the Apache HTTP Server (httpd) can access data intended for use by another subject, when running unconfined. Note: on Fedora 10, the httpd subject runs in the confined httpd_t domain type by default. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/test2file command.

2. Run the ls -Z /var/www/html/test2file command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/test2file

By default, Linux users run unconfined on Fedora 10, which is why the test2file file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

3. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/test2file command to change the file type, to a file type that is used by Samba. Run the ls

(quoted diff) +0 -2
-Z /var/www/html/test2file command to verify the changes:
 
-rw-r--r--  root root unconfined_u:object_r:samba_share_t:s0 

/var/www/html/test2file

Quoted 8 lines

4. To simulate the httpd subject running unconfined, run the /usr/sbin/setenforce 0 command as the Linux root user to temporarily disable SELinux. Confirm SELinux is disabled by running the /usr/sbin/getenforce command. When SELinux is disabled, /usr/sbin/getenforce returns Permissive:

$ getenforce
Permissive

There are more precise ways to make httpd unconfined w/o making the entire system permissive, e.g.:
1) Label the httpd binary with unconfined_exec_t and re-start it, or
2) Making the httpd_t domain permissive (in F10 and later):
semanage permissive -a httpd_t

Quoted 16 lines

5. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. Change into a directory where your Linux user has write access to, and run the wget http://localhost/test2file command. Unless there are any changes to the default configuration, this command succeeds.

6. Enable SELinux by running /usr/sbin/setenforce 1 command. When SELinux is enabled, /usr/sbin/getenforce returns Enforcing:

$ getenforce
Enforcing

The examples in these sections demonstrate how data can be protected from a compromised confined-subject (protected by SELinux), as well as how data is more accessible to an attacker from a compromised unconfined-subject (not protected by SELinux).

Quoted 7 lines

Confined and Unconfined User Domains

In progress. Introduction to restrictions on certain domains (user_t, guest_t etc).

Are there any SELinux restrictions on what users can do when they run unconfined?

Yes. They are still restricted by MCS. There are certain booleans that can apply certain restrictions like execmem, execstack. And if they run any program with its own domain and a domain transition is defined from unconfined_t to the program's domain then they are still subject to the restrictions on that domain.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#5 lore raw
Quoted 7 lines · Stephen Smalley
Quoted 6 lines · Murray McAllister

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Thanks.

Quoted 7 lines
Quoted 3 lines

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t domain type. When a subject runs in the unconfined_t domain type, SELinux rules do not apply, and only DAC rules are used.

Not exactly true. SELinux rules are always applied, but the unconfined_t domain is allowed (almost) all permissions in the SELinux policy/rules.

I have moved this part to the "Unconfined Subjects" section. How about:

Unconfined subjects run in the unconfined_t domain. For subjects running in this domain, SELinux policy rules are applied, but policy rules exist that allow subjects running in this domain almost all access. Subjects running in this domain almost always fall back to using DAC rules exclusively. When an unconfined subject is comprised, SELinux does not prevent the attacker from gaining access to system resources and data, and only DAC rules are used.

Quoted 8 lines
Quoted 4 lines

Confined Subjects

A large number of subjects are protected, and are therefore confined by the SELinux targeted policy, including the Apache HTTP Server (httpd), Samba (samba), FTP (vsftpd), Kerberos (krb5-server), ISC BIND (bind and bind-chroot), NFS (nfs-utils), and NIS (ypserv). When a subject is confined, it runs in its own domain type, such as the httpd subject running in the httpd_t domain type. When a confined subject is compromised by an attacker, the damage an attacker can do and the data they can access is greatly limited.

Greatly limited might be too strong as a general statement - it is limited in accordance with the policy, and thus depends on how the policy is configured.

How about:

When a confined subject is compromised by an attacker, depending on SELinux policy configuration, the attacker's access is to resources and the possible damage they can do is limited.

Quoted 10 lines
Quoted 10 lines

The following example demonstrates how SELinux prevents the Apache HTTP Server (httpd) from reading files that are not correctly labeled, such as files intended for use by another subject. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/testfile command.

2. Run the ls -Z /var/www/html/testfile command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/testfile

Quoted 6 lines
Quoted 3 lines

By default, Linux users run unconfined on Fedora 10, which is why the testfile file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

[ What is object_r really for? ]

The default role value for objects, and one that avoids any restrictions on the user, type, and level combination in the object context.

RBAC is used for subjects, not objects. Roles do not have a meaning for objects, and the object_r role is a generic role that is used for objects.

Quoted 29 lines
Quoted 6 lines

3. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. When the server has started, change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command succeeds.

4. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/testfile command to change the file type, to a file type that is used by Samba. Run the ls -Z /var/www/html/testfile command to verify the changes:

[ If a file has an entry in file_contexts, and is relabeled with semanage fcontext, does that update /etc/selinux/targeted/contexts/files/file_contexts with the change? I was going to try, but forgot how to change the file type with semanage]

See the EXAMPLES section of the semanage man page.
semanage fcontext -a -t samba_share_t /var/www/html/testfile The semanage command will update the file_contexts file with the change, but does not immediately apply the label to any affected files - you need to run restorecon on the files in order to apply it.

Quoted 16 lines

-rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/testfile

5. Note: the current DAC permissions allow the httpd subject access to this file. Change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command fails:

HTTP request sent, awaiting response... 403 Forbidden

2008-08-22 03:48:40 ERROR 403: Forbidden.

This example demonstrates the additional security added by SELinux. Although the httpd subject had access to the object in step 5, because the object was labeled with a file type that httpd subject does not have access to, SELinux denied access. After step 5, an error such as the following is logged to /var/log/messages:

Aug 22 03:48:40 localhost setroubleshoot: SELinux is preventing httpd (httpd_t) "getattr"

to /var/www/html/testfile (samba_share_t). For complete SELinux messages. run sealert -l c05911d3-e680-4e42-8e36-fe2ab9f8e654

Also, if the audit package is installed and the auditd subject is running, a more detailed denial is logged to /var/log/audit/audit.log. These denials are discussed later.

Quoted 7 lines
Quoted 3 lines

Unconfined Subjects

Unconfined subjects run in the unconfined_t domain type. This means that SELinux policy rules do not apply, and only DAC permissions are used.

To be precise, the SELinux policy rules grant most permissions to the unconfined_t domain, making it _effectively_ unconstrained by SELinux even though the rules _are_ still applied.

See above.

Quoted 22 lines
Quoted 22 lines

When an unconfined subject is comprised, an attacker may gain access to a large number of system resources and data.

The following example demonstrates how the Apache HTTP Server (httpd) can access data intended for use by another subject, when running unconfined. Note: on Fedora 10, the httpd subject runs in the confined httpd_t domain type by default. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/test2file command.

2. Run the ls -Z /var/www/html/test2file command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/test2file

By default, Linux users run unconfined on Fedora 10, which is why the test2file file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

3. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/test2file command to change the file type, to a file type that is used by Samba. Run the ls

(quoted diff) +0 -2
-Z /var/www/html/test2file command to verify the changes:
 
-rw-r--r--  root root unconfined_u:object_r:samba_share_t:s0 

/var/www/html/test2file

4. To simulate the httpd subject running unconfined, run the /usr/sbin/setenforce 0 command as the Linux root user to temporarily disable SELinux. Confirm SELinux is disabled by running the /usr/sbin/getenforce command. When SELinux is disabled, /usr/sbin/getenforce returns Permissive:

Quoted 8 lines
Quoted 2 lines
$ getenforce
Permissive

There are more precise ways to make httpd unconfined w/o making the entire system permissive, e.g.:
1) Label the httpd binary with unconfined_exec_t and re-start it, or
2) Making the httpd_t domain permissive (in F10 and later):
semanage permissive -a httpd_t

I'll update the example (probably with semanage permissive -a httpd_t)

Quoted 14 lines
Quoted 14 lines

5. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. Change into a directory where your Linux user has write access to, and run the wget http://localhost/test2file command. Unless there are any changes to the default configuration, this command succeeds.

6. Enable SELinux by running /usr/sbin/setenforce 1 command. When SELinux is enabled, /usr/sbin/getenforce returns Enforcing:

$ getenforce
Enforcing

The examples in these sections demonstrate how data can be protected from a compromised confined-subject (protected by SELinux), as well as how data is more accessible to an attacker from a compromised unconfined-subject (not protected by SELinux).

Confined and Unconfined User Domains

In progress. Introduction to restrictions on certain domains (user_t, guest_t etc).

Quoted 7 lines
Quoted 1 line

Are there any SELinux restrictions on what users can do when they run unconfined?

Yes. They are still restricted by MCS. There are certain booleans that can apply certain restrictions like execmem, execstack. And if they run any program with its own domain and a domain transition is defined from unconfined_t to the program's domain then they are still subject to the restrictions on that domain.

Thanks for your feedback.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#6 lore raw
Quoted 8 lines · Murray McAllister

I have moved this part to the "Unconfined Subjects" section. How about:

Unconfined subjects run in the unconfined_t domain. For subjects running in this domain, SELinux policy rules are applied, but policy rules exist that allow subjects running in this domain almost all access. Subjects running in this domain almost always fall back to using DAC rules exclusively. When an unconfined subject is comprised, SELinux does not

s/comprised/compromised/

Quoted 2 lines

prevent the attacker from gaining access to system resources and data, and only DAC rules are used.

Otherwise, sounds fine.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#7 lore raw
In reply to Murray McAllister
Quoted 47 lines · Murray McAllister
Quoted 16 lines · Stephen Smalley
Quoted 7 lines · Murray McAllister

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Thanks.

Quoted 7 lines

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t domain type. When a subject runs in the unconfined_t domain type, SELinux rules do not apply, and only DAC rules are used.

Quoted 3 lines

Not exactly true. SELinux rules are always applied, but the unconfined_t domain is allowed (almost) all permissions in the SELinux policy/rules.

I have moved this part to the "Unconfined Subjects" section. How about:

Unconfined subjects run in the unconfined_t domain. For subjects running in this domain, SELinux policy rules are applied, but policy rules exist that allow subjects running in this domain almost all access. Subjects running in this domain almost always fall back to using DAC rules exclusively. When an unconfined subject is comprised, SELinux does not prevent the attacker from gaining access to system resources and data, and only DAC rules are used.

Quoted 12 lines
Quoted 11 lines

Confined Subjects

A large number of subjects are protected, and are therefore confined by the SELinux targeted policy, including the Apache HTTP Server (httpd), Samba (samba), FTP (vsftpd), Kerberos (krb5-server), ISC BIND (bind and bind-chroot), NFS (nfs-utils), and NIS (ypserv). When a subject is confined, it runs in its own domain type, such as the httpd subject running in the httpd_t domain type. When a confined subject is compromised by an attacker, the damage an attacker can do and the data they can access is greatly limited.

Quoted 3 lines

Greatly limited might be too strong as a general statement - it is limited in accordance with the policy, and thus depends on how the policy is configured.

Quoted 6 lines

How about:

When a confined subject is compromised by an attacker, depending on SELinux policy configuration, the attacker's access is to resources and the possible damage they can do is limited.

If a confined ...

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

The following example demonstrates how SELinux prevents the Apache HTTP Server (httpd) from reading files that are not correctly labeled, such as files intended for use by another subject. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/testfile command.

2. Run the ls -Z /var/www/html/testfile command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/testfile

By default, Linux users run unconfined on Fedora 10, which is why the testfile file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

Quoted 68 lines
Quoted 4 lines
Quoted 1 line

[ What is object_r really for? ]

The default role value for objects, and one that avoids any restrictions on the user, type, and level combination in the object context.

RBAC is used for subjects, not objects. Roles do not have a meaning for objects, and the object_r role is a generic role that is used for objects.

Quoted 60 lines
Quoted 16 lines

3. As the Linux root user, start the Apache HTTP Server:
/sbin/service httpd start. When the server has started, change into a directory where your Linux user has write access to, and run the wget
http://localhost/testfile command. Unless there are any changes to the default configuration, this command succeeds.

4. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/testfile command to change the file type, to a file type that is used by Samba. Run the ls -Z /var/www/html/testfile command to verify the changes:

Quoted 4 lines

[ If a file has an entry in file_contexts, and is relabeled with semanage fcontext, does that update /etc/selinux/targeted/contexts/files/file_contexts with the change? I was going to try, but forgot how to change the file type with semanage]

See the EXAMPLES section of the semanage man page.
semanage fcontext -a -t samba_share_t /var/www/html/testfile The semanage command will update the file_contexts file with the change, but does not immediately apply the label to any affected files - you need to run restorecon on the files in order to apply it.

Quoted 32 lines

-rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/testfile

5. Note: the current DAC permissions allow the httpd subject access to this file. Change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command fails:

HTTP request sent, awaiting response... 403 Forbidden

2008-08-22 03:48:40 ERROR 403: Forbidden.

This example demonstrates the additional security added by SELinux. Although the httpd subject had access to the object in step 5, because the object was labeled with a file type that httpd subject does not have access to, SELinux denied access. After step 5, an error such as the following is logged to /var/log/messages:

Aug 22 03:48:40 localhost setroubleshoot: SELinux is preventing httpd

(httpd_t) "getattr"
to /var/www/html/testfile (samba_share_t). For complete SELinux messages.
run sealert -l c05911d3-e680-4e42-8e36-fe2ab9f8e654

Also, if the audit package is installed and the auditd subject is running, a more detailed denial is logged to /var/log/audit/audit.log. These denials are discussed later.

Unconfined Subjects

Unconfined subjects run in the unconfined_t domain type. This means that SELinux policy rules do not apply, and only DAC permissions are used.

Only unconfined login users run as unconfined_t, init programs run in the unconfined domain initrc_t, unconfined inetd processes run in the inetd_child_t domain. Unconfined kernel processes run in kernel_t. There are about 20 unconfined domains in Fedora 10.

Quoted 88 lines
Quoted 3 lines

To be precise, the SELinux policy rules grant most permissions to the unconfined_t domain, making it _effectively_ unconstrained by SELinux even though the rules _are_ still applied.

See above.

Quoted 45 lines
Quoted 45 lines

When an unconfined subject is comprised, an attacker may gain access to a large number of system resources and data.

The following example demonstrates how the Apache HTTP Server (httpd) can access data intended for use by another subject, when running unconfined. Note: on Fedora 10, the httpd subject runs in the confined httpd_t domain type by default. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/test2file command.

2. Run the ls -Z /var/www/html/test2file command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/test2file

By default, Linux users run unconfined on Fedora 10, which is why the test2file file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

3. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/test2file command to change the file type, to a file type that is used by Samba. Run the ls -Z /var/www/html/test2file command to verify the changes:

-rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/test2file

4. To simulate the httpd subject running unconfined, run the /usr/sbin/setenforce 0 command as the Linux root user to temporarily disable SELinux. Confirm SELinux is disabled by running the /usr/sbin/getenforce command. When SELinux is disabled, /usr/sbin/getenforce returns Permissive:

Quoted 8 lines
Quoted 2 lines
$ getenforce
Permissive

There are more precise ways to make httpd unconfined w/o making the entire system permissive, e.g.:
1) Label the httpd binary with unconfined_exec_t and re-start it, or
2) Making the httpd_t domain permissive (in F10 and later):
semanage permissive -a httpd_t

I'll update the example (probably with semanage permissive -a httpd_t)

Quoted 26 lines
Quoted 25 lines

5. As the Linux root user, start the Apache HTTP Server:
/sbin/service httpd start. Change into a directory where your Linux user has write access to, and run the wget http://localhost/test2file
command. Unless there are any changes to the default configuration, this command succeeds.

6. Enable SELinux by running /usr/sbin/setenforce 1 command. When SELinux is enabled, /usr/sbin/getenforce returns Enforcing:

$ getenforce
Enforcing

The examples in these sections demonstrate how data can be protected from a compromised confined-subject (protected by SELinux), as well as how data is more accessible to an attacker from a compromised unconfined-subject (not protected by SELinux).

Confined and Unconfined User Domains

In progress. Introduction to restrictions on certain domains (user_t, guest_t etc).

Are there any SELinux restrictions on what users can do when they run unconfined?

Quoted 14 lines
Quoted 5 lines

Yes. They are still restricted by MCS. There are certain booleans that can apply certain restrictions like execmem, execstack. And if they run any program with its own domain and a domain transition is defined from unconfined_t to the program's domain then they are still subject to the restrictions on that domain.

Thanks for your feedback.

Signature · 4 lines
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected]
with
the words "unsubscribe selinux" without quotes as the message.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#8 lore raw
Quoted 9 lines · Daniel J Walsh
Quoted 7 lines · Murray McAllister
Quoted 1 line · Stephen Smalley

On Wed, 2008-09-03 at 17:41 +1000, Murray McAllister wrote:

When a confined subject is compromised by an attacker, depending on SELinux policy configuration, the attacker's access is to resources and the possible damage they can do is limited.

If a confined ...

Changed.

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Unconfined Subjects

Unconfined subjects run in the unconfined_t domain type. This means that SELinux policy rules do not apply, and only DAC permissions are used.

Only unconfined login users run as unconfined_t, init programs run in the unconfined domain initrc_t, unconfined inetd processes run in the inetd_child_t domain. Unconfined kernel processes run in kernel_t. There are about 20 unconfined domains in Fedora 10.

How about:

Unconfined subjects run in unconfined domains, for example, init programs run in the unconfined initrc_t domain, unconfined kernel subjects run in the kernel_t domain, and unconfined Linux users run in the unconfined_t domain. For unconfined subjects, SELinux policy rules are applied, but policy rules exist that allow subjects running in unconfined domains almost all access. Subjects running in unconfined domains almost always fall back to using DAC rules exclusively. If an unconfined subject is compromised, SELinux does not prevent the attacker from gaining access to system resources and data, but of course, DAC rules are still used. SELinux is a security enhancement above DAC rules - it does not replace them.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#9 lore raw
Quoted 25 lines · Murray McAllister
Quoted 9 lines · Daniel J Walsh
Quoted 7 lines · Murray McAllister
Quoted 1 line · Stephen Smalley

On Wed, 2008-09-03 at 17:41 +1000, Murray McAllister wrote:

When a confined subject is compromised by an attacker, depending on SELinux policy configuration, the attacker's access is to resources and the possible damage they can do is limited.

If a confined ...

Changed.

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Unconfined Subjects

Unconfined subjects run in the unconfined_t domain type. This means that SELinux policy rules do not apply, and only DAC permissions are used.

Only unconfined login users run as unconfined_t, init programs run in the unconfined domain initrc_t, unconfined inetd processes run in the inetd_child_t domain. Unconfined kernel processes run in kernel_t. There are about 20 unconfined domains in Fedora 10.

How about:

Quoted 11 lines

Unconfined subjects run in unconfined domains, for example, init programs run in the unconfined initrc_t domain, unconfined kernel subjects run in the kernel_t domain, and unconfined Linux users run in the unconfined_t domain. For unconfined subjects, SELinux policy rules are applied, but policy rules exist that allow subjects running in unconfined domains almost all access. Subjects running in unconfined domains almost always fall back to using DAC rules exclusively. If an unconfined subject is compromised, SELinux does not prevent the attacker from gaining access to system resources and data, but of course, DAC rules are still used. SELinux is a security enhancement above DAC rules
- it does not replace them.

I don't think you need the "almost always"

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#10 lore raw
In reply to Murray McAllister

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 5 lines · Murray McAllister

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Quoted 7 lines

Thanks.

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t

confined domain, and subjects that are not targeted run in an unconfined domain, For example logged in users by default log in as unconfined_t while system processes started by init run in initrc_t. Both of these domains are unconfined.

NOTE:

Even unconfined domains are subject to executable/writable memory checks. execmem, execstack, execheap. By default processes run as an unconfined domain can not allocate writeable memory and execute it. This is a common attack vector call buffer overflow attacks. Some applications require this type of access (java, wine, mono and a few
others). These applications need to be labeled correctly to allow the
access. There are booleans that can turn off this protection for the unconfined user unconfined_t. allow_execmem, allow_execstack, allow_execheap.

You can turn the booleans on using setsebool

setsebool -P allow_execmem 1

Quoted 7 lines

domain type. When a subject runs in the unconfined_t domain type,

SELinux rules do not apply, and only DAC rules are used.

Confined Subjects

large number of subjects are protected, and are therefore confined by

Greater then 200, subjects are not protected they are confined. IE A subject could still be compromized but other processes on the system are protected from the confined process.

Quoted 3 lines

the SELinux targeted policy, including the Apache HTTP Server (httpd), Samba (samba), FTP (vsftpd), Kerberos (krb5-server), ISC BIND (bind and bind-chroot), NFS (nfs-utils), and NIS (ypserv).

This is an old RHEL4 list. Almost every domain that listens to the internet is now confined. And most processes that run as root and do stuff for users are confined.
When a subject is

Quoted 12 lines

confined, it runs in its own domain type, such as the httpd subject running in the httpd_t domain type. When a confined subject is compromised by an attacker, the damage an attacker can do and the data they can access is greatly limited.

The following example demonstrates how SELinux prevents the Apache HTTP Server (httpd) from reading files that are not correctly labeled, such as files intended for use by another subject. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

Quoted 8 lines

1. As the Linux root user, run the touch /var/www/html/testfile command.

2. Run the ls -Z /var/www/html/testfile command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/testfile

Make sure the machine is in enforcing mode, setenforce 1.

Quoted 7 lines

By default, Linux users run unconfined on Fedora 10, which is why the testfile file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

[ What is object_r really for? ]

Not used on objects so it is just the default.

Quoted 15 lines

3. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. When the server has started, change into a directory where your Linux user has write access to, and run the wget
http://localhost/testfile command. Unless there are any changes to the default configuration, this command succeeds.

4. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/testfile command to change the file type, to a file type that is used by Samba. Run the ls -Z /var/www/html/testfile command to verify the changes:

Quoted 5 lines

[ If a file has an entry in file_contexts, and is relabeled with semanage fcontext, does that update /etc/selinux/targeted/contexts/files/file_contexts with the change? I was going to try, but forgot how to change the file type with semanage]

Yes it will update /etc/selinux/targeted/contexts/files/file_contexts

Quoted 17 lines

-rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/testfile

5. Note: the current DAC permissions allow the httpd subject access to this file. Change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command fails:

HTTP request sent, awaiting response... 403 Forbidden

2008-08-22 03:48:40 ERROR 403: Forbidden.

This example demonstrates the additional security added by SELinux. Although the httpd subject had access to the object in step 5, because the object was labeled with a file type that httpd subject does not have access to, SELinux denied access. After step 5, an error such as the following is logged to /var/log/messages:

Quoted 5 lines
Aug 22 03:48:40 localhost setroubleshoot: SELinux is preventing httpd

(httpd_t) "getattr"
to /var/www/html/testfile (samba_share_t). For complete SELinux messages. run sealert -l c05911d3-e680-4e42-8e36-fe2ab9f8e654

setroubleshoot requires audit subsystem to be running.

Quoted 7 lines

Also, if the audit package is installed and the auditd subject is running, a more detailed denial is logged to /var/log/audit/audit.log. These denials are discussed later.

Unconfined Subjects

Unconfined subjects run in the unconfined_t domain type. This means that

Unconfined subjects run in the unconfined domain. This means that

Quoted 4 lines

SELinux policy rules do not apply, and only DAC permissions are used. When an unconfined subject is comprised, an attacker may gain access to a large number of system resources and data.

I think this would be better stated:

If an unconfined subject is compromized, SELinux will not prevent the attacker from gaining access to system resources and data, the system will still have DAC protection.

Quoted 58 lines

The following example demonstrates how the Apache HTTP Server (httpd) can access data intended for use by another subject, when running unconfined. Note: on Fedora 10, the httpd subject runs in the confined httpd_t domain type by default. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/test2file command.

2. Run the ls -Z /var/www/html/test2file command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/test2file

By default, Linux users run unconfined on Fedora 10, which is why the test2file file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

3. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/test2file command to change the file type, to a file type that is used by Samba. Run the ls

(quoted diff) +0 -2
-Z /var/www/html/test2file command to verify the changes:
 
-rw-r--r--  root root unconfined_u:object_r:samba_share_t:s0

/var/www/html/test2file

4. To simulate the httpd subject running unconfined, run the /usr/sbin/setenforce 0 command as the Linux root user to temporarily disable SELinux. Confirm SELinux is disabled by running the /usr/sbin/getenforce command. When SELinux is disabled, /usr/sbin/getenforce returns Permissive:

$ getenforce
Permissive

5. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. Change into a directory where your Linux user has write access to, and run the wget http://localhost/test2file command. Unless there are any changes to the default configuration, this command succeeds.

6. Enable SELinux by running /usr/sbin/setenforce 1 command. When SELinux is enabled, /usr/sbin/getenforce returns Enforcing:

$ getenforce
Enforcing

The examples in these sections demonstrate how data can be protected from a compromised confined-subject (protected by SELinux), as well as how data is more accessible to an attacker from a compromised unconfined-subject (not protected by SELinux).

Quoted 8 lines

Confined and Unconfined User Domains

In progress. Introduction to restrictions on certain domains (user_t, guest_t etc).

Are there any SELinux restrictions on what users can do when they run unconfined?

See above, Also there are booleans available to allow the transition to
a confined domain from the unconfined_t. The one I would like to
encourage is.

allow_unconfined_nsplugin_transition

Which will transition firefox plugins to a confined domain.

Quoted 5 lines
Signature · 4 lines
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected]
with
the words "unsubscribe selinux" without quotes as the message.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAki+kQYACgkQrlYvE4MpobNPWQCgujeWSr7KJHhu0qtsded8Ftyb +kIAoM2oo7FMz9n8NedTIyI/wh0sOG6K
=Yeqt
-----END PGP SIGNATURE-----

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#11 lore raw
Quoted 21 lines · Daniel J Walsh

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 5 lines · Murray McAllister

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Quoted 7 lines

Thanks.

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t

confined domain, and subjects that are not targeted run in an unconfined domain, For example logged in users by default log in as unconfined_t while system processes started by init run in initrc_t. Both of these domains are unconfined.

Quoted 8 lines

NOTE:

Even unconfined domains are subject to executable/writable memory checks. execmem, execstack, execheap. By default processes run as an unconfined domain can not allocate writeable memory and execute it. This is a common attack vector call buffer overflow attacks. Some applications require this type of access (java, wine, mono and a few others).

Does this mean applications running in a Java Virtual Machine, and in Wine?

I'll change my response below based on the answer to this.

These applications need to be labeled correctly to allow the

Quoted 7 lines

access. There are booleans that can turn off this protection for the unconfined user unconfined_t. allow_execmem, allow_execstack, allow_execheap.

You can turn the booleans on using setsebool

setsebool -P allow_execmem 1

I will use these examples later on.

How about:

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in a confined domain, and subjects that are not targeted run in an unconfined domain. For example, by default, logged in users run in the unconfined_t domain, and system processes started by init run in the initrc_t domain - both of these domains are unconfined.

Unconfined domains (as well as confined domains) are subject to executable and writeable memory checks. By default, subjects running in an unconfined domain can not allocate writeable memory and execute it.

[I think I changed the meaning. Is it still correct? ]

This reduces vulnerability to buffer overflow attacks. Some subjects require this access, including but not limited to Java™, Wine and Mono. To allow this access, these subjects must be labeled correctly, and memory checks need to be disabled for the users running in the unconfined_t domain. These memory checks are disable by setting booleans, which allow the SELinux policy to be modified during runtime. Configuring booleans is discussed later.

Quoted 11 lines
Quoted 8 lines

domain type. When a subject runs in the unconfined_t domain type,

SELinux rules do not apply, and only DAC rules are used.

Confined Subjects

large number of subjects are protected, and are therefore confined by

Greater then 200, subjects are not protected they are confined. IE A subject could still be compromized but other processes on the system are protected from the confined process.

Quoted 11 lines
Quoted 3 lines

the SELinux targeted policy, including the Apache HTTP Server (httpd), Samba (samba), FTP (vsftpd), Kerberos (krb5-server), ISC BIND (bind and bind-chroot), NFS (nfs-utils), and NIS (ypserv).

This is an old RHEL4 list. Almost every domain that listens to the internet is now confined. And most processes that run as root and do stuff for users are confined.
When a subject is

Quoted 4 lines

confined, it runs in its own domain type, such as the httpd subject running in the httpd_t domain type. When a confined subject is compromised by an attacker, the damage an attacker can do and the data they can access is greatly limited.

How about:

Almost every subject that has network access is confined in Fedora 10. Most subjects that run as the Linux root user and perform tasks for users, such as the passwd application, are confined. When a subject is confined, it runs in its own domain, such as the httpd subject running in the httpd_t domain. When a confined subject is compromised by an attacker, depending on SELinux policy configuration, the attacker's access is to resources and the possible damage they can do is limited.

Quoted 10 lines
Quoted 10 lines

The following example demonstrates how SELinux prevents the Apache HTTP Server (httpd) from reading files that are not correctly labeled, such as files intended for use by another subject. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/testfile command.

Quoted 7 lines
Quoted 6 lines

2. Run the ls -Z /var/www/html/testfile command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/testfile

Make sure the machine is in enforcing mode, setenforce 1.

I am adding more steps and example output.

Quoted 63 lines
Quoted 7 lines

By default, Linux users run unconfined on Fedora 10, which is why the testfile file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

[ What is object_r really for? ]

Not used on objects so it is just the default.

Quoted 14 lines

3. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. When the server has started, change into a directory where your Linux user has write access to, and run the wget
http://localhost/testfile command. Unless there are any changes to the default configuration, this command succeeds.

4. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/testfile command to change the file type, to a file type that is used by Samba. Run the ls -Z /var/www/html/testfile command to verify the changes:

Quoted 5 lines

[ If a file has an entry in file_contexts, and is relabeled with semanage fcontext, does that update /etc/selinux/targeted/contexts/files/file_contexts with the change? I was going to try, but forgot how to change the file type with semanage]

Yes it will update /etc/selinux/targeted/contexts/files/file_contexts

Quoted 17 lines

-rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/testfile

5. Note: the current DAC permissions allow the httpd subject access to this file. Change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command fails:

HTTP request sent, awaiting response... 403 Forbidden

2008-08-22 03:48:40 ERROR 403: Forbidden.

This example demonstrates the additional security added by SELinux. Although the httpd subject had access to the object in step 5, because the object was labeled with a file type that httpd subject does not have access to, SELinux denied access. After step 5, an error such as the following is logged to /var/log/messages:

Quoted 5 lines
Aug 22 03:48:40 localhost setroubleshoot: SELinux is preventing httpd

(httpd_t) "getattr"
to /var/www/html/testfile (samba_share_t). For complete SELinux messages. run sealert -l c05911d3-e680-4e42-8e36-fe2ab9f8e654

setroubleshoot requires audit subsystem to be running.

Quoted 7 lines

Also, if the audit package is installed and the auditd subject is running, a more detailed denial is logged to /var/log/audit/audit.log. These denials are discussed later.

Unconfined Subjects

Unconfined subjects run in the unconfined_t domain type. This means that

Unconfined subjects run in the unconfined domain. This means that

Quoted 4 lines

SELinux policy rules do not apply, and only DAC permissions are used. When an unconfined subject is comprised, an attacker may gain access to a large number of system resources and data.

Quoted 5 lines

I think this would be better stated:

If an unconfined subject is compromized, SELinux will not prevent the attacker from gaining access to system resources and data, the system will still have DAC protection.

How about:

When an unconfined subject is comprised, SELinux does not prevent the attacker from gaining access to system resources and data, and DAC rules are used.

(I should probably change these to "If an...")

Quoted 80 lines
Quoted 59 lines

The following example demonstrates how the Apache HTTP Server (httpd) can access data intended for use by another subject, when running unconfined. Note: on Fedora 10, the httpd subject runs in the confined httpd_t domain type by default. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/test2file command.

2. Run the ls -Z /var/www/html/test2file command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/test2file

By default, Linux users run unconfined on Fedora 10, which is why the test2file file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

3. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/test2file command to change the file type, to a file type that is used by Samba. Run the ls

(quoted diff) +0 -2
-Z /var/www/html/test2file command to verify the changes:
 
-rw-r--r--  root root unconfined_u:object_r:samba_share_t:s0

/var/www/html/test2file

4. To simulate the httpd subject running unconfined, run the /usr/sbin/setenforce 0 command as the Linux root user to temporarily disable SELinux. Confirm SELinux is disabled by running the /usr/sbin/getenforce command. When SELinux is disabled, /usr/sbin/getenforce returns Permissive:

$ getenforce
Permissive

5. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. Change into a directory where your Linux user has write access to, and run the wget http://localhost/test2file command. Unless there are any changes to the default configuration, this command succeeds.

6. Enable SELinux by running /usr/sbin/setenforce 1 command. When SELinux is enabled, /usr/sbin/getenforce returns Enforcing:

$ getenforce
Enforcing

The examples in these sections demonstrate how data can be protected from a compromised confined-subject (protected by SELinux), as well as how data is more accessible to an attacker from a compromised unconfined-subject (not protected by SELinux).

Quoted 8 lines

Confined and Unconfined User Domains

In progress. Introduction to restrictions on certain domains (user_t, guest_t etc).

Are there any SELinux restrictions on what users can do when they run unconfined?

See above, Also there are booleans available to allow the transition to
a confined domain from the unconfined_t. The one I would like to
encourage is.

allow_unconfined_nsplugin_transition

Which will transition firefox plugins to a confined domain.

Quoted 5 lines
Signature · 4 lines
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected]
with
the words "unsubscribe selinux" without quotes as the message.
Quoted 8 lines

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAki+kQYACgkQrlYvE4MpobNPWQCgujeWSr7KJHhu0qtsded8Ftyb +kIAoM2oo7FMz9n8NedTIyI/wh0sOG6K
=Yeqt
-----END PGP SIGNATURE-----

Thanks for your help.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#12 lore raw
Quoted 19 lines · Murray McAllister

Daniel J Walsh wrote:

Quoted 5 lines · Murray McAllister
Quoted 5 lines
Quoted 5 lines

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks.

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t

confined domain, and subjects that are not targeted run in an unconfined domain, For example logged in users by default log in as unconfined_t while system processes started by init run in initrc_t. Both of these domains are unconfined.

Quoted 12 lines

NOTE:

Even unconfined domains are subject to executable/writable memory checks. execmem, execstack, execheap. By default processes run as an unconfined domain can not allocate writeable memory and execute it. This is a common attack vector call buffer overflow attacks. Some applications require this type of access (java, wine, mono and a few others).

Quoted 3 lines

Does this mean applications running in a Java Virtual Machine, and in Wine?

I'll change my response below based on the answer to this.

Yes

Quoted 27 lines
Quoted 2 lines

These applications need to be labeled correctly to allow the

access. There are booleans that can turn off this protection for the unconfined user unconfined_t. allow_execmem, allow_execstack, allow_execheap.

You can turn the booleans on using setsebool

setsebool -P allow_execmem 1

Quoted 17 lines

I will use these examples later on.

How about:

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in a confined domain, and subjects that are not targeted run in an unconfined domain. For example, by default, logged in users run in the unconfined_t domain, and system processes started by init run in the initrc_t domain - both of these domains are unconfined.

Unconfined domains (as well as confined domains) are subject to executable and writeable memory checks. By default, subjects running in an unconfined domain can not allocate writeable memory and execute it.

[I think I changed the meaning. Is it still correct? ]

Looks good

Quoted 4 lines
Quoted 4 lines

This reduces vulnerability to buffer overflow attacks. Some subjects require this access, including but not limited to Java", Wine and Mono. To allow this access, these subjects must be labeled correctly.

For example, if you had a java application /usr/local/bin/myjavaapp, that was not working because it needed the execmem access, you could change the system labeling.

# semanage fcontext -a -t java_exec_t /usr/local/bin/myjavaapp
Then you fix the context on the actual file
# restorecon /usr/local/bin/myjavaapp

myjavaapp will now be allowed to run with execmem and execstack.

If you do not want to deal with any of the memory checks for users, you can disable them with by setting the allow_exec* booleans.

# setsebool -P allow_execmem=1 allow_execstack=1 allow_execheap=1
You can check if the booleans current state by executing

getsebool -a | grep allow_exec

You system is most protected if these booleans are turned off.

# setsebool -P allow_execmem=0 allow_execstack=0 allow_execheap=0
Quoted 2 lines
Quoted 2 lines

memory checks need to be disabled for the users running in the unconfined_t domain.

No this sentence is wrong.
These memory checks are disable by setting

Quoted 16 lines
Quoted 13 lines

booleans, which allow the SELinux policy to be modified during runtime. Configuring booleans is discussed later.

Quoted 7 lines
Quoted 7 lines

domain type. When a subject runs in the unconfined_t domain type,

SELinux rules do not apply, and only DAC rules are used.

Confined Subjects

large number of subjects are protected, and are therefore confined by

Greater then 200, subjects are not protected they are confined. IE A subject could still be compromized but other processes on the system are protected from the confined process.

Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the SELinux targeted policy, including the Apache HTTP Server (httpd), Samba (samba), FTP (vsftpd), Kerberos (krb5-server), ISC BIND (bind and bind-chroot), NFS (nfs-utils), and NIS (ypserv).

This is an old RHEL4 list. Almost every domain that listens to the internet is now confined. And most processes that run as root and do stuff for users are confined.
When a subject is

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

confined, it runs in its own domain type, such as the httpd subject running in the httpd_t domain type. When a confined subject is compromised by an attacker, the damage an attacker can do and the data they can access is greatly limited.

How about:

Almost every subject that has network access is confined in Fedora 10. Most subjects that run as the Linux root user and perform tasks for users, such as the passwd application, are confined.

DBUS/Hal are good examples also.
When a subject is

Quoted 5 lines
Quoted 4 lines

confined, it runs in its own domain, such as the httpd subject running in the httpd_t domain. When a confined subject is compromised by an attacker, depending on SELinux policy configuration, the attacker's access is to resources and the possible damage they can do is limited.

Good

Quoted 84 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The following example demonstrates how SELinux prevents the Apache HTTP Server (httpd) from reading files that are not correctly labeled, such as files intended for use by another subject. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

1. As the Linux root user, run the touch /var/www/html/testfile command.

2. Run the ls -Z /var/www/html/testfile command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/testfile

Make sure the machine is in enforcing mode, setenforce 1.

Quoted 9 lines

I am adding more steps and example output.

Quoted 7 lines
Quoted 7 lines

By default, Linux users run unconfined on Fedora 10, which is why the testfile file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

[ What is object_r really for? ]

Not used on objects so it is just the default.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

3. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. When the server has started, change into a directory where your Linux user has write access to, and run the wget
http://localhost/testfile command. Unless there are any changes to the default configuration, this command succeeds.

4. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/testfile command to change the file type, to a file type that is used by Samba. Run the ls -Z /var/www/html/testfile command to verify the changes:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

[ If a file has an entry in file_contexts, and is relabeled with semanage fcontext, does that update /etc/selinux/targeted/contexts/files/file_contexts with the change? I was going to try, but forgot how to change the file type with semanage]

Yes it will update /etc/selinux/targeted/contexts/files/file_contexts

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

-rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/testfile

5. Note: the current DAC permissions allow the httpd subject access to this file. Change into a directory where your Linux user has write access to, and run the wget http://localhost/testfile command. Unless there are any changes to the default configuration, this command fails:

HTTP request sent, awaiting response... 403 Forbidden

2008-08-22 03:48:40 ERROR 403: Forbidden.

This example demonstrates the additional security added by SELinux. Although the httpd subject had access to the object in step 5, because the object was labeled with a file type that httpd subject does not have access to, SELinux denied access. After step 5, an error such as the following is logged to /var/log/messages:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Aug 22 03:48:40 localhost setroubleshoot: SELinux is preventing httpd

(httpd_t) "getattr"
to /var/www/html/testfile (samba_share_t). For complete SELinux messages.
run sealert -l c05911d3-e680-4e42-8e36-fe2ab9f8e654

setroubleshoot requires audit subsystem to be running.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Also, if the audit package is installed and the auditd subject is running, a more detailed denial is logged to /var/log/audit/audit.log. These denials are discussed later.

Unconfined Subjects

Unconfined subjects run in the unconfined_t domain type. This means that

Unconfined subjects run in the unconfined domain. This means that

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

SELinux policy rules do not apply, and only DAC permissions are used. When an unconfined subject is comprised, an attacker may gain access to a large number of system resources and data.

Quoted 14 lines

I think this would be better stated:

If an unconfined subject is compromized, SELinux will not prevent the attacker from gaining access to system resources and data, the system will still have DAC protection.

Quoted 7 lines

How about:

When an unconfined subject is comprised, SELinux does not prevent the attacker from gaining access to system resources and data, and DAC rules are used.

(I should probably change these to "If an...")

If an unconfined subject is comprised, SELinux does not prevent the attacker from gaining access to system resources and data, of course DAC rules are used.

Note: A common misconception about SELinux is that it replaces DAC Controls, when it really just augments them.

Quoted 76 lines
Quoted 61 lines
Quoted 61 lines
Quoted 61 lines

The following example demonstrates how the Apache HTTP Server (httpd) can access data intended for use by another subject, when running unconfined. Note: on Fedora 10, the httpd subject runs in the confined httpd_t domain type by default. This is an example, and should not be used in production. It assumes that the httpd and wget packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode:

1. As the Linux root user, run the touch /var/www/html/test2file command.

2. Run the ls -Z /var/www/html/test2file command to view the SELinux context:

-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/test2file

By default, Linux users run unconfined on Fedora 10, which is why the test2file file object is labeled with the SELinux unconfined_u user. The object_r role is a standard role, and does not affect access control. The httpd_sys_content_t file type allows the httpd subject to access this object.

3. The /usr/bin/chcon command relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use the /usr/sbin/semanage command, which is discussed later. As the Linux root user, run the /usr/bin/chcon -t samba_share_t /var/www/html/test2file command to change the file type, to a file type that is used by Samba. Run the ls

(quoted diff) +0 -2
-Z /var/www/html/test2file command to verify the changes:
 
-rw-r--r--  root root unconfined_u:object_r:samba_share_t:s0

/var/www/html/test2file

4. To simulate the httpd subject running unconfined, run the /usr/sbin/setenforce 0 command as the Linux root user to temporarily disable SELinux. Confirm SELinux is disabled by running the /usr/sbin/getenforce command. When SELinux is disabled, /usr/sbin/getenforce returns Permissive:

$ getenforce
Permissive

5. As the Linux root user, start the Apache HTTP Server: /sbin/service httpd start. Change into a directory where your Linux user has write access to, and run the wget http://localhost/test2file command. Unless there are any changes to the default configuration, this command succeeds.

6. Enable SELinux by running /usr/sbin/setenforce 1 command. When SELinux is enabled, /usr/sbin/getenforce returns Enforcing:

$ getenforce
Enforcing

The examples in these sections demonstrate how data can be protected from a compromised confined-subject (protected by SELinux), as well as how data is more accessible to an attacker from a compromised unconfined-subject (not protected by SELinux).

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Confined and Unconfined User Domains

In progress. Introduction to restrictions on certain domains (user_t, guest_t etc).

Are there any SELinux restrictions on what users can do when they run unconfined?

See above, Also there are booleans available to allow the transition to
a confined domain from the unconfined_t. The one I would like to
encourage is.

allow_unconfined_nsplugin_transition

Which will transition firefox plugins to a confined domain.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Signature · 4 lines
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected]
with
the words "unsubscribe selinux" without quotes as the message.

Thanks for your help.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#13 lore raw
Quoted 29 lines · Daniel J Walsh
Quoted 28 lines · Murray McAllister

Daniel J Walsh wrote:

Quoted 5 lines · Murray McAllister
Quoted 5 lines
Quoted 5 lines

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks.

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t

confined domain, and subjects that are not targeted run in an unconfined domain, For example logged in users by default log in as unconfined_t while system processes started by init run in initrc_t. Both of these domains are unconfined.

NOTE:

Even unconfined domains are subject to executable/writable memory checks. execmem, execstack, execheap. By default processes run as an unconfined domain can not allocate writeable memory and execute it. This is a common attack vector call buffer overflow attacks. Some applications require this type of access (java, wine, mono and a few others).

Quoted 17 lines
Quoted 3 lines
Quoted 3 lines

Does this mean applications running in a Java Virtual Machine, and in Wine?

I'll change my response below based on the answer to this.

Yes

Quoted 13 lines
Quoted 2 lines

These applications need to be labeled correctly to allow the

access. There are booleans that can turn off this protection for the unconfined user unconfined_t. allow_execmem, allow_execstack, allow_execheap.

You can turn the booleans on using setsebool

setsebool -P allow_execmem 1

Quoted 1 line

I will use these examples later on.

And then there is text relocation

http://people.redhat.com/drepper/textrelocs.html
http://people.redhat.com/drepper/selinux-mem.html

/usr/sbin/semanage fcontext -l | grep execmem
/usr/sbin/semanage fcontext -l | grep textrel

Quoted 4 lines

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Signature · 1 line
Dominick Grift <[email protected]>
#14 lore raw
In reply to Daniel J Walsh
Quoted 76 lines · Daniel J Walsh
Quoted 19 lines · Murray McAllister

Daniel J Walsh wrote:

Quoted 5 lines · Murray McAllister
Quoted 5 lines
Quoted 5 lines

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks.

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t

confined domain, and subjects that are not targeted run in an unconfined domain, For example logged in users by default log in as unconfined_t while system processes started by init run in initrc_t. Both of these domains are unconfined.

Quoted 11 lines

NOTE:

Even unconfined domains are subject to executable/writable memory checks. execmem, execstack, execheap. By default processes run as an unconfined domain can not allocate writeable memory and execute it. This is a common attack vector call buffer overflow attacks. Some applications require this type of access (java, wine, mono and a few others).

Quoted 2 lines

Does this mean applications running in a Java Virtual Machine, and in Wine? I'll change my response below based on the answer to this.

Yes

Quoted 22 lines
Quoted 1 line

These applications need to be labeled correctly to allow the

access. There are booleans that can turn off this protection for the unconfined user unconfined_t. allow_execmem, allow_execstack, allow_execheap.

You can turn the booleans on using setsebool

setsebool -P allow_execmem 1

Quoted 13 lines

I will use these examples later on.

How about:
Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in a confined domain, and subjects that are not targeted run in an unconfined domain. For example, by default, logged in users run in the unconfined_t domain, and system processes started by init run in the initrc_t domain - both of these domains are unconfined.
Unconfined domains (as well as confined domains) are subject to executable and writeable memory checks. By default, subjects running in an unconfined domain can not allocate writeable memory and execute it. [I think I changed the meaning. Is it still correct? ]

Looks good

Quoted 3 lines
Quoted 3 lines

This reduces vulnerability to buffer overflow attacks. Some subjects require this access, including but not limited to Java", Wine and Mono. To allow this access, these subjects must be labeled correctly.

For example, if you had a java application /usr/local/bin/myjavaapp, that was not working because it needed the execmem access, you could change the system labeling.

# semanage fcontext -a -t java_exec_t /usr/local/bin/myjavaapp
Then you fix the context on the actual file
# restorecon /usr/local/bin/myjavaapp

myjavaapp will now be allowed to run with execmem and execstack.

If you do not want to deal with any of the memory checks for users, you can disable them with by setting the allow_exec* booleans.

# setsebool -P allow_execmem=1 allow_execstack=1 allow_execheap=1
You can check if the booleans current state by executing

getsebool -a | grep allow_exec

Quoted 11 lines

You system is most protected if these booleans are turned off.

# setsebool -P allow_execmem=0 allow_execstack=0 allow_execheap=0
Quoted 2 lines
Quoted 2 lines

memory checks need to be disabled for the users running in the unconfined_t domain.

No this sentence is wrong.
These memory checks are disable by setting

Quoted 3 lines
Quoted 2 lines

booleans, which allow the SELinux policy to be modified during runtime. Configuring booleans is discussed later.

I removed some bits to avoid too much theory:

Unconfined domains (as well as confined domains) are subject to executable and writeable memory checks. By default, subjects running in an unconfined domain can not allocate writeable memory and execute it. This reduces vulnerability to buffer overflow attacks. These memory checks are disable by setting booleans, which allow the SELinux policy to be modified during runtime. Configuring booleans is discussed later.

Quoted 11 lines
Quoted 5 lines
Quoted 5 lines

How about:
When an unconfined subject is comprised, SELinux does not prevent the attacker from gaining access to system resources and data, and DAC rules are used.
(I should probably change these to "If an...")

If an unconfined subject is comprised, SELinux does not prevent the attacker from gaining access to system resources and data, of course DAC rules are used.

Note: A common misconception about SELinux is that it replaces DAC Controls, when it really just augments them.

How about:

If an unconfined subject is compromised, SELinux does not prevent the attacker from gaining access to system resources and data, but of course, DAC rules are still used. SELinux is a security enhancement on top of DAC rules - it does not replace them.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#15 lore raw
Quoted 113 lines · Murray McAllister
Quoted 78 lines · Daniel J Walsh
Quoted 20 lines · Murray McAllister

Daniel J Walsh wrote:

Quoted 5 lines · Murray McAllister
Quoted 5 lines
Quoted 5 lines

Hi,

The following is a draft of the "Targeted Policy" sections for the SELinux User Guide. Any comments and corrections are appreciated.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Thanks.

Targeted Policy

Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in their own domain type, and subjects that are not targeted run in the unconfined_t

confined domain, and subjects that are not targeted run in an unconfined domain, For example logged in users by default log in as unconfined_t while system processes started by init run in initrc_t. Both of these domains are unconfined.

Quoted 11 lines

NOTE:

Even unconfined domains are subject to executable/writable memory checks. execmem, execstack, execheap. By default processes run as an unconfined domain can not allocate writeable memory and execute it. This is a common attack vector call buffer overflow attacks. Some applications require this type of access (java, wine, mono and a few others).

Quoted 3 lines

Does this mean applications running in a Java Virtual Machine, and in Wine?
I'll change my response below based on the answer to this.

Yes

Quoted 23 lines
Quoted 1 line

These applications need to be labeled correctly to allow the

access. There are booleans that can turn off this protection for the unconfined user unconfined_t. allow_execmem, allow_execstack, allow_execheap.

You can turn the booleans on using setsebool

setsebool -P allow_execmem 1

Quoted 14 lines

I will use these examples later on.

How about:
Targeted policy is the default SELinux policy used in Fedora 10. When using targeted policy, subjects that are targeted run in a confined domain, and subjects that are not targeted run in an unconfined domain. For example, by default, logged in users run in the unconfined_t domain,
and system processes started by init run in the initrc_t domain - both of these domains are unconfined.
Unconfined domains (as well as confined domains) are subject to executable and writeable memory checks. By default, subjects running in an unconfined domain can not allocate writeable memory and execute it. [I think I changed the meaning. Is it still correct? ]

Looks good

Quoted 3 lines
Quoted 3 lines

This reduces vulnerability to buffer overflow attacks. Some subjects require this access, including but not limited to Java", Wine and Mono. To allow this access, these subjects must be labeled correctly.

For example, if you had a java application /usr/local/bin/myjavaapp, that was not working because it needed the execmem access, you could change the system labeling.

# semanage fcontext -a -t java_exec_t /usr/local/bin/myjavaapp
Then you fix the context on the actual file
# restorecon /usr/local/bin/myjavaapp

myjavaapp will now be allowed to run with execmem and execstack.

If you do not want to deal with any of the memory checks for users, you can disable them with by setting the allow_exec* booleans.

# setsebool -P allow_execmem=1 allow_execstack=1 allow_execheap=1
You can check if the booleans current state by executing

getsebool -a | grep allow_exec

Quoted 11 lines

You system is most protected if these booleans are turned off.

# setsebool -P allow_execmem=0 allow_execstack=0 allow_execheap=0
Quoted 2 lines
Quoted 2 lines

memory checks need to be disabled for the users running in the unconfined_t domain.

No this sentence is wrong.
These memory checks are disable by setting

Quoted 3 lines
Quoted 2 lines

booleans, which allow the SELinux policy to be modified during runtime. Configuring booleans is discussed later.

I removed some bits to avoid too much theory:

Unconfined domains (as well as confined domains) are subject to executable and writeable memory checks. By default, subjects running in an unconfined domain can not allocate writeable memory and execute it. This reduces vulnerability to buffer overflow attacks. These memory checks are disable by setting booleans, which allow the SELinux policy to be modified during runtime. Configuring booleans is discussed later.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

How about:
When an unconfined subject is comprised, SELinux does not prevent the attacker from gaining access to system resources and data, and DAC rules
are used.
(I should probably change these to "If an...")

Quoted 6 lines

If an unconfined subject is comprised, SELinux does not prevent the attacker from gaining access to system resources and data, of course DAC rules are used.

Note: A common misconception about SELinux is that it replaces DAC Controls, when it really just augments them.

Quoted 6 lines

How about:

If an unconfined subject is compromised, SELinux does not prevent the attacker from gaining access to system resources and data, but of course, DAC rules are still used. SELinux is a security enhancement on top of DAC rules - it does not replace them.

Looks good.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

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

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

#18 lore raw
Quoted 6 lines · Daniel J Walsh
Quoted 5 lines · Stephen Smalley

As a reminder, users will derive the most benefit from actual practical HOWTO-style guidance you can give them on how to use SELinux and deal with issues that arise, not from a redux of introductory material on what SELinux is.

Quoted 6 lines

I agree, Most people are not looking into what SELinux does, but how do I make my system work without needing to disable SELinux

I believe conveying information like the following is critical.

http://danwalsh.livejournal.com/22347.html

Yes, I do not want to spend any more time on the intro, as I'm wasting everyone's time with it now.

I tried to include an intro because someone mentioned expanding the guide to include policy writing, so I wrongly assumed an intro to selinux would make that easier.

Let me know if you want anything removed.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.