![]() |
|
|||||||||||||||
|
||||||||||||||||
|
| Software security principles: Part 5 | ||||
| On keeping secrets, trusting others, and following the crowd
In this series, Gary and John present a set of 10 principles that can help you remove the majority of security problems from your code. Here, they finish up with the last three principles. First, they examine why you shouldn't expect to successfully hide secrets in your systems, at least not without great effort. Second, they emphasize that it's important to be wary of extending trust to anyone, including yourself. Third, they advise that when we do need to trust, it's sometimes a good idea to follow the herd. Principle 8: It's hard to hide secrets Many people assume that secrets in a binary are likely to stay secret, because it is too difficult to extract them. Yes, binaries are complex, but it's incredibly difficult to keep the "secrets" secret. One problem is that some people are actually quite good at reverse engineering binaries -- that is, pulling them apart, and figuring out what they do. This is why software copy protection schemes tend to be inadequate. Skilled hackers can generally circumvent any protection that a company tries to hard code into its software, and release "cracked" copies. For years, there was an escalation in the number of techniques being used; vendors would try harder to keep people from finding the secrets to "unlocking" software, and the software crackers would try harder to break the software. For the most part, the crackers won. Cracks for interesting software have been known to show up on the same day the software is officially released -- sometimes sooner. If your software all runs server-side on your own network, you might decide that your secrets are safe. Actually, it's much harder than that to hide secrets. You shouldn't trust your own network if you can avoid it. What if some unanticipated flaw permits an intruder to steal your software? This is what happened to Id software right before they released the first version of Quake. Even if your network is as secure as possible, your problems may lie within. Several studies have shown that the most common threat to companies is the "insider " attack, where a disgruntled employee abuses access. Sometimes the employee isn't even disgruntled; maybe he just takes his job home, where a friend goes prodding around where he shouldn't. Also, many companies would not be able to protect their preciously-guarded software from a malicious janitor. If people are intent on getting your software through illegal means, they will probably succeed. When we point out the possibility of an inside attack to people, they often respond, "That won't happen to us; we trust our employees." If you're thinking the same thing, you should be wary. Ninety percent of the people we talk to say the same thing, yet most attacks are perpetrated by insiders. There's a huge gap here; most of the people who believe they can trust their employees must be wrong. Remember, employees may like your environment, but when it comes down to it, most of them have a business relationship with your company, not a personal one. The moral here is that it pays to be paranoid. Sometimes people don't even need to reverse engineer software to figure out its secrets. These can often be discovered just from observing the software at work. For example, we (John Viega and Tim Hollebeek) once broke a simple cryptographic algorithm in the Netscape e-mail client simply by observing its behavior with a series of chosen inputs. (It was so easy to do that we were quoted as saying, "We didn't do this with just a pencil and paper. Lots of our notes are in pen. We didn't need to erase much.") More recently, E*Trade was the subject of a similar fiasco -- anyone could see your username and password as you logged in over the Web. The practice of trusting a binary (or any other form of obfuscation, for that matter) to keep secrets for you is affectionately termed "security by obscurity" (see Resources). Whenever possible, you should avoid using this as your sole line of defense. That doesn't mean that there is no place for security by obscurity. Denying access to the source code definitely raises the bar for an attacker -- somewhat. Obfuscating the code to produce an obfuscated binary helps even more. These techniques require that potential attackers posses more skill than they would otherwise need to actually break your system, and that is usually a good thing. On the flip side, most systems protected this way fail to go through an adequate security audit; there is something to be said for openness, which allows you to obtain free security advice from your users. Principle 9: Don't extend trust easily For example, while off-the-shelf software can certainly help you keep your designs and implementations simple, how do you know you can trust an off-the-shelf component to be secure? Do you really think the developers were security experts? Even if they were, do you expect them to be infallible? There have been tons of products from security vendors with gaping security holes. Many people in the security business don't actually know very much about writing secure code. Another place where trust is generally extended far too easily is in the area of customer support. Social engineering attacks are incredibly easy to launch against unsuspecting customer support agents, who have a proclivity to trust, because it makes their jobs easier. You should also be careful about "following the herd." Just because a particular security feature is standard doesn't mean you should provide the same poor level of protection. For example, we've often heard people opt not to encrypt sensitive data simply because their competitors weren't encrypting data. That won't be much of an excuse when customers get attacked, and then look to blame someone for being lax with security. You should be skeptical of security vendors, too. They very often spread shady or downright false information in order to sell their products. Generally, such "snake oil" peddlers work by spreading FUD -- Fear, Uncertainty, and Doubt. Many common warning signs can help you detect quacks. One of our favorites is the advertising of "million-bit keys" for a secret-key encryption algorithm. Mathematics tells us that 256 bits is likely to be sufficient to protect messages through the lifetime of the universe -- assuming the algorithm is of high quality. People advertising more know too little about cryptography to sell worthwhile security products. Before you finish your shopping, make sure to do your research. One good place to start is the "Snake Oil" FAQ (see Resources). You should also be reluctant to trust yourself and your organization. It's easy to be short-sighted when it comes to your own ideas and your own code. While you might like to be perfect, you should admit that you're not, and get a high-quality, objective outside perspective on what you're doing periodically. One final point to remember is that trust is transitive. Once you give it to an entity, you implicitly extend it to anyone that entity may trust. For this reason, trusted programs should never invoke untrusted programs. You should also be careful when determining which programs to trust; programs may have hidden functionality that you do not expect. For example, in the early '90s, one of us had a UNIX account with extremely limited, menu-driven functionality. You started out in the menu when you logged in, and could only perform simple operations, such as read and compose mail and news. The menu program trusted the mail program. The mail program would call out to an external editor (in this case, the "vi" editor) when the user was composing mail. When composing mail, the user could do some vi magic to run an arbitrary command. As it turned out, it was easy to leverage this implicit, indirect trust of the vi editor to get rid of the menu system altogether, in favor of a regular old unrestricted command-line shell. Principle 10: Trust the community For example, in cryptography it's considered a bad idea to trust any algorithm that isn't public knowledge and hasn't been widely scrutinized. There's no real solid mathematical proof of the security of most cryptographic algorithms; they're trusted only when a bunch of smart people spend a lot of time trying to break them, and all fail to make substantial progress. Many people find it alluring to write their own cryptographic algorithms, hoping that if these algorithms are weak, security by obscurity will serve as a safety net. Repeatedly, such hopes are dashed (for example, with the Netscape and E*Trade breaks mentioned above). The argument generally goes that a secret algorithm is better than a publicly-known one. We've already discussed how you should expect your algorithm not to stay secret for very long. For example, the RC4 encryption algorithm was supposed to be a trade secret of RSA Data Security. However, it was reverse engineered and posted on the Internet anonymously soon after its introduction. In fact, cryptographers design their algorithms so that knowledge of the algorithm is unimportant to security. Good cryptographic algorithms work because you keep a small secret called a "key," not because the algorithm is secret. That is, the only thing you need to keep private is the key. If you can do that, and the algorithm is actually good (and the key is long enough), then even an attacker who's intimately familiar with the algorithm will be unable to attack you. Similarly, it's far better to trust security libraries that have been widely used, and widely scrutinized. Sure, they might contain bugs that haven't been found -- but at least you get to leverage the experience of others. This principle only applies if you have reason to believe that the community is doing its part to promote the security of components you want to use. One common misconception is the belief that "open source" software is highly likely to be secure, because source availability will lead to people performing security audits. There's strong evidence to suggest that source availability doesn't provide the strong incentive for people to review source code, even though many people would like to believe that incentive exists. For example, many security bugs in widely-used, free software programs went unnoticed for years. In the case of the most popular FTP server around (WU-FTPD), several security bugs went unnoticed for more than a decade! Conclusion
Remember that it's important to apply good software risk management techniques when using these principles. You should only apply principles when such a strategy tells you that it is cost effective to do so. Also, these principles can sometimes work to contradictory ends, so such a strategy is even more crucial. Finally, we certainly don't expect that this set of principles will cover every situation you might encounter, but it should do a good job in general.
| ||||||||||||||||
| About IBM | Privacy | Terms of use | Contact |