As a follow-up to my recent post on security, I thought that I’d write up a few quick thoughts about compromised web servers. In this scenario, let’s assume that I’ve managed to gain administrator privileges on your web server. If this is in fact the case then it’s game over. Let’s consider why.
With administrator privileges, I can replace any and all code that is running on your web server. This includes, for example, code that handles login requests. I could replace your login.aspx page and wait for an administrator to log in. Once I have that administrator’s password, I have compromised your application.
Let’s say that you placed some countermeasures on your system. Your login handler is digitally signed, and the authentication sub-system of your web application makes a StrongNamePermission demand against all callers. This means that I can’t capture passwords in the login handler anymore. In this case I’d simply replace the code in your authentication sub-system. While this is harder than just replacing a login.aspx page, it can still be done since I’m an administrator on your web server.
If I were a script-kiddie who lacked the sophistication to replace the code in your authentication sub-system, I could simply replace mscoree.dll with one that was built from, say, the Rotor sources. This would allow me to circumvent all code-access security countermeasures in your software. Note that I don’t need to create the hacked mscoree.dll, I just need to know where I can find a copy. Now I can simply replace your login handler with a standard one from my hacker toolkit.
What this really calls out for is a digital rights management solution. You could imagine buying a computer in the future which has been spec’d by the manufacturer to only execute code that was digitally signed using one of an approved set of public keys / public key tokens that you provide. To hack this computer would require physical access which raises the bar considerably.
Hopefully I’ve convinced you that you can’t defend against a compromised administrator account. Another scenario to consider that hasn’t gotten much publicity is that of a rogue developer. I’ll write some thoughts about this scenario later.
2 archived reader comments
Joseph E Shook (2004-02-27)
One way to mitigate such a threat is via the combination of least privilege policies and monitoring. The act of logging on as administrator could be out of the norm. Runas techniques should be used whenever possible during administration. A compromised machine can turn off logging of course. Just the act of logging on as administrator can be logged. This leaves some food for thought. I wonder if I truly can capture an administrator logging on before a bad guy has a chance to delete the log. That is if I have a way to log remotely. Which off the top of my head I do not know if that is possible. I know there are tools for collecting logs centrally but I don�t know if they are built to push logs and if the monitor would notice the absence of logs, maybe through a heart beat technique. Still holes can be punched in this also but it is something to think about.
John Lam (2004-02-27)
The act of erasing the security log generates an entry in the log. So you can definitely tell if someone has erased the security log - which should be a red flag.
Other tools periodically scan the logs on a computer for anomalous behavior. Microsoft Operations Manager is one tool that does exactly this.