Repository navigation
Cloud and Container Hardening
Heisenbug edited this page Mar 5, 2026
·
1 revision
Home · Security Features Guide
- Strategies for deploying CSF in cloud-native and containerized environments.
- Managing the interplay between Cloud Security Groups (SG) and host-level CSF.
- Handling kernel module constraints in restricted environments (Docker, LXC, Podman).
In cloud environments (AWS, Azure, GCP, DigitalOcean), you have two layers of defense.
| Layer | Control Point | Scope | Best Use |
|---|---|---|---|
| Cloud SG | Network Infrastructure | Perimeter / Subnet | Broad port blocks, VPC-wide policy |
| CSF | OS / Host Level | Instance | Deep packet inspection, LFD (brute-force), rate limiting |
Recommended Strategy: "Defense in Depth"
- Restrict at SG first: Block everything at the cloud level except what is absolutely necessary.
- Refine at CSF: Use CSF for login failure detection (LFD), temporary blocks, and process tracking which Cloud SGs cannot see.
- Synchronization: If CSF blocks an IP, it only protects that specific instance. For VPC-wide blocks, consider using a centralized API-driven blocklist that updates Cloud SGs.
CSF and Docker both manipulate iptables rules, which can lead to conflicts.
By default, Docker bypasses many host-level firewall rules by inserting its own chains at the top.
-
Problem: A
csf -d IPmight not block traffic to a Docker container because Docker'sFORWARDrules take precedence. -
Solution: If your CSF version supports Docker-aware settings, enable them; otherwise explicitly manage policy in the
DOCKER-USERchain. -
Best Practice: Use
csf.allowandcsf.denyfor the host, but be aware that container-bound traffic may need explicit rules in theFORWARDchain.
Many container environments do not allow the guest to load kernel modules.
-
Common Error:
FATAL: Could not load /lib/modules/... -
Check: Run
perl /etc/csf/csftest.plinside the container. -
Fix: If
ipt_LOGorxt_conntrackare missing, some CSF features (like logging or connection limit) will fail. You must enable these on the host node for the guest to use them.
CSF is a standalone firewall manager. It must not run alongside UFW or firewalld.
-
Risk: Race conditions for
iptableslocks, conflicting rule sets, and unpredictable "shadow" rules. -
Action: Disable/mask other managers before enabling CSF:
systemctl stop ufw && systemctl disable ufw systemctl stop firewalld && systemctl disable firewalld
If your environment has a control panel integration (cPanel/InterWorx/CWP/DirectAdmin), avoid mixed ownership of firewall state.
- Risk: panel-side writes can overwrite or conflict with manual CLI/file edits.
- Rule: choose one source of truth for routine changes (panel workflow or managed files/automation).
- Practice: reserve direct CLI edits for emergency operations, then reconcile them back into the primary workflow.
Cloud instances often rely on a single public IP for management.
- Always use TESTING="1" during initial setup.
-
Bootstrap via User-Data: When spinning up instances via IaC, ensure your admin IP is injected into
csf.allowimmediately. -
OOB Access: Ensure you have access to the cloud provider's serial console (for example provider serial/console features) before enabling
TESTING="0".
Last reviewed: 2026-03-04
- Security Features Guide
- Cloud & Container Hardening
- Automation & IaC
- IPv6 Deployment & Hardening
- IP Block Lists
- Reference Map
- Introduction
- csf Principles
- lfd Principles
- csf CLI Options
- lfd CLI Options
- Login Tracking
- Regex Custom Cookbook
- Script Email Alerts
- Process Tracking
- Directory Watching
- Advanced Filters
- Multiple Ethernet
- Generic Linux
- FTP Issues
- Messenger Service
- Block Reporting
- Port Flood
- Pre/Post Scripts
- Port Knocking
- Connection Limit
- Port/IP Redirect
- Integrated UI
- RESTRICT_SYSLOG
- Exim SMTP AUTH
- UI Skinning
- InterWorx
- CentOS Web Panel