Course contentsShow
← Linux
Lesson 1001 of 1,8199. Security Hardening and Mandatory Access ControlFree lesson

Handling Policy Exceptions via Delegation

Define secure methods for delegating specific administrative permissions to non-root users.

In this lesson, you will learn how to safely delegate specific administrative policy changes to non-root users without granting them full system control.

The Principle of Least Privilege Delegation

In a hardened environment, you often face a dilemma: a user or service needs to temporarily modify a security policy (like an AppArmor profile), but giving them root access or full sudo privileges creates an unacceptable security risk. "Handling Policy Exceptions via Delegation" solves this by creating granular, restricted pathways for policy adjustments.

Instead of broad permissions, we focus on delegation via controlled execution. By restricting a user to run only specific commands—and only with specific arguments—we can allow them to toggle or update security policies without exposing the entire system to their potential misuse.

Implementation via Sudoers

The most common method for delegation is utilizing the /etc/sudoers file to whitelist specific binaries or scripts. Suppose you have a junior administrator who needs to reload AppArmor profiles. Instead of ALL=(ALL) ALL, you define a strict rule:

# Allow the 'sec-admin' user to reload AppArmor profiles only
sec-admin ALL=(root) NOPASSWD: /sbin/apparmor_parser -r /etc/apparmor.d/*

This prevents the user from editing other system files or running arbitrary commands. However, to take this further, you should wrap the action in a sanitized wrapper script. By creating a script that performs input validation (e.g., ensuring the profile being reloaded is located in a specific directory and adheres to internal naming conventions), you add a layer of logic between the user's request and the actual kernel-level policy application.

Why This Matters

When you delegate these exceptions, you minimize "Policy Drift." If a user needs an exception, they don't have to bypass your security hardening; they use your defined "delegated lane." This keeps your security posture visible and auditable through logs (like auditd), ensuring that even when privileges are delegated, the chain of custody remains intact.

Key Takeaway: Secure delegation relies on narrowing the scope of administrative actions to specific, validated commands or scripts, ensuring that policy exceptions do not compromise the integrity of the overall MAC environment.