🚧Linux SELinux Labs

🚧 Under Construction!!

🎯 Objective

Learn how SELinux works, how to manage policies, and how to troubleshoot denials using native Linux systems.


🧰 Prerequisites

  • Linux system with SELinux enabled (e.g., Fedora, RHEL, CentOS, Rocky Linux)

  • Root or sudo access

  • Basic Linux command-line knowledge

πŸ› οΈ Confirm SELinux is enabled

sestatus

βœ… Expected Output:

SELinux status:                 enabled
Current mode:                   enforcing

πŸ”Ή Lab 1: View SELinux Contexts

1.1 Check the context of files and processes

βœ… Expected: SELinux contexts like system_u:object_r:etc_t:s0.


πŸ”Ή Lab 2: Switch to Permissive Mode

2.1 Temporarily set SELinux to permissive

βœ… SELinux logs denials but does not block access.

2.2 Set it back to enforcing


πŸ”Ή Lab 3: Create a Policy Violation and Examine Logs

3.1 Create a file and change its context

3.2 View denials (from a non-httpd process context)

βœ… SELinux should block improper access attempts.


πŸ”Ή Lab 4: Restore Default SELinux Contexts

4.1 Reset file label using restorecon

βœ… Expected: File context is restored to default.


πŸ”Ή Lab 5: View and Use Boolean Flags

5.1 List SELinux booleans

5.2 Enable boolean for FTP access

βœ… Allows FTP daemons to access user home directories.


πŸ”Ή Lab 6: Analyze and Troubleshoot SELinux Denials

6.1 Analyze recent denials

βœ… Expected: Explanation of SELinux blocks.

6.2 Create and apply a custom policy (optional)

βœ… Creates and loads a custom module to allow specific actions.


βœ… Wrap-Up

  • You viewed SELinux labels and processes.

  • You worked with permissive and enforcing modes.

  • You restored contexts and managed booleans.

  • You analyzed and handled policy violations with custom rules.


Last updated