After reading this question on a server compromise, I started to wonder why people continue to seem to believe that they can recover a compromised system using detection/cleanup tools, or by just fixing the hole that was used to compromise the system.
Given all the various root kit technologies and other things a hacker can do most experts suggest you should reinstall the operating system.
I am hoping to get a better idea why more people don't just take off and nuke the system from orbit.
Here are a couple points, that I would like to see addressed.
- Are there conditions where a format/reinstall would not clean the system?
- Under what types conditions do you think a system can be cleaned, and when must you do a full reinstall?
- What reasoning do you have against doing a full reinstall?
- If you choose not to reinstall, then what method do you use to be reasonably confident you have cleaned and prevented any further damage from happening again.
A security decision is ultimately a business decision about risk, just as is a decision about what product to take to market. When you frame it in that context, the decision to not level and reinstall makes sense. When you consider it strictly from a technical perspective, it does not.
Here's what typically goes into that business decision:
And therefore, when you add up the costs like those, it may be deemed that continuing with a "potentially" still-compromised system is better than reinstalling the system.
Based on a post I wrote ages ago back when I could still be bothered to blog.
This question keeps being asked repeatedly by the victims of hackers breaking into their web server. The answers very rarely change, but people keep asking the question. I'm not sure why. Perhaps people just don't like the answers they've seen when searching for help, or they can't find someone they trust to give them advice. Or perhaps people read an answer to this question and focus too much on the 5% of why their case is special and different from the answers they can find online and miss the 95% of the question and answer where their case is near enough the same as the one they read online.
That brings me to the first important nugget of information. I really do appreciate that you are a special unique snowflake. I appreciate that your website is too, as it's a reflection of you and your business or at the very least, your hard work on behalf of an employer. But to someone on the outside looking in, whether a computer security person looking at the problem to try and help you or even the attacker himself, it is very likely that your problem will be at least 95% identical to every other case they've ever looked at.
Don't take the attack personally, and don't take the recommendations that follow here or that you get from other people personally. If you are reading this after just becoming the victim of a website hack then I really am sorry, and I really hope you can find something helpful here, but this is not the time to let your ego get in the way of what you need to do.
You have just found out that your server(s) got hacked. Now what?
Do not panic. Absolutely do not act in haste, and absolutely do not try and pretend things never happened and not act at all.
First: understand that the disaster has already happened. This is not the time for denial; it is the time to accept what has happened, to be realistic about it, and to take steps to manage the consequences of the impact.
Some of these steps are going to hurt, and (unless your website holds a copy of my details) I really don't care if you ignore all or some of these steps but doing so will make things better in the end. The medicine might taste awful but sometimes you have to overlook that if you really want the cure to work.
Stop the problem from becoming worse than it already is:
Still hesitating to take this last step? I understand, I do. But look at it like this:
In some places you might well have a legal requirement to inform the authorities and/or the victims of this kind of privacy breach. However annoyed your customers might be to have you tell them about a problem, they'll be far more annoyed if you don't tell them, and they only find out for themselves after someone charges $8,000 worth of goods using the credit card details they stole from your site.
Remember what I said previously? The bad thing has already happened. The only question now is how well you deal with it.
Understand the problem fully:
Make a plan for recovery and to bring your website back online and stick to it:
Nobody wants to be offline for longer than they have to be. That's a given. If this website is a revenue generating mechanism then the pressure to bring it back online quickly will be intense. Even if the only thing at stake is your / your company's reputation, this is still going generate a lot of pressure to put things back up quickly.
However, don't give in to the temptation to go back online too quickly. Instead move with as fast as possible to understand what caused the problem and to solve it before you go back online or else you will almost certainly fall victim to an intrusion once again, and remember, "to get hacked once can be classed as misfortune; to get hacked again straight afterward looks like carelessness" (with apologies to Oscar Wilde).
Reducing the risk in the future.
The first thing you need to understand is that security is a process that you have to apply throughout the entire life-cycle of designing, deploying and maintaining an Internet-facing system, not something you can slap a few layers over your code afterwards like cheap paint. To be properly secure, a service and an application need to be designed from the start with this in mind as one of the major goals of the project. I realise that's boring and you've heard it all before and that I "just don't realise the pressure man" of getting your beta web2.0 (beta) service into beta status on the web, but the fact is that this keeps getting repeated because it was true the first time it was said and it hasn't yet become a lie.
You can't eliminate risk. You shouldn't even try to do that. What you should do however is to understand which security risks are important to you, and understand how to manage and reduce both the impact of the risk and the probability that the risk will occur.
What steps can you take to reduce the probability of an attack being successful?
For example:
What steps can you take to reduce the consequences of a successful attack?
If you decide that the "risk" of the lower floor of your home flooding is high, but not high enough to warrant moving, you should at least move the irreplaceable family heirlooms upstairs. Right?
... And finally
I've probably left out no end of stuff that others consider important, but the steps above should at least help you start sorting things out if you are unlucky enough to fall victim to hackers.
Above all: Don't panic. Think before you act. Act firmly once you've made a decision, and leave a comment below if you have something to add to my list of steps.
Always nuke it from orbit. It's the only way to be sure.
(source: flickr.com)
Most systems are holistic entities that have an inner, implicit trust. Trusting a compromised system is an implicit statement that you trust whomever did the breach of your system to begin with. In other words:
You can't trust it. Don't bother with cleaning. Disconnect and isolate the machine immediately. Understand the nature of the breach before you proceed, otherwise you invite the same thing all over again. Try, if possible, to get the date and time of the breach, so you have a frame of reference. You need this because if you restore from backup, you need to be sure that the backup itself doesn't have a copy of the compromise on it. Wipe before you restore - do not take shortcuts.
Practically speaking, most people don't do it because they think it'll take too long or be too disruptive. I've advised countless clients of the likelihood of continuing problems, but a reinstall is often shot down by a decision maker for one of those reasons.
That being said, on systems where I'm confident that I know the entry method and the full extent of the damage (solid off-machine logs, typically with an IDS, perhaps SELinux or something similar limiting the scope of the intrusion), I have done a cleanup without reinstall without feeling too guilty.
Most likely they don't have a disaster recovery routine that is tested enough for them to feel confident in doing a rebuild, or it's unclear how long it would take or what the impact would be... or backups are unreliable or their risk analysts don't understand the scope of a compromised system. I can think of many reasons.
I'd say it's mostly something amiss in the basic routines and policies and that is not something you'd want to admit openly - and instead you take a defensive stance. At least I can't see or defend not wiping a compromised system no matter what angle you look at it.
I have previous not nuked the system so that I can do some analysis of the vector that they came in on and subsequent anaylysis of the use and to see where they got to inside.
Once you have been rooted - you have a live honeypot and it can offer much more than just the hack. - especially for the police.