Writing Secure Code

Most programmers think that once data gets dropped on the network, it will be very hard for an attacker to do anything nefarious to it, besides maybe read it. Often, the developer doesnt worry about network-level confidentiality because it hasnt been an explicit requirement from customers. But, there are tools out there that can redirect traffic and even give the attacker the ability to manipulate the data stream.

The mental model most people have is that data gets sent upstream too quickly for an attacker to get in the middle, then it goes from router to router where it is safe. Those programmers who have switches on their networks often feel more confident that there wont be an issue.

In the real world, if attackers have a foothold on the local LAN for either side of a communication, they can have a good shot of launching a network-based attack, taking advantage of the lack of security in the underlying infrastructure. If the attackers are on the same shared network segment as one of the endpoints (for example, attached to a hub), they see all traffic on that segment, and can usually arrange to intercept it all. Even if the attackers are plugged into a switch (a hub where the individual ports dont see each others traffic), theres a technique called Address Resolution Protocol (ARP) spoofing, where attackers pretend to be the gateway and redirect all traffic to themselves . They can then send out the traffic after processing it. There are several other techniques that work, too. For example, some switches can be ARP-flooded into promiscuous mode where they basically end up acting like hubs.

How does this work? ARP is a protocol for mapping layer 2 (Ethernet MAC) addresses to layer 3 (IP) addresses. Attackers simply advertise their MAC addresses as ones bound to the gateway IP. Once machines see the change, they will start routing all their IP traffic through an attacker. This problem doesnt have a practical and universal short- term fix, because there need to be fundamental services at the Ethernet level that are only now starting to be discussed within standard bodies. Oh, and these problems all get worse on most wireless networks.

Even at the router level, its probably not safe to assume that there are no attack vectors. Popular routers tend to be large, complex C programs, and they can be susceptible to buffer overflows and other issues that would allow an attacker to run arbitrary code on a router. Until router vendors implement technologies to make such catastrophic consequences more or less impossible , this will continue to be a risk. And, indeed, there have been buffer overflows in routers before. See, for example, from the Common Vulnerabilities and Exposures (CVE) dictionary (at http://cve.mitre.org): CVE-2002-0813, CVE- 2003-0100, and CAN-2003-0647.

Network attacks can take a wide variety of forms:

If youre worried about the security of your network connections, you should know what kinds of services its reasonable to expect applications to provide. Well talk about those basic services here, then talk about how to achieve those goals in the Redemption Steps section. Anyway, in order to protect against these kinds of attacks, you will generally want to provide three basic security services:

Категории