Day 05: SElinux Installation and Configuration

Question:

Following a security audit, the xFusionCorp Industries security team has opted to enhance application and server security with SELinux. To initiate testing, the following requirements have been established for App server 2 in the Stratos Datacenter:

  1. Install the required SELinux packages.
  2. Permanently disable SELinux for the time being; it will be re-enabled after necessary configuration changes.
  3. No need to reboot the server, as a scheduled maintenance reboot is already planned for tonight.
  4. Disregard the current status of SELinux via the command line; the final status after the reboot should be disabled.


Explanation:

1. Discretionary Access Control (DAC) – Used in linux by default

This type of access control lets the resource owner set the permissions who can read, write, or execute the resource.

Categories: Permissions are divided into three groups:

  • Owner (u): The user who created or owns the item.
  • Group (g): A set of users assigned to share the item.
  • Others (o): Everyone else on the system.

2. Mandatory Access Control

SElinux uses Mandatory Access Control. It is an extra layer of security that you can have above the kernel. Access decisions are governed completely by system-wide security policies and administrators rather than individual file owners.

Every user (subject) is assigned a clearance level and every resource (object) is assigned a corresponding sensitivity label. Regular users cannot change permissions, share files, or override the rules. If a user’s clearance does not match or exceed the resource’s label, access is automatically blocked.

Now lets go to the challenge.


Solution:

1. Install the required SELinux packages.

# SSH to app server 2
ssh steve@stapp02

# Get system info
uname -v
#96~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 16 13:19:05 UTC 2

# Check which package manager the system uses
which apt
/usr/bin/which: no apt in (/home/steve/.local/bin:/home/steve/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)

which dnf
/usr/bin/dnf

# Install the required packages for SELinux
sudo dnf install selinux-policy selinux-policy-targeted libselinux-utils policycoreutils

# After install you can check this file. By default SELINUX variable is set to enforcing
cat /etc/selinux/config
...
SELINUX=enforcing

2. Permanently disable SELinux for the time being;

sudo setenforce 0
setenforce: SELinux is disabled

3. No need to reboot the server

SELinux needs a reboot to scan all files on the system and the security controls. But in the challenge they say don’t do the reboot now itself.

4. Check the current status

sestatus
SELinux status:                 disabled

Remember google is your friend 🙂

References

https://www.akamai.com/cloud/guides/how-to-install-selinux-on-ubuntu-22-04/#how-to-disable-selinux

By shafdo

Leave a Reply

Your email address will not be published. Required fields are marked *