Chapter 11
Security on the Internet
According to the traditional definition, network security comprises integrity, confidentiality,
and availability. Message integrity ensures that if an unauthorized party modifies a message
between the sender and the receiver, the receiver is able to detect this modification. In addition
to message integrity, integrity mechanisms always provide some type of proof of data origin.
Knowing that a message has not been modified without knowing who initially created the
message would be useless.
Confidentiality mechanisms keep unauthorized parties from gaining access to the contents
of a message. Confidentiality is typically achieved through encryption.
Denial of Service (DoS) attacks compromise the system’s availability by keeping
authorized users from accessing a particular service. The most common DoS attacks consist
of keeping the servers busy performing an operation or sending the servers more traffic than
they can handle.
SIP provides several security mechanisms to address integrity, confidentiality, and
availability. Some of the security mechanisms come from the world of the web, some come
from the world of email, and some of them are SIP-specific. We analyze these mechanisms
in the following sections and describe how they relate to the three security properties just
described.
11.1 HTTP Digest Access Authentication
The first problem a SIP server faces is authenticating users who are requesting services.
SIP has inherited an authentication mechanism from HTTP called HTTP Digest Access
Authentication (specified in RFC 2617 [145]). In the SIP context the server authenticating
the user (i.e., the caller) can be a proxy, a registrar, a redirect server, or a user agent
(the callee’s user agent). The WWW-Authenticate and Authorization header fields are
used with registrars, redirect servers, and user agents, and the Proxy-Authenticate and
Proxy-Authorization header fields are used with proxies.
When using HTTP Digest Access Athentication the client and the server have a shared
secret (e.g., a password), which is exchanged using an out-of-band mechanism. When a
server at a given domain receives a request from a client the server challenges the client to
provide valid credentials for that domain. At that point the client provides the server with a
username and proves that the client knows the shared secret.
´ıa- M ar t´ın
The 3G IP Multimedia Subsystem (IMS): Merging the Internet and the Cellular Worlds Third Edition
Gonzalo Camarillo and Miguel A. Garc
© 2008 John Wiley & Sons, Ltd. ISBN: 978- 0- 470- 51662- 1
278
CHAPTER 11. SECURITY ON THE INTERNET
An obvious way for the client to prove that it knows the shared secret would be to send
it to the server in clear text (i.e., without any encryption). In fact, this is what HTTP basic
access authentication (also specified in RFC 2617 [145]) does. Nevertheless, the security
risks created by sending passwords in clear text are obvious. Any attacker that manages
to gain access to the message carrying the shared secret gains access to the shared secret
itself. Previous SIP specifications allowed the use of basic authentication, but it has now
been deprecated for some time. The use of HTTP Digest Access Authentication is currently
recommended instead.
Clients using digest can prove that they know the shared secret without sending it over
the network. Digest uses hashes and nonces for this purpose. A hash algorithm is a one-way
function that takes an argument of an arbitrary length and produces a fixed length result, as
shown in Figure 11.1. The fact that hash algorithms are one-way functions means that it is
computationally infeasible to obtain the original argument from the result. Two popular hash
algorithms are MD5 (specified in RFC 1321 [263]) and SHA1 (specified in RFC 3174 [127]).
A nonce is a random value that is used only once.
This is a short text.
This text is not that
short. Many would
even say that it is fairly
long.
Hash function
Hash function
abd45gx534
6hbcRsQ3jP
gyE4n9BawH
JK3AiBxZfh
Fixed length output
Computationally
infeasible
Computationally
infeasible
Figure 11.1: Hash function
Figure 11.2 shows how digest uses hashes and nonces. Alice sends an INVITE (1) request
addressed to Bob through her outbound proxy (at domain.com). The proxy challenges the
INVITE with a 407 (Proxy Authentication Required) response (2). The proxy includes a
Proxy-Authenticate header field with a set of parameters. The realm parameter indicates
the domain of the proxy server, so that the client knows which password to use. The qop
(quality of protection) parameter indicates that the server supports integrity protection for
either the request line alone (auth) or for both the request line and the message body
(auth-int). The server provides the client with a random nonce in the nonce parameter.
The algorithm parameter identifies the hash function (MD5, in this example).
When the client receives the response it issues a new INVITE (3) with a Proxy-Authori-
zation header field. The Proxy-Authorization header field contains a set of parameters.
The response parameter is especially interesting. It contains a hash comprising, among
other things, the username, the password, the server’s nonce, the client’s nonce (cnonce
parameter), and the request line. When the auth-int qop is chosen the message body is also
fed into the hash algorithm to generate the response parameter.
When the server receives this Proxy-Authorization header field it calculates another
hash value using the same input as the client, but using the shared secret the server has. If
the result matches the value in the response parameter of the INVITE request the server
11.1. HTTP DIGEST ACCESS AUTHENTICATION
279
Alice
(1) INVITE
SIP proxy
domain.com
(2) 407 Proxy Authentication Required
Proxy-Authenticate: Digest
realm="domain.com",
qop="auth,auth-int",
nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
algorithm=MD5
(3) INVITE
Proxy-Authorization: Digest
username="alice",
realm="domain.com",
nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
uri="sip:bob@domain2.com",
qop=auth,
nc=00000001,
cnonce="0a4f113b",
response="6629fae49393a05397450978507c4ef1",
algorithm=MD5
Figure 11.2: HTTP Digest Access Authentication operation
considers the authentication successful and keeps on processing the INVITE. Otherwise, the
server will challenge this INVITE again.
The inclusion of random nonces chosen by the server in the hash prevents replay attacks.
Even if an eavesdropper manages to obtain the correct hash value for a particular nonce it
will not be able to access the server, since the server will challenge it with a different random
nonce.
11.1.1 Security Properties of Digest
HTTP Digest Access Authentication provides authentication of users and a limited degree
of integrity protection (no confidentiality). Digest integrity protects the request line (i.e.,
method and Request-URI) and, potentially, the message body. Still, it does not integrity-
protect the header fields of the message. This lack of header field protection is an important
drawback, because, as we saw in previous chapters, header fields in SIP carry important
information which attackers can easily manipulate if digest is used by itself. In brief, digest
access authentication is vulnerable to Man-in-the-Middle (MitM) attacks.
280
CHAPTER 11. SECURITY ON THE INTERNET
Regarding availability, digest offers good DoS protection. Servers issuing challenges
using digest can remain stateless until the new request arrives. So, an attacker issuing a large
number of requests to a server will not block any resources for a long period of time.
In addition to client authentication, digest can also provide server authentication. That
is, the server can prove to the client that the server knows their shared secret as well.
Nevertheless, this feature is not used by SIP proxies.
Digest client authentication is common because user agents acting as clients do not
typically have certificates to use more advanced and secure certificate-based authentication
mechanisms. On the other hand, domain administrators typically provide their proxy servers
with site certificates, which is why certificate-based proxy authentication is used instead of
digest server authentication.
11.2 Certificates
Certificates are key to understanding TLS and S/MIME (which are described in the following
sections). A certificate is a statement about the truth of something signed by a trusted party.
A passport is an example of a certificate. The government of a country certifies the identity
of the passport holder. Everyone who trusts the government will be convinced of the identity
of the holder.
Certificates used in SIP bundle together a public key with a user (e.g., sip:Alice.
Smith@domain.com), a domain (e.g., domain.com), or a host (e.g., ws1234.domain.com).
Domain certificates, also known as site certificates, are used by network elements (i.e., prox-
ies, redirect servers, and registrars) and are usually signed by a certification authority whose
public key is well known. This way, any SIP entity that knows the public key of the
certification authority can check the validity of the certificates presented by another SIP
entity. Within a domain, host certificates can be used to authenticate different network nodes
(e.g., two proxies).
Since building and managing a certification authority hierarchy to provide signed
certificates to every user has been proven to be a difficult task for a number of reasons
(technical and nontechnical), SIP allows the use of self-signed certificates: that is, certificates
that are not signed by any certification authority. Section 11.4 describes how self-signed
certificates are used in SIP.
11.3 TLS
TLS (Transport Layer Security, specified in RFC 2246 [120]) is based on SSL (Secure
Sockets Layer). SSL was designed to protect web communications and is currently
implemented in most Internet browsers. TLS is more generic than SSL and can be used
to protect any type of reliable connection. So, using TLS to protect SIP traffic is yet another
security solution that comes from the world of the web.
TLS provides data integrity and confidentiality for reliable connections (e.g., a TCP
connection). It can also provide compression, although that feature is not typically used.
TLS consists of two layers: namely, the TLS handshake layer and the TLS record layer.
The TLS handshake layer handles the authentication of peers, using public keys and
certificates, and the negotiation of the algorithm and the keys to encrypt the actual data
transmission. Once a reliable connection at the transport layer is established (e.g., a TCP
connection) a TLS handshake takes place. The handshake starts with an exchange of hello
messages and usually takes two RTTs (Round Trip Times) to complete. During authentication
11.3. TLS
281
the server provides the client with the server’s certificates (e.g., X.509 certificates [187]) and
can optionally request the client to provide its certificates as well. The server chooses the
encryption algorithm to be used from among those supported by the client.
The TLS handshake also allows peers to generate a so-called premaster secret (e.g., using
Diffie–Hellman) and to exchange random values. The premaster secret and the random values
are used by the TLS record layer to generate the encryption key.
The TLS record layer handles the encryption of the data. It typically uses a symmetric
encryption algorithm whose key is generated from the values provided by the handshake
layer.
As we can see in Figure 11.3, when TLS is used over TCP peers need to wait for three
RTTs (one for the TCP handshake and two for the TLS handshake) before exchanging secure
data. Note that in Figure 11.3 we assume that the TLS Client Hello (3) is piggybacked
on the TCP ACK that completes the TCP three-way handshake, although many TCP
implementations send them in parallel rather than in a single datagram.
Alice
(1) TCP SYN
SIP Proxy
domain.com
(2) TCP SYN
(3) TCP ACK +TLS Client Hello
(5) TLS Certificate, Key stuff, Certificate Verify, Change Cipher, Finished
(4) TLS Server Hello, Certificate, Key stuff, Certificate request, Done
(6) TLS Change cipher, Finished
(7) INVITE
(8) 200 OK
(9) ACK
Handled by the
TLS handshake
layer
Handled by the
TLS record layer
Figure 11.3: TLS connection establishment
11.3.1 SIP Usage
From the SIP point of view, TLS is a hop-by-hop security solution. That is, a TLS connection
protects the messages exchanged between a SIP entity and the SIP entity one hop away
(e.g., a user agent and a proxy). For example, if Alice’s outbound proxy needs to send a
SIP message to Bob through his proxy server at domain2.com, Alice’s proxy will perform
a DNS lookup for domain2.com. If the DNS records for domain2.com show that the proxy
at domain2.com prefers to use TLS, they will exchange SIP traffic using a TLS connection;
however, establishing this TLS connection is out of Alice’s control. When Alice sent the
original message to her outbound proxy she did not know anything about the domain2.com
DNS records. If these DNS records had said that UDP with no security was preferred over
TLS, the proxies would not have used any kind of encryption. So, Alice needs a way to tell
her proxy that she wants her message to be protected all of the time. That is, she wants all of
the proxies in the path to exchange data using TLS while handling her request. SIP provides