Home > Articles > Security > Network Security

Security Review of Protocols: The Upper Layers

  • Print
  • + Share This
Security pros Cheswick, Bellovin, and Rubin take a look at the upper layers of the TCP/IP protocol suite and touch on the highlights of the many applications that have security implications, including messaging, FTP, remote login, SNMP, and lots more.
This chapter is from the book

If you refer to Figure 2.1, you'll notice that the hourglass gets wide at the top, very wide. There are many, many different applications, most of which have some security implications. This chapter just touches the highlights.

3.1 Messaging

In this section, we deal with mail transport protocols. SMTP is the most common mail transport protocol—nearly every message is sent this way. Once mail has reached a destination spool host, however, there are several options for accessing that mail from a dumb server.

3.1.1 SMTP

One of the most popular Internet services is electronic mail. Though several services can move mail on the net, by far the most common is Simple Mail Transfer Protocol (SMTP) [Klensin, 2001].

Traditional SMTP transports 7-bit ASCII text characters using a simple protocol, shown below. (An extension, called ESMTP, permits negotiation of extensions, including "8-bit clean"-transmission; it thus provides for the transmission of binary data or non-ASCII character sets.) Here's a log entry from a sample SMTP session (the arrows show the direction of data flow):

<--- 220 fg.net SMTP
---> HELO sales.mymegacorp.com
<--- 250 fg.net
---> MAIL FROM:<Anthony.Stazzone@sales.mymegacorp.com>
<--- 250 OK
---> RCPT TO:<ferd.berfle@fg.net>
<--- 250 OK
---> DATA
<--- 354 Start mail input; end with <CRLF>.<CRLF>
---> From: A.Stazzone@sales.mymegacorp.com
---> To: ferd.berfle@fg.net
---> Date: Thu, 27 Jan 94 21:00:05 EST
---> Meet you for lunch after I buy some power tools.
---> Anthony
---> .
<--- 250 OK
.... sales.mymegacorp.com!A.Stazzone sent 273 bytes to fg.net!ferd.berfle
---> QUIT
<--- 221 sales.mymegacorp.com Terminating

Here, the remote site, SALES.MYMEGACORP.COM, is sending mail to the local machine, FG.NET. It is a simple protocol. Postmasters and hackers learn these commands and occasionally type them by hand.

Notice that the caller specified a return address in the MAIL FROM command. At this level, there is no reliable way for the local machine to verify the return address. You do not know for sure who sent you mail based on SMTP. You must use some higher level mechanism if you need trust or privacy.

An organization needs at least one mail guru. It helps to concentrate the mailer expertise at a gateway, even if the inside networks are fully connected to the Internet. This way, administrators on the inside need only get their mail to the gateway mailer. The gateway can ensure that outgoing mail headers conform to standards. The organization becomes a better network citizen when there is a single, knowledgeable contact for reporting mailer problems.

The mail gateway is also an excellent place for corporate mail aliases for every person in a company. (When appropriate, such lists must be guarded carefully: They are tempting targets for industrial espionage.) From a security standpoint, the basic SMTP by itself is fairly innocuous. It could, however, be the source of a denial-of-service (DOS) attack, an attack that's aimed at preventing legitimate use of the machine. Suppose we arrange to have 50 machines each mail you 1000 1 MB mail messages. Can your systems handle it? Can they handle the load? Is the spool directory large enough?

The mail aliases can provide the hacker with some useful information. Commands such as VRFY <postmaster> VRFY <root> often translate the mail alias to the actual login name. This can provide clues about who the system administrator is and which accounts might be most profitable if successfully attacked. It's a matter of policy whether this information is sensitive or not. The finger service, discussed in Section 3.8.1, can provide much more information.

The EXPNsubcommand expands a mailing list alias; this is problematic because it can lead to a loss of confidentiality. Worse yet, it can feed spammers, a life form almost as low as the hacker.

A useful technique is to have the alias on the well-known machine point to an inside machine, not reachable from the outside, so that the expansion can be done there without risk.

