Introduction to Security Based on *nix Systems

Cloned Boy

Professional
Messages
877
Reaction score
700
Points
93
Unix-like systems (Linux, macOS, BSD, etc.) are widely used in servers, networking, and security-critical environments due to their robust permission model, open-source transparency, and strong security heritage. Below is a breakdown of core security concepts in *nix systems.

1. Fundamental Security Principles​

*nix systems follow several key security principles:
  • Principle of Least Privilege → Users and processes should have only the minimum permissions needed.
  • Defense in Depth → Multiple layers of security (firewalls, permissions, encryption).
  • No Default Trust → Everything must be authenticated and authorized.

2. Core nix Security Mechanisms

A) User & Permission Model​

  • Users & Groups
    • Every process runs under a user (root = superuser).
    • Groups allow permission sharing (e.g., www-data for web servers).
  • File Permissions (chmod, chown)
    • Read (r), Write (w), Execute (x) for Owner, Group, Others.
    • Example: -rwxr-xr-- (Owner: read/write/execute, Group: read/execute, Others: read-only).
  • SUID, SGID, Sticky Bits
    • SUID → Runs a file as its owner (e.g., passwd runs as root).
    • SGID → Runs a file with group privileges.
    • Sticky Bit → Only owner can delete/modify files in a directory (e.g., /tmp).

B) Access Control Lists (ACLs)​

  • Extends traditional permissions for finer control.
  • Example:
    sh
    Code:
    setfacl -m u:alice:rwx /shared_folder # Grants Alice full access
    getfacl /shared_folder                 # Shows ACL permissions

C) Mandatory Access Control (MAC) Systems​

  • SELinux (Security-Enhanced Linux)
    • Enforces strict policies (e.g., a web server can’t access /home).
  • AppArmor
    • Profile-based restrictions (e.g., only allow /usr/bin/nginx to read /var/www).

D) Process Isolation & Sandboxing​

  • Namespaces → Isolates processes (filesystem, network, PID).
  • cgroups → Limits resource usage (CPU, memory).
  • Containers (Docker, LXC) → Combines namespaces + cgroups for lightweight virtualization.

E) Secure Authentication​

  • Shadow Passwords (/etc/shadow) → Hashed passwords (SHA-512, bcrypt).
  • SSH Key Authentication → Uses RSA/ECDSA keys instead of passwords.
  • PAM (Pluggable Authentication Modules) → Flexible auth policies (2FA, LDAP).

F) Logging & Auditing​

  • syslog / journalctl (systemd) → System logs.
  • auditd → Tracks file access, system calls (for compliance).
  • fail2ban → Blocks brute-force attacks (SSH, FTP).

3. Common nix Security Tools

ToolPurpose
iptables/nftablesFirewall (packet filtering, NAT).
OpenSSHSecure remote access (replace Telnet/FTP).
GPGFile & email encryption.
ClamAVMalware scanning.
Tripwire/AIDEFile integrity monitoring (detect unauthorized changes).
SELinux/AppArmorMandatory access control.
LynisSecurity auditing tool.

4. Best Practices for nix Security]​

  1. Minimal Installation → Only install necessary services.
  2. Regular Updates → Patch OS and software (apt update && apt upgrade).
  3. Disable Root SSH Login → Use sudo instead.
  4. Firewall Rules → Block unnecessary ports (iptables -A INPUT -p tcp --dport 22 -j ACCEPT).
  5. Disable Unused Services → Stop telnet, ftp, rlogin.
  6. Use SSH Keys + 2FA → Disable password-based SSH.
  7. Encrypt Sensitive Data → Use LUKS (disk encryption) or GPG (files).
  8. Monitor Logs → Check /var/log/auth.log, journalctl -u sshd.

5. Attack Vectors & Mitigations​

AttackDefense
Brute-Force SSHFail2ban, key-based auth, rate limiting.
Privilege EscalationSELinux, minimal sudo access, regular audits.
Malware/RootkitsClamAV, rkhunter, signed packages.
Misconfigured ServicesLynis, hardening guides (CIS benchmarks).
Unencrypted DataFull-disk encryption (LUKS), HTTPS, VPNs.

Final Thoughts​

*nix systems are inherently secure but require proper configuration. Key takeaways:
  • Principle of Least Privilege → Limit root access.
  • Hardening → Firewalls, MAC (SELinux/AppArmor), encryption.
  • Monitoring → Logs, intrusion detection (AIDE, auditd).

Would you like a deeper dive into a specific area (e.g., SELinux, SSH hardening, or container security)?
 
Top