Filipe Brandenburger
2008-Jun-06 23:03 UTC
[CentOS] Hardening CentOS by removing "hacker" tools
Hi, My boss asked me to harden a CentOS box by removing "hacker" tools, such as nmap, tcpdump, nc (netcat), telnet, etc. I would like to know which list of packages would you remove from a base install. I would appreciate if someone could point me to a "standard" way of doing this. I know there are procedures for hardening a machine (I remember reading about Bastille Linux) but I don't know how effective they are and if they include the removal of such tools in their procedures. Any advice would be very appreciated! Thanks, Filipe
Filipe Brandenburger wrote:> Hi, > > My boss asked me to harden a CentOS box by removing "hacker" tools, > such as nmap, tcpdump, nc (netcat), telnet, etc. > > I would like to know which list of packages would you remove from a > base install. I would appreciate if someone could point me to a > "standard" way of doing this. I know there are procedures for > hardening a machine (I remember reading about Bastille Linux) but I > don't know how effective they are and if they include the removal of > such tools in their procedures. >those are all client-side tools. if someone gains access to them, the box is already hacked. how exactly does that harden it? most all of those (certainly, nmap, tcpdump and telnet) are useful diagnostic tools for troubleshooting network connectivity issues.
Filipe Brandenburger wrote:> Hi, > > My boss asked me to harden a CentOS box by removing "hacker" tools, > such as nmap, tcpdump, nc (netcat), telnet, etc. > > I would like to know which list of packages would you remove from a > base install. I would appreciate if someone could point me to a > "standard" way of doing this. I know there are procedures for > hardening a machine (I remember reading about Bastille Linux) but I > don't know how effective they are and if they include the removal of > such tools in their procedures. > > Any advice would be very appreciated! > > Thanks, > Filipe > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >I don't think that removing these tools would make the box any more secure. If a hacker is able to get into the system through exploiting a service, he can download the necessary tools or compile them himself. I suggest to start setting up the firewall to only have the necessary ports open (which is usually already done), moving anything you can to a non standard port (especially things like ssh), and disabling any unneeded services. You would be surprised how many attacks a public server can get on standard ports like ssh. People will run scripts that will just try to bruteforce a password, and can lead to DOS attacks, especially on slower servers. There are also tools, such as the ones that rackspace installs, that stop port scans. They basically detect port scans and add a firewall rule to temporarily block that ip. Does anyone know what tool that is? Also disabling remote login as root should help. Russ
On Fri, 2008-06-06 at 19:03 -0400, Filipe Brandenburger wrote:> Hi, > > My boss asked me to harden a CentOS box by removing "hacker" tools, > such as nmap, tcpdump, nc (netcat), telnet, etc. > > I would like to know which list of packages would you remove from a > base install. I would appreciate if someone could point me to a > "standard" way of doing this. I know there are procedures for > hardening a machine (I remember reading about Bastille Linux) but I > don't know how effective they are and if they include the removal of > such tools in their procedures. > > Any advice would be very appreciated!Filipe, Have a search on google for NSA Hardening RHEL5, you will find a very good document (pdf) which will help you start you're hardening. Regards, Erik
Luke S Crawford
2008-Jun-06 23:54 UTC
[CentOS] Hardening CentOS by removing "hacker" tools
"Filipe Brandenburger" <filbranden at gmail.com> writes:> My boss asked me to harden a CentOS box by removing "hacker" tools, > such as nmap, tcpdump, nc (netcat), telnet, etc.Removing network tools does not make it harder to break into the box, however, it can make it harder to do something with it once you are in. removing those tools might help keep an infection from spreading, but it wont protect the box itself. (also, just installing the programs just means that if your box get compromised, the hacker needs to install some new packages. Not difficult, even without root- the attacker can install to the compromised user homedir.) It sounds like your boss doesn't know much about this. you have 2 choices... You can do what he says (largely useless.) or you can try to educate yourself (and your boss) on ways to actually make your systems more secure. I would advise the latter course, personally, - if the boss is a good boss, he will listen to his technical people. here are the basics: First, turn off all daemons you don't need. if it's not running, you don't need to worry if there is a security hole in it. I think a good firewall is useful... it saves your ass if you accidentally leave a daemon running that you don't need, or if the new guy starts up a demon that you weren't running before, or if you need a daemon to be accessibly to the office but not the world. use the centos iptables default setup- make sure you can take the box offline, then change the, default to 'reject' and then open things up one service at a time until your system works again. third, subscribe to the announce list for your distro- and check it every day. apply security updates immediately (you can't just do this with cron; some require reboots) also, make sure that PermitRootLogin is set to no in /etc/ssh/sshd_config - all of the successful brute-force attacks I've seen have been against the root user. Brute-forcing other users is more difficult, as the attacker (usually an automated process) needs to first obtain the username; if you watch /var/log/secure you see a lot more attempts at root than others. if you use applications that are not provided by your distro's standard distribution, subscribe to the mailing lists for those, as well. the idea being that the majority of hacks are known exploits... if you watch the mailing lists, you can at least solve the known problems soon after they become generally known. those are the minimum steps you need to take... it's thousands of times better than nothing. these are the 'easy' steps that get you a lot of security while minimally interfering with usability going beyond here, you must recognize that in the optimal case, there is a tradeoff between usability and security. this is the optimal case; sometimes you can make things less usable without increasing security. Beyond here, look at selinux, look at mounting all user-accessible partitions (/tmp, /home/ and /var) as noexec and ensuring that nobody but root can write anywhere else... - it doesn't help if you get rooted, but it makes things mildly more difficult for a local user to run a local root exploit. some people remove development tools, because many people transport exploit code as c source code to the box, compile it and then execute it. many other things can be done... but don't bother until you take down unnecessary demons, put up a firewall, subscribe to the announce lists for your distro, and disable remote root login.
On Fri, 6 Jun 2008, Filipe Brandenburger wrote:> Hi, > > My boss asked me to harden a CentOS box by removing "hacker" tools, > such as nmap, tcpdump, nc (netcat), telnet, etc. > > I would like to know which list of packages would you remove from a > base install. I would appreciate if someone could point me to a > "standard" way of doing this. I know there are procedures for > hardening a machine (I remember reading about Bastille Linux) but I > don't know how effective they are and if they include the removal of > such tools in their procedures. > > Any advice would be very appreciated! > > Thanks, > FilipeAssuming from the question that a) the box is already installed and b) the application for which it exists is installed via a well formed rpm... (Tell your boss the box or the app may go down unexpectedly while you're doing this. This will almost certainly happen if condition b) is not met. And the app may not come back up right when you reboot the box or restart the app. Definitely schedule a power cycle or two for after you think you're done. Maybe freshen up your resume too. Probably should mention to the boss that if the app has gone through any internal certification process, you are probably going to invalidate it and he needs to talk to the development/enduser folks to schedule a recert.) rpm -qa | sort > rpm.lst look at the list, anything you don't know what it is, rpm -qi. Season with a liberal dose of "man -k package;man <something" and "less /usr/share/doc/<package>" If you think you probably don't need it yum erase. If it doesn't try to erase the application or something else necessary (like ssh or the kernel), say yes. Use yum not rpm so you have a record in /var/log/yum.log of what you did. Maybe start a screen session with history or a typescript session. Read everything c.a.r.e.f.u.l.l.y and slowly. Don't multitask. If you're really paranoid (twitch, twitch), run your application test suite after each deletion (you do have a test suite, right???). Better, google for "tiny centos" and build a new box with the minimum on it. Then get the well formed application rpm from the vendor (evil laughter), put it in a local repository and use yum to install it and it's dependencies. And do all the firewall, selinux, hosts.{allow,deny} and NSA stuff too. ------------------------------------------------------------------------ Jim Wildman, CISSP, RHCE jim at rossberry.com http://www.rossberry.com "Society in every state is a blessing, but Government, even in its best state, is a necessary evil; in its worst state, an intolerable one." Thomas Paine