I am NOT going to discuss here the definitions and concept. I wanted to put it down, based in what i faced before on the Subject line and how I tackled. I came up with some predictable symptoms which will definitely help some one to get some hint and how to manage this crisis.
I always believed that along with the networks and server admins, - application developer should accommodate a module based on security aspects(necessary but NOT essential), so that the prevention preparation becomes a bit more collaborative. But while trying to meet the application/product deadline line, specially in start-up kinda company, somehow this gets overlooked.
Apache being the Leading web server, its vulnerability has always been worked upon continuously. So there should not be any scope left from our side too, to fine tune this guy so that it is strong enough to combat DoS/DDoS kind of attack.
If you are a web server administrator and see the following symptoms, i would advice you to be more detail about your log analysis:
Symptoms
I always believed that along with the networks and server admins, - application developer should accommodate a module based on security aspects(necessary but NOT essential), so that the prevention preparation becomes a bit more collaborative. But while trying to meet the application/product deadline line, specially in start-up kinda company, somehow this gets overlooked.
Apache being the Leading web server, its vulnerability has always been worked upon continuously. So there should not be any scope left from our side too, to fine tune this guy so that it is strong enough to combat DoS/DDoS kind of attack.
If you are a web server administrator and see the following symptoms, i would advice you to be more detail about your log analysis:
Symptoms
- if the sites are suddenly serving slow, despite any new business marketing boost etc.
- Lots of hanging processes, http://(Your-Apache-Admin-URL)
/server-status. Read More. - You see same set of ip's requesting more than needed -
netstat -punta | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n. - Server resource spike, with top command you see soaring high resource utilization.
- You are left with very less no. of connection to serve the real traffic, with some intermittent 5xx error.
And Finally You Are Left With,
- A hang server.
- Web site down/ intermittent service delivery .
- Gradually SSH also stops responding. (Lucky if you had already logged in!)
- Need for a mandatory reboot in order to restore access to the system.
Prevention Preparation:
- You should have a solid understanding of what is being served from your server, how much average rss memory consumtion per child, how much memory this server has, and based on that only you calculate the MPM settings. For ex.
#ps -ylC httpd --sort:rss | awk '{ sum = sum + $8 } END { print sum/NR }' ; doing so gave me 28422.2 = approx 28 MB , Hence my MPM settings should be in proportionate to the available share of RAM for this apache web server.Thus the appropriate setting for MaxSpareServers would help apache not to over consume and ultimately ending up onsuming ethe ntire available memory resource causing a systems OOM error and hang up permanently.
- Enable SYN COOKIES at the kernel level
echo 1 > /proc/sys/net/ipv4/tcp_syncookies,
along with this, lets also do a
echo 1 > /proc/sys/net/ipv4/tcp_keepalive_probes
echo 2 > /proc/sys/net/ipv4/tcp_synack_retries
echo 1 > /proc/sys/net/ipv4/tcp_syn_retries - Enable and Configure iptables to prevent the attack or at least work to identify the attack(this is regardless of apache specific, rather system wide)
/sbin/iptables -N syn-fld
/sbin/iptables -A syn-fld -m limit --limit 100/second --limit-burst 150 -j RETURN
/sbin/iptables -A syn-fld -j LOG --log-prefix "SYN fld: "
/sbin/iptables -A syn-fld -j DROP - Two must deploy tool,
mod_ipconnlimit and
mod_evasive module. - A fair knowledge of sed/awk/perl and regex shell tricks to do a quick analysis of your access logs.
- and the moment you identify some one(or even slightest suspect) drop all his request(across entire web cluster),
/sbin/iptables -A INPUT -p tcp -s
and later on, needless to say, don't forget to white list the same if it is NOT the culprit.
I will write more on MPM settings for better performance in coming days. , and steps for setting up mod_evasive and mod_ipconnlimit soon..
PS: I would be more than happy to get the opportunity to discuss your challenges, it will help us to understand various other aspects too.
Thanks & Cheers!
DEBU
No comments:
Post a Comment