Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Fortifying CentOS Against Common Security Threats

Tech 1

Social engineering involves deception where attackers impersonate trusted entities to trick users into revealing credentials or sensitive data.

Malicious login attempts often utilize automated tools for brute-force or dictionary attacks against user account passwords.

Sensitive information exposure can occur due to misconfigurations or improper file permissions, allowing unauthorized access to critical data.

Web application vulnerabilities like SQL injection and cross-site scripting enable attackers to bypass security controls and execute malicious operations.

Buffer overflow attacks exploit software flaws by inputting data exceeding buffer capacity, overwriting adjacent memory to execute arbitrary code.

Implementing Security Countermeasures

Strengthening System Access Controls

Enforce Strong Password Policies

  • Require complex passwords with uppercase, lowercase, digits, and special charatcers
  • Set minimum password length to at least 12 characters
  • Block common predictable passwords like sequential patterns
  • Mandate periodic password rotation

Disable Unnecessary Services

  • Use systemctl to stop and disable unused network services:
sudo systemctl disable vsftpd.service
sudo systemctl stop vsftpd.service
  • Remove unnecessary packages to reduce attack surface:
sudo yum remove telnet-server rsh-server

Secure SSH Configuration

  • Edit /etc/ssh/sshd_config with these settings:
PermitRootLogin no
Port 2222
PubkeyAuthentication yes
PasswordAuthentication no
MaxAuthTries 3
ClientAliveInterval 300
  • Restart SSH service after modifications:
sudo systemctl restart sshd

Implement Access Control Lists

  • Set granular permissions on sensitive directories:
sudo setfacl -m u:webadmin:rx /var/www/html
sudo setfacl -m g:developers:rw /opt/app/config
  • Verify ACL settings:
getfacl /etc/shadow

Maintaining System Updates

Automate Security Updates

  • Configure automatic updates with yum-cron:
sudo yum install yum-cron
sudo systemctl enable yum-cron
  • Customize update settings in /etc/yum/yum-cron.conf

Manage Package Sources

  • Verify repository GPG keys:
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  • Check for available updates:
sudo yum check-update --security

Configuring Network Security

Firewall Configuration with firewalld

  • Create custom zones for different network segments:
sudo firewall-cmd --new-zone=internal --permanent
sudo firewall-cmd --zone=internal --add-source=192.168.1.0/24 --permanent
  • Configure port-based rules:
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --zone=public --remove-port=23/tcp --permanent

Network Service ACLs

  • Configure Nginx access controls:
location /admin {
    allow 10.0.0.0/8;
    deny all;
}

SELinux Enforcement

  • Check current SELinux status:
sudo sestatus -v
  • Modify file context for web directories:
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/srv/webapp(/.*)?"
sudo restorecon -R /srv/webapp
  • Generate SELinux policy modules for custom appplications:
sudo audit2allow -a -M myapp
sudo semodule -i myapp.pp

Monitoring and Log Management

Centralized Logging with rsyslog

  • Configure remote log aggregation in /etc/rsyslog.conf:
*.* @logserver.example.com:514
  • Create custom log templates:
template(name="RemoteLog" type="string" string="%TIMESTAMP% %HOSTNAME% %syslogtag%%msg%")

Intrusion Detection with Suricata

  • Install and configure Suricata IDS:
sudo yum install suricata
sudo suricata-update
  • Monitor network interfaces:
sudo suricata -c /etc/suricata/suricata.yaml -i eth0
  • Review alert logs:
sudo tail -f /var/log/suricata/fast.log

Data Protection Strategies

File Encryption with OpenSSL

  • Encrypt configuration files:
openssl enc -aes-256-cbc -pbkdf2 -in app.conf -out app.conf.enc
  • Create decryption script:
#!/bin/bash
openssl enc -d -aes-256-cbc -pbkdf2 -in $1.enc -out $1

Automated Backups with rsync

  • Schedule incremental backups:
rsync -avz --delete --link-dest=/backup/previous /data/ /backup/current/
  • Create backup rotation script:
#!/bin/bash
mv /backup/current /backup/$(date +%Y%m%d)
ln -sfn /backup/$(date +%Y%m%d) /backup/previous

Filesystem Encryption

  • Encrypt swap partition:
sudo cryptsetup luksFormat /dev/sdb2
sudo cryptsetup luksOpen /dev/sdb2 swapcrypt
sudo mkswap /dev/mapper/swapcrypt
  • Configure ancrypted volumes in /etc/crypttab

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.