The most common implementation of SMTP is contained in sendmail [Costales, 1993]. This program is included free in most UNIX software distributions, but you get less than you pay for. Sendmail has been a security nightmare. It consists of tens of thousands of lines of C and often runs as root. It is not surprising that this violation of the principle of minimal trust has a long and infamous history of intentional and unintended security holes. It contained one of the holes used by the Internet Worm [Spafford, 1989a, 1989b; Eichin and Rochlis, 1989; Rochlis and Eichin, 1989], and was mentioned in a New York Times article [Markoff, 1989]. Privileged programs should be as small and modular as possible. An SMTP daemon does not need to run as root. (To be fair, we should note that recent versions of sendmail have been much better. Still, there are free mailers that we trust much more; see Section 8.8.1.) For most mail gatekeepers, the big problem is configuration. The sendmail configuration rules are infamously obtuse, spawning a number of useful how-to books such as [Costales, 1993] and [Avolio and Vixie, 2001]. And even when a mailer's rewrite rules are relatively easy, it can still be difficult to figure out what to do. RFC 2822 [Resnick, 2001] offers useful advice.

Sendmail can be avoided or tamed to some extent, and other mailers are available. We have also seen simple SMTP front ends for sendmail that do not run as root and implement a simple and hopefully reliable subset of the SMTP commands [Carson, 1993; Avolio and Ranum, 1994]. For that matter, if sendmail is not doing local delivery (as is the case on gateway machines), it does not need to run as root. It does need write permission on its spool directory (typically, /var/spool/mqueue), read permission on /dev/kmem (on some machines) so it can determine the current load average, and some way to bind to port 25. The latter is most easily accomplished by running it via inetd, so that sendmail itself need not issue the bindcall.

Regardless of which mailer you run, you should configure it so that it will only accept mail that is either from one of your networks, or to one of your users. So-called open relays, which will forward e-mail to anyone from anyone, are heavily abused by spammers who want to cover their tracks [Hambridge and Lunde, 1999]. Even if sending the spam doesn't overload your mailer (and it very well might), there are a number of blacklists of such relays. Many sites will refuse to accept any e-mail whatsoever from a known open relay.

If you need to support road warriors, you can use SMTP Authentication [Myers, 1999]. This is best used in conjunction with encryption of the SMTP session [Hoffman, 2002]. The purpose of SMTP Authentication is to avoid having an open relay; open relays attract spammers, and can result in your site being added to a "reject all mail from these clowns" list. This use of SMTP is sometimes known as "mail submission," to distinguish it from more general mail transport.

3.1.2 MIME

The content of the mail can also pose dangers. Apart from possible bugs in the receiving machine's mailer, automated execution of Multipurpose Internet Mail Extensions (MIME)-encoded messages [Freed and Borenstein, 1996a] is potentially quite dangerous. The structured information encoded in them can indicate actions to be taken. For example, the following is an excerpt from the announcement of the publication of an RFC:

Content-Type: Message/External-body;

Content-Type: text/plain

A MIME-capable mailer would retrieve the RFC for you automatically. Suppose, however, that a hacker sent a forged message containing this:

Content-Type: Message/External-body;

Content-Type: text/plain

Would your MIME agent blithely overwrite the existing .rhosts file in your current working directory? Would you notice if the text of the message otherwise appeared to be a legitimate RFC announcement?

There is a MIME analog to the fragmentation attack discussed on page 21. One MIME type [Freed and Borenstein, 1996b] permits a single e-mail message to be broken up into multiple pieces. Judicious fragmentation can be used to evade the scrutiny of gateway-based virus checkers. Of course, that would not work if the recipient's mailer couldn't reassemble the fragments; fortunately, Microsoft Outlook Express—an unindicted (and unwitting) co-conspirator in many worm outbreaks—can indeed do so. The fix is either to do reassembly at the gateway or to reject fragmented incoming mail.

Other MIME dangers include the ability to mail executable programs, and to mail PostScript files that themselves can contain dangerous actions. Indeed, sending active content via e-mail is a primary vector for the spread of worms and viruses. It is, of course, possible to send a MIME message with a forged From: line; a number of popular worms do precisely that. (We ourselves have received complaints, automated and otherwise, about viruses that our machines have allegedly sent.) These problems and others are discussed at some length in the MIME specification; unfortunately, the advice given there has been widely ignored by implementors of some popular Windows-based mailers.

3.1.3 POP version 3

POP3, the Post Office Protocol [Myers and Rose, 1996] is used by simple clients to obtain their mail. Their mail is delivered to a mailbox on a spooling host, perhaps provided by an ISP. When a client runs its mailer, the mailer downloads the waiting messages into the client. The mail is typically removed from the server. While online, the mailer may poll the server at regular intervals to obtain new mail. The client sends mail using SMTP, perhaps directly or through a different mail server. (A number of sites use the POP3 authentication to enable mail-relaying via SMTP, thus blocking spammers. The server caches the IP address of the machine from which the successful POP3 session came; for a limited time thereafter, that machine is allowed to do SMTP relaying.)

The protocol is quite simple, and has been around for a while. The server can implement it quite easily, even with a Perl script. See Section 8.9 for an example of such a server.

POP3 is quite insecure. In early versions, the user's password was transmitted in the clear to obtain access to the mailbox. More recent clients use the APOP command to exchange a challenge/response based on a password. In both cases, the password needs to be stored in the clear on the server. In addition, the authentication exchange permits a dictionary attack on the password. Some sites support POP3 over SSL/TLS [Rescorla, 2000b], but this is not supported by a number of popular clients.

If the server is running UNIX, the POP3 server software typically runs as root until authentication is complete, and then changes to the user's account on the server. This means that the user must have an account on the server, which is not good—it adds more administrative overhead, and may imply that the user can log into the server itself. This is never a good idea: Users are bad security risks. It also means that another network server is running as root. If you're running a large installation, though, you can use a POP3 server that maintains its own database of users and e-mail.

The benefits of POP3 include the simplicity of the protocol (if only network telephony were this easy!) and the easy implementation on the server. It is limited, however—users generally must read their mail from one host, as the mail is generally delivered to the client.

3.1.4 IMAP Version 4

IMAP version 4 [Crispin, 1996] offers remote access to mailboxes on a server. It enables the client and server to synchronize state, and supports multiple folders. As in POP3, mail is still sent using SMTP.

A typical UNIX IMAP4 server requires the same access as a POP3 server, plus more to support the extra features. We have not attempted to "jail" an IMAP server (see Section 8.5), as the POP3 server has supported our needs.

The IMAP protocol does support a suite of authentication methods, some of which are fairly secure. The challenge/response authentication mentioned in [Klensin et al., 1997] is a step in the right direction, but it is not as good as it could be. A shared secret is involved, which again must be stored on the server. It would be better if the challenge/response secret were first hashed with a domain string to remove some password equivalence. (Multiple authentication options always raise the possibility of version-rollback attacks, forcing a server to use weaker authentication or cryptography.) Our biggest reservation about IMAP is the complexity of the protocol, which of course requires a complex server. If the server is implemented properly, with a small, simple authentication module as a front end to an unprivileged protocol engine, this may be no worse than user logins to the machine, but you need to verify the design of your server.

3.1.5 Instant Messaging

There are numerous commercial Instant Messaging (IM) offerings that use various proprietary protocols. We don't have the time or interest to keep up with all of them. America Online Instant Messenger uses a TCP connection to a master server farm to link AOL Instant Messenger users.

ICQ does the same. It is not clear to us how Microsoft Messenger connects. You might think that messaging services would operate peer-to-peer after meeting at a central point, but peer-to-peer is unlikely to work if both peers are behind firewalls. Central meeting points are a good place to sniff these sessions. False meeting places could be used to attract messaging traffic if DNS queries can be diverted. Messaging traffic often contains sensitive company business, and it shouldn't. The client software usually has other features, such as the ability to send files. Security bugs have appeared in a number of them.

It is possible to provide your own meeting server using something like jabber [Miller, 2002]. Jabber attempts to provide protocol support for a number of instant messaging clients, though the owners of these protocols often attempt to frustrate this interaction. It even supports SSL connections to the server, frustrating eavesdropping. However, note that if you use server-side gateways, as opposed to multi-protocol clients, you're trusting the server with all of your conversations and—for some protocols—your passwords.

There is a lot of software, both server and clients, for IRC, but their security record for these programs has been poor.

The locally run servers have a much better security model but tend to short-circuit the business models of the instant messaging services. The providers of these services realize this, and are trying to move into the business IM market.

Instant messaging can leak personal schedules. Consider the following log from naim, a UNIX implementation of the AOL instant messenger protocol:

[06:56:02] *** Buddy Fred is now online =) 
[07:30:23] *** Buddy Fred has just logged off :( 
[08:14:16] *** Buddy Fred is now online =) 

"Fred" checked his e-mail upon awakening. It took him 45 minutes to eat breakfast and commute to work. This could be useful for a burglar, too.

  • + Share This
  • 🔖 Save To Your Account