Computer Security
Computer Security
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted
in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without either the
prior written permission of the publisher or a licence permitting restricted copying in the United Kingdom
issued by the Copyright Licensing Agency Ltd, Saffron House, 6–10 Kirby Street, London EC1N 8TS.
All trademarks used herein are the property of their respective owners. The use of any trademark
in this text does not vest in the author or publisher any trademark ownership rights in such
trademarks, nor does the use of such trademarks imply any affiliation with or endorsement of this
book by such owners.
Table of Contents
1. Introduction
Michael T. Goodrich/Roberto Tamassia 1
2. Physical Security
Michael T. Goodrich/Roberto Tamassia 55
3. Operating Systems Security
Michael T. Goodrich/Roberto Tamassia 113
4. Malware
Michael T. Goodrich/Roberto Tamassia 173
5. Network Security I
Michael T. Goodrich/Roberto Tamassia 221
6. Network Security II
Michael T. Goodrich/Roberto Tamassia 269
7. Web Security
Michael T. Goodrich/Roberto Tamassia 327
8. Cryptography
Michael T. Goodrich/Roberto Tamassia 387
9. Distributed-Applications Security
Michael T. Goodrich/Roberto Tamassia 445
10. Bibliography
Michael T. Goodrich/Roberto Tamassia 499
Index 505
I
This page intentionally left blank
Introduction
Contents
1 Fundamental Concepts
1.1 Confidentiality, Integrity, and Availability
1.2 Assurance, Authenticity, and Anonymity
1.3 Threats and Attacks
1.4 Security Principles
2 Access Control Models
2.1 Access Control Matrices
2.2 Access Control Lists
2.3 Capabilities
2.4 Role-Based Access Control
3 Cryptographic Concepts
3.1 Encryption
3.2 Digital Signatures
3.3 Simple Attacks on Cryptosystems
3.4 Cryptographic Hash Functions
3.5 Digital Certificates
4 Implementation and Usability Issues
4.1 Efficiency and Usability
4.2 Passwords
4.3 Social Engineering
4.4 Vulnerabilities from Programming Errors
5 Exercises
1
Introduction
1 Fundamental Concepts
2
Introduction
Confidentiality Availability
© Andresr/Shutterstock © Yuri Arcurs/Fotolia, LLC–Royalty Free
3
Introduction
Confidentiality
In the context of computer security, confidentiality is the avoidance of the
unauthorized disclosure of information. That is, confidentiality involves
the protection of data, providing access for those who are allowed to see it
while disallowing others from learning anything about its content.
Keeping information secret is often at the heart of information security,
and this concept, in fact, predates computers. For example, in the first
recorded use of cryptography, Julius Caesar communicated commands to
his generals using a simple cipher. In his cipher, Caesar took each letter in
his message and substituted D for A, E for B, and so on. This cipher can be
easily broken, making it an inappropriate tool for achieving confidentiality
today. But in its time, the Caesar cipher was probably fairly secure, since
most of Caesar’s enemies couldn’t read Latin anyway.
Nowadays, achieving confidentiality is more of a challenge. Computers
are everywhere, and each one is capable of performing operations that
could compromise confidentiality. With all of these threats to the confiden-
tiality of information, computer security researchers and system designers
have come up with a number of tools for protecting sensitive information.
These tools incorporate the following concepts:
• Encryption: the transformation of information using a secret, called
an encryption key, so that the transformed information can only be
read using another secret, called the decryption key (which may, in
some cases, be the same as the encryption key). To be secure, an
encryption scheme should make it extremely difficult for someone to
determine the original information without use of the decryption key.
• Access control: rules and policies that limit access to confidential
information to those people and/or systems with a “need to know.”
This need to know may be determined by identity, such as a person’s
name or a computer’s serial number, or by a role that a person has,
such as being a manager or a computer security specialist.
• Authentication: the determination of the identity or role that some-
one has. This determination can be done in a number of different
ways, but it is usually based on a combination of something the
person has (like a smart card or a radio key fob storing secret keys),
something the person knows (like a password), and something the
person is (like a human with a fingerprint). The concept of authenti-
cation is schematically illustrated in Figure 2.
• Authorization: the determination if a person or system is allowed
access to resources, based on an access control policy. Such authoriza-
tions should prevent an attacker from tricking the system into letting
him have access to protected resources.
4
Introduction
5
Introduction
Integrity
6
Introduction
• Data correcting codes: methods for storing data in such a way that
small changes can be easily detected and automatically corrected.
These codes are typically applied to small units of storage (e.g., at the
byte level or memory word level), but there are also data-correcting
codes that can be applied to entire files as well.
These tools for achieving data integrity all possess a common trait—they
use redundancy. That is, they involve the replication of some information
content or functions of the data so that we can detect and sometimes even
correct breaches in data integrity.
In addition, we should stress that it is not just the content of a data
file that needs to be maintained with respect to integrity. We also need to
protect the metadata for each data file, which are attributes of the file or
information about access to the file that are not strictly a part of its content.
Examples of metadata include the user who is the owner of the file, the
last user who has modified the file, the last user who has read the file, the
dates and times when the file was created and last modified and accessed,
the name and location of the file in the file system, and the list of users or
groups who can read or write the file. Thus, changing any metadata of a
file should be considered a violation of its integrity.
For example, a computer intruder might not actually modify the content
of any user files in a system he has infiltrated, but he may nevertheless be
modifying metadata, such as access time stamps, by looking at our files
(and thereby compromising their confidentiality if they are not encrypted).
Indeed, if our system has integrity checks in place for this type of metadata,
it may be able to detect an intrusion that would have otherwise gone
unnoticed.
7
Introduction
Availability
8
Introduction
Anonymity
© acequestions/Shutterstock
Assurance
© neelsky/Shutterstock
Assurance
9
Introduction
10
Introduction
11
Introduction
Authenticity
With so many online services providing content, resources, and even com-
putational services, there is a need for these systems to be able to enforce
their policies. Legally, this requires that we have an electronic way of
enforcing contracts. That is, when someone says that they are going to buy
a song from an online music store, there should be some way to enforce this
commitment. Likewise, when an online movie store commits to allowing a
user to rent a movie and watch it sometime in the following 30 days, there
should be some enforceable way for that user to know that the movie will
be available for that entire time.
12
Introduction
Anonymity
When people interact with systems in ways that involve their real-world
identities, this interaction can have a number of positive benefits, as out-
lined above. There is an unfortunate side effect from using personal
identities in such electronic transactions, however. We end up spreading
our identity across a host of digital records, which ties our identity to
our medical history, purchase history, legal records, email communications,
employment records, etc. Therefore, we have a need for anonymity, which
is the property that certain records or transactions not to be attributable to
any individual.
If organizations need to publish data about their members or clients, we
should expect that they do so in a privacy-preserving fashion, using some
of the following tools:
13
Introduction
14
Introduction
15
Introduction
16
Introduction
17
Introduction
18
Introduction
One of the best ways to defend against attacks is to prevent them in the
first place. By providing for a rigorous means of determining who has
access to various pieces of information, we can often prevent attacks on
confidentiality, integrity, and anonymity. In this section, we discuss some
of the most popular means for managing access control.
All of the models assume that there are data managers, data owners,
or system administrators who are defining the access control specifications.
The intent is that these folks should be restricting access to those who have
a need to access and/or modify the information in question. That is, they
should be applying the principle of least privilege.
A useful tool for determining access control rights is the access control
matrix, which is a table that defines permissions. Each row of this table
is associated with a subject, which is a user, group, or system that can
perform actions. Each column of the table is associated with an object,
which is a file, directory, document, device, resource, or any other entity
for which we want to define access rights. Each cell of the table is then
filled with the access rights for the associated combination of subject and
object. Access rights can include actions such as reading, writing, copying,
executing, deleting, and annotating. An empty cell means that no access
rights are granted. We show an example access control matrix for part of a
fictional file system and a set of users in Table 1.
Table 1: An example access control matrix. This table lists read, write, and
execution (exec) access rights for each of four fictional users with respect to
one file, /etc/passwd, and three directories.
19
Introduction
Advantages
The nice thing about an access control matrix is that it allows for fast and
easy determination of the access control rights for any subject-object pair—
just go to the cell in the table for this subject’s row and this object’s column.
The set of access control rights for this subject-object pair is sitting right
there, and locating a record of interest can be done with a single operation
of looking up a cell in a matrix. In addition, the access control matrix
gives administrators a simple, visual way of seeing the entire set of access
control relationships all at once, and the degree of control is as specific as the
granularity of subject-object pairs. Thus, there are a number of advantages
to this access control model.
Disadvantages
There is a fairly big disadvantage to the access control matrix, however—it
can get really big. In particular, if we have n subjects and m objects, then the
access control matrix has n rows, m columns, and n · m cells. For example,
a reasonably sized computer server could easily have 1,000 subjects, who
are its users, and 1,000,000 objects, which are its files and directories. But
this would imply an access control matrix with 1 billion cells! It is hard
to imagine there is a system administrator anywhere on the planet with
enough time and patience to fill in all the cells for a table this large! Also,
nobody would be able to view this table all at once.
To overcome the lack of scalability of the access control matrix, com-
puter security researchers and system administrators have suggested a
number of alternatives to the access control matrix. We discuss three of
these models in the remaining part of this section. In particular, we discuss
access control lists, capabilities, and role-based access control. Each of these
models provides the same functionality as the access control matrix, but in
ways that reduce its complexity.
20
Introduction
Advantages
The main advantage of ACLs over access control matrices is size. The total
size of all the access control lists in a system will be proportional to the
number of nonempty cells in the access control matrix, which is expected to
be much smaller than the total number of cells in the access control matrix.
Another advantage of ACLs, with respect to secure computer systems,
is that the ACL for an object can be stored directly with that object as part
of its metadata, which is particularly useful for file systems. That is, the
header blocks for files and directories can directly store the access control
list of that file or directory. Thus, if the operating system is trying to decide
if a user or process requesting access to a certain directory or file in fact has
that access right, the system need only consult the ACL of that object.
Disadvantages
The primary disadvantage of ACLs, however, is that they don’t provide an
efficient way to enumerate all the access rights of a given subject. In order to
determine all the access rights for a given subject, s, a secure system based
on ACLs would have to search the access control list of every object looking
for records involving s. That is, determining such information requires
a complete search of all the ACLs in the system, whereas the similar
computation with an access control matrix simply involves examining the
row for subject s.
Unfortunately, this computation is sometimes necessary. For example, if
a subject is to be removed from a system, the administrator needs to remove
his or her access rights from every ACL they are in. But if there is no way
to know all the access rights for a given subject, the administrator has no
choice but to search all the ACLs to find any that contain that subject.
21
Introduction
2.3 Capabilities
Another approach, known as capabilities, takes a subject-centered ap-
proach to access control. It defines, for each subject s, the list of the objects
for which s has nonempty access control rights, together with the specific
rights for each such object. Thus, it is essentially a list of cells for each row
in the access control matrix, compressed to remove any empty cells. (See
Figure 6.)
/usr/passwd: r; /usr/bin: r;
roberto
/u/roberto: r,w,x
Advantages
The capabilities access control model has the same advantage in space over
the access control matrix as the access control list model has. Namely,
a system administrator only needs to create and maintain access control
relationships for subject-object pairs that have nonempty access control
rights. In addition, the capabilities model makes it easy for an administrator
to quickly determine for any subject all the access rights that that subject
has. Indeed, all she needs to do is read off the capabilities list for that
subject. Likewise, each time a subject s requests a particular access right
for an object o, the system needs only to examine the complete capabilities
list for s looking for o. If s has that right for o, then it is granted it. Thus, if
the size of the capabilities list for a subject is not too big, this is a reasonably
fast computation.
22
Introduction
Disadvantages
The main disadvantage of capabilities is that they are not associated directly
with objects. Thus, the only way to determine all the access rights for an
object o is to search all the capabilities lists for all the subjects. With the
access control matrix, such a computation would simply involve searching
the column associated with object o.
Role Hierarchies
In addition, a hierarchy can be defined over roles so that access rights
propagate up the hierarchy. Namely, if a role R1 is above role R2 in the
hierarchy, then R1 inherits the access rights of R2 . That is, the access
rights of R1 include those of R2 . For example, in the role hierarchy for a
computer science department, role “system administrator,” would be above
23
Introduction
Department
Chair
Administrative Technical
Faculty Student
Personnel Personnel
Department
Member
24
Introduction
3 Cryptographic Concepts
Computer security policies are worthless if we don’t have ways of enforc-
ing them. Laws and economics can play an important role in deterring
attacks and encouraging compliance, respectively. However, technological
solutions are the primary mechanism for enforcing security policies and
achieving security goals.
That’s were cryptography comes in. We can use cryptographic tech-
niques to achieve a broad range of security goals, including some that at
first might even seem to be impossible. In this section, we give an overview
of several fundamental cryptographic concepts.
3.1 Encryption
Traditionally, encryption is described as a means to allow two parties,
customarily called Alice and Bob, to establish confidential communication
over an insecure channel that is subject to eavesdropping. It has grown to
have other uses and applications than this simple scenario, but let us nev-
ertheless start with the scenario of Alice and Bob wanting to communicate
in a confidential manner, as this gives us a foundation upon which we can
build extensions later.
Suppose, then, that Alice has a message, M, that she wishes to commu-
nicate confidentially to Bob. The message M is called the plaintext, and it
is not to be transmitted in this form as it can be observed by other parties
while in transit. Instead, Alice will convert plaintext M to an encrypted
form using an encryption algorithm E that outputs a ciphertext C for M.
This encryption process is denoted by
C = E ( M ).
M = D ( C ).
25
Introduction
Cryptosystems
The decryption algorithm must use some secret information known to Bob,
and possibly also to Alice, but no other party. This is typically accomplished
by having the decryption algorithm use as an auxiliary input a secret num-
ber or string called decryption key. In this way, the decryption algorithm
itself can be implemented by standard, publicly available software and
only the decryption key needs to remain secret. Similarly, the encryption
algorithm uses as auxiliary input an encryption key, which is associated
with the decryption key. Unless it is infeasible to derive the decryption key
from the encryption key, the encryption key should be kept secret as well.
That is encryption in a nutshell.
But before Alice and Bob even start performing this encrypted com-
munication, they need to agree on the ground rules they will be using.
Specifically, a cryptosystem consists of seven components:
1. The set of possible plaintexts
26
Introduction
Modern Cryptosystems
Modern cryptosystems are much more complicated than the Caesar cipher,
and much harder to break. For example, the Advanced Encryption Stan-
dard (AES) algorithm, uses keys that are 128, 196, or 256 bits in length, so
that it is practically infeasible for an eavesdropper, Eve, to try all possible
keys in a brute-force attempt to discover the corresponding plaintext from
a given ciphertext. Likewise, the AES algorithm is much more convoluted
than a simple cyclic shift of characters in the alphabet, so we are not going
to review the details here.
Symmetric Encryption
One important property of the AES algorithm that we do note here, how-
ever, is that the same key K is used for both encryption and decryption.
Such schemes as this, which use the same key for encryption and de-
cryption, are called symmetric cryptosystems or shared-key cryptosystems,
since Alice and Bob have to both share the key K in order for them to
communicate a confidential message, M. A symmetric cryptosystem is
schematically illustrated in Figure 8.
Communication
Sender Recipient
channel
encrypt decrypt
ciphertext plaintext
plaintext
shared
h d shared
h d
secret secret
key key
Attacker
(eavesdropping)
27
Introduction
shared
secret
shared
secret
shared shared shared
secret secret secret
n (n−1)/2
keys
shared
secret
Public-Key Encryption
An alternative approach to symmetric cryptosystems is the concept of a
public-key cryptosystem. In such a cryptosystem, Bob has two keys: a
private key, SB , which Bob keeps secret, and a public key, PB , which Bob
broadcasts widely, possibly even posting it on his web page. In order
for Alice to send an encrypted message to Bob, she need only obtain his
public key, PB , use that to encrypt her message, M, and send the result,
C = EPB ( M), to Bob. Bob then uses his secret key to decrypt the message as
M = DS B ( C ) .
A public-key cryptosystem is schematically illustrated in Figure 10.
28
Introduction
Communication
Sender Recipient
channel
encrypt decrypt
plaintext
public
bli private
i t
key key
Attacker
((eavesdropping)
g)
Figure 10: In a public-key cryptosystem, the sender uses the public key of
the recipient to encrypt and the recipient uses its private key to decrypt.
An attacker who eavesdrops the communication channel cannot decrypt
the ciphertext (encrypted message) without knowing the private key.
© Igor Nazarenko/Shutterstock
private
p private
public public
n key pairs
public
p public
p
private
p private
29
Introduction
Communication
Sender Recipient
channel
encryptt d
decrypt
t
secret secret
k
key ciphertext
key
shared
h d shared
h d
secret key Attacker secret key
(eavesdropping)
encrypt decrypt
30
Introduction
EPB ( DSB ( M )) = M.
That is, Bob can give as input to the decryption algorithm a message, M,
and his private key, SB . Applying the encryption algorithm to the resulting
output and Bob’s public key, which can be done by anyone, yields back
message M.
S = DS B ( M ) .
M = EPB (S).
In this way, Alice is assured that message M is authored by Bob and not
by any other user. Indeed, no one but Bob, who has private key SB , could
have produced such an object S, so that EPB (S) = M.
The only disadvantage of this approach is that Bob’s signature will
be at least as long as the plaintext message he is signing, so this exact
approach is not used in practice.
31
Introduction
Man-in-the-Middle Attacks
Communication
Sender Recipient
channel
encryptt d
decrypt
t
plaintext M plaintext M′
shared shared
secret ciphertext C ciphertext C′ secret
k
key k
key
Attacker
(intercepting)
32
Introduction
English Ciphertext of
text English text
Plaintexts Ciphertexts
n-bit strings n-bit strings
Figure 14: Natural-language plaintexts are a very small fraction of the set
of possible plaintexts. This fraction tends to zero as the plaintext length
grows. Thus, for a given key, it is hard for an adversary to guess a ciphertext
that corresponds to a valid message.
33
Introduction
So, in terms of the bit length n, the number of n-bit arrays corresponding to
English text is approximately 20.16n .
More generally, for a natural language that uses an alphabet instead of
ideograms, there is a constant α, with 0 < α < 1, such that there are 2αn texts
among all n-bit arrays. The constant α depends on the specific language and
character-encoding scheme used. As a consequence, in a natural language
the fraction of valid messages out of all possible n-bit plaintexts is about
2αn 1
n
= (1− α ) n .
2 2
Thus, the fraction of valid messages tends rapidly to zero as n grows.
Note that this fraction represents the probability that a randomly selected
plaintext corresponds to meaningful text.
The above property of natural languages implies that it is infeasible for
an adversary to guess a ciphertext that will decrypt to a valid message or
to guess a signature that will encrypt to a valid message.
The previously mentioned property of natural languages has also im-
portant implications for brute-force decryption attacks, where an adversary
tries all possible decryption keys and aims at determining which of the
resulting plaintexts is the correct one. Clearly, if the plaintext is an arbitrary
binary string, this attack cannot succeed, as there is no way for the attacker
to distinguish a valid message. However, if the plaintext is known to be text
in a natural language, then the adversary hopes that only a small subset of
the decryption results (ideally just a single plaintext) will be a meaningful
text for the language. Some knowledge about the possible message being
sent will then help the attacker pinpoint the correct plaintext.
We know that for some constant α > 1, there are 2αn valid text messages
among the 2n possible plaintexts. Let k be the length (number of bits) of the
decryption key. For a given ciphertext, there are 2k possible plaintexts, each
corresponding to a key. From the previous discussion, each such plaintext
is a valid text message with probability 2(1−1 α)n . Hence, the expected number
of plaintexts corresponding to valid text messages is
2k
.
2(1− α ) n
34
Introduction
As the key length k is fixed, the above number tends rapidly to zero as
the ciphertext length n grows. Also, we expect that there is a unique valid
plaintext for the given ciphertext when
k
n= .
1−α
The above threshold value for n is called the unicity distance for the given
language and key length. For the English language and the 256-bit AES
cryptosystem, the unicity distance is about 304 bits or 38 ASCII-encoded
characters. This is only half a line of text.
From the above discussion, we conclude that brute-force decryption is
likely to succeed for messages in natural language that are not too short.
Namely, when a key yields a plaintext that is a meaningful text, the attacker
has probably recovered the original message.
35
Introduction
36
Introduction
Communication
Co u cat o
channel
(attack detected)
h 6B34339 4C66809 4C66809 =? 87F9024 h
message M MAC MAC received computed
MAC MAC message M’
shared shared
secret secret
key key
Sender Attacker Recipient
(modifying)
Consider an attacker who alters the message and MAC while in transit.
Since the hash function is one-way, it is infeasible for the attacker to recover
the key k from the MAC A = h(K || M) and the message M sent by Alice.
Thus, the attacker cannot modify the message and compute a correct MAC
A0 for the modified message M0 .
37
Introduction
• Name of the organization operating the web site (e.g., “Google, Inc.”).
• Public key used of the web server (e.g., an RSA 1, 024-bit key).
• Digital signature.
In fact, when an Internet browser “locks the lock” at a secure web
site, it is doing so based on a key exchange that starts with the browser
downloading the digital certificate for this web server, matching its name
to a public key. Thus, one approach to defend against a phishing attack for
encrypted web sites is to check that the digital certificate contains the name
of the organization associated with the website.
There are a number of other cryptographic concepts, including such
things a zero-knowledge proofs, secret sharing schemes, and broadcast
encryption methods, but the topics covered above are the most common
cryptographic concepts used in computer security applications.
38
Introduction
Efficiency and ease of use are also important in the context of access control.
Many systems allow only administrators to make changes to the files that
define access control rights, roles, or entities. So, for example, it is not
possible in some operating systems, including several Linux versions, for
users to define the access control rights for their own files beyond coarse-
grained categories such as “everyone” and “people in my group.” Because
of this limitation, it is actually a cumbersome task to define a new work
group and give access rights to that group. So, rather than going through
the trouble of asking an administrator to create a new group, a user may just
give full access rights to everyone, thus compromising data confidentiality
and integrity.
For example, suppose a group of students decides to work on a software
project together for a big schoolwide contest. They are probably going
to elect a project leader and have her create a subdirectory of her home
directory for all the project code to reside. Ideally, it should be easy for the
leader to define the access control for this directory and allow her partners
to have access to it, but no one else. Such control is often not possible
without submitting a request to an overworked system administrator, who
may or may not respond to such requests from students. So, what should
the project leader do?
39
Introduction
Possible Solutions
One solution is to have the leader maintain the reference version of the code
in the project directory and require the team members to email her all their
code updates. On receipt of an update from a team member, the leader
would then perform the code revisions herself on the reference version of
the code and would distribute the modified files to the rest of the team.
This solution provides a reasonable level of security, as it is difficult (though
not impossible) to intercept email messages. However, the solution is very
inefficient, as it implies a lot of work for the leader who would probably
regret being selected for this role.
Another possibility is for the project leader to take an easy way out by
hiding the project directory somewhere deep in her home directory, making
that directory be accessible by all the users in the system, and hoping
that none of the competing teams will discover this unprotected directory.
This approach is, in fact, an example of security by obscurity, which is
the approach of deriving security from a fact that is not generally known
rather than employing sound computer security principles (as discussed in
Sections 1.1 and 1.2). History has taught us again and again, however, that
security by obscurity fails miserably. Thus, the leader of our software team
is forced into choosing between the lesser of two evils, rather than being
given the tools to build a secure solution to her problem.
Users should clearly not have to make such choices between security
and efficiency, of course. But this requirement implies that system designers
need to anticipate how their security decisions will impact users. If doing
the safe thing is too hard, users are going to find a workaround that is easy
but probably not very secure.
Let us now revisit our example of the school programming team. The
most recent versions of Linux and Microsoft Windows allow the owner of
a folder to directly define an access control list for it (see Section 2.2),
without administrator intervention. Also, by default such permissions are
automatically applied to all the files and subfolders created within the
folder. Thus, our project leader could simply add an access control list
to the project folder that specifies read, write, and execute rights for each
of the team members. Team members can now securely share the project
folder without the risk of snooping by competing teams. Also, the project
leader needs to create this access control list only once, for the project folder.
Any newly added files and subfolders will automatically inherit this access
control list. This solution is both efficient and easy to use.
40
Introduction
4.2 Passwords
One of the most common means for authenticating people in computer sys-
tems is through the use of usernames and passwords. Even systems based
on cryptographic keys, physical tokens, and biometrics often augment the
security of these techniques with passwords. For example, the secret key
used in a symmetric cryptosystem may be stored on the hard drive in
encrypted form, where the decryption key is derived from a password. In
order for an application to use the secret key, the user will have to enter
her password for the key. Thus, a critical and recurring issue in computer
security circles is password security.
Ideally, passwords should be easy to remember and hard to guess. Un-
fortunately, these two goals are in conflict with each other. Passwords that
are easy to remember are things like English words, pet names, birthdays,
anniversaries, and last names. Passwords that are hard to guess are random
sequences of characters that come from a large alphabet, such as all the
possible characters that can be typed on a keyboard, including lowercase
and uppercase letters, numbers, and symbols. In addition, the longer a
password is used the more it is at risk. Thus, some system administrators
require that users frequently change their passwords, which makes them
even more difficult to remember.
Dictionary Attack
The problem with the typical easy-to-remember password is that it belongs
to a small set of possibilities. Moreover, computer attackers know all these
passwords and have built dictionaries of them. For example, for the English
language, there are less than 50,000 common words, 1,000 common human
first names, 1,000 typical pet names, and 10,000 common last names. In
addition, there are only 36,525 birthdays and anniversaries for almost all
living humans on the planet, that is, everyone who is 100 years old or
younger. So an attacker can compile a dictionary of all these common
passwords and have a file that has fewer than 100,000 entries.
Armed with this dictionary of common passwords, one can perform an
attack that is called, for obvious reasons, a dictionary attack. If an attcker
can try the words in his dictionary at the full speed of a modern computer,
he can attack a password-protected object and break its protections in just
a few minutes. Specifically, if a computer can test one password every
millisecond, which is probably a gross overestimate for a standard com-
puter with a clock speed of a gigahertz, then it can complete the dictionary
attack in 100 seconds, which is less than 2 minutes. Indeed, because of
this risk, many systems introduce a multiple-second delay before reporting
41
Introduction
password failures and some systems lock out users after they have had a
number of unsuccessful password attempts above some threshold.
Secure Passwords
Secure passwords, on the other hand, take advantage of the full potential
of a large alphabet, thus slowing down dictionary attacks. For instance,
if a system administrator insists on each password being an arbitrary
string of at least eight printable characters that can by typed on a typical
American keyboard, then the number of potential passwords is at least
948 = 6 095 689 385 410 816, that is, at least 6 quadrillion. Even if a computer
could test one password every nanosecond, which is about as fast as any
computer could, then it would take, on average, at least 3 million seconds
to break one such password, that is, at least 1 month of nonstop attempts.
The above back-of-the-envelope calculation could be the reason why
paranoid system administrators ask users to change their passwords every
month. If each attempt takes at least a microsecond, which is more realistic,
then breaking such a password would take at least 95 years on average. So,
realistically, if someone can memorize a complex password, and never leak
it to any untrustworthy source, then it is probably good for a long time.
There are several tricks for memorizing a complex password. Needless
to say in a book on computer security, one of those ways is definitely not
writing the password down on a post-it note and sticking it on a computer
screen! A better way is to memorize a silly or memorable sentence and then
take every first letter of each word, capitalizing some, and then folding in
some special characters. For example, a user, who we will call “Mark,”
could start with the sentence
MtLtDoM15,
which provides a pretty strong password. However, we can do even better.
Since a t looks a lot like the plus sign, Mark can substitute “+” for one of the
t’s, resulting in the password
MtL+DoM15,
which is even stronger. If Mark is careful not to let this out, this password
could last a lifetime.
42
Introduction
Pretexting
A classic example of a social engineering attack, for instance, involves an
attacker, Eve, calling a helpdesk and telling them that she has forgotten her
password, when she is actually calling about the account of someone else,
say, someone named “Alice.” The helpdesk agent might even ask Eve a
few personal questions about Alice, which, if Eve has done her homework,
she can answer with ease. Then the courteous helpdesk agent will likely
reset the password for Alice’s account and give the new password to Eve,
thinking that she is Alice. Even counting in the few hours that it takes Eve to
discover some personal details about Alice, such as her birthday, mother’s
maiden name, and her pet’s name, such an attack works faster than a brute-
force password attack by orders of magnitudes, and it doesn’t require any
specialized hardware or software. Such an attack, which is based on an
invented story or pretext, is known as pretexting.
Baiting
Another attack, known as baiting, involves using some kind of “gift” as a
bait to get someone to install malicious software. For example, an attacker
could leave a few USB drives in the parking lot of a company with an
otherwise secure computer system, even marking some with the names of
popular software programs or games. The hope is that some unsuspecting
employee will pick up a USB drive on his lunch break, bring it into the
company, insert it into an otherwise secure computer, and unwittingly
install the malicious software.
43
Introduction
having any trouble with her computer or with her company’s computer
system in general. Or he could ask Alice if she needs any help in coming
up with a strong password now that it is time to change her old one. In
any case, Bob offers Alice some legitimate help. He may even diagnose
and solve a problem she has been having with her computer. This is the
“something” that Bob has now offered Alice, seemingly without asking for
anything in return. At that point, Bob then asks Alice for her password,
possibly offering to perform future fixes or offering to do an evaluation of
how strong her password is. Because of the social pressure that is within
each of us to want to return a favor, Alice may feel completely at ease at this
point in sharing her password with Bob in return for his “free” help. If she
does so, she will have just become a victim of the quid pro quo attack.
To increase the chances of succeeding in his attack, Bob may use a voice-
over-IP (VoIP) telephone service that allows for caller-ID spoofing. Thus,
he could supply as his caller-ID the phone number and name of the actual
helpdesk for Alice’s company, which will increase the likelihood that Alice
will believe Bob’s story. This is an instance of another type of attack called
vishing, which is short for VoIP phishing.
In general, social engineering attacks can be very effective methods to
circumvent strong computer security solutions. Thus, whenever a system
designer is implementing an otherwise secure system, he or she should
keep in mind the way that people will interact with that system and the
risks it may have to social engineering attacks.
44
Introduction
provided by the attacker can overwrite the data and code of the application,
which may result in the application performing malicious actions specified
by the attacker. Web servers and other applications that communicate over
the Internet have been often attacked by remote users by exploiting buffer
overflow vulnerabilities in their code.
malicious
name buffer
code
application
code
enter name
web server
Attacker
(a)
name buffer
malicious
code
application
li ti
code
web server
Attacker
(b)
Figure 16: A buffer overflow attack on a web server. (a) A web server
accepts user input from a name field on a web page into an unchecked
buffer variable. The attacker supplies as input some malicious code. (b) The
malicious code read by the server overflows the buffer and part of the
application code. The web server now runs the malicious code.
45
Introduction
5 Exercises
For help with exercises, please visit securitybook.net.
Reinforcement
R-1 Compare and contrast the C.I.A. concepts for information security
with the A.A.A. concepts.
R-2 What is the ciphertext in an English version of the Caesar cipher
for the plaintext “ALL ZEBRAS YELP.”
R-3 Explain why someone need not worry about being a victim of a
social engineering attack through their cell phone if they are inside
of a Faraday cage.
R-4 What are some of the techniques that are used to achieve confiden-
tiality?
R-5 What is the most efficient technique for achieving data integrity?
R-6 With respect to the C.I.A. and A.A.A. concepts, what risks are
posed by spam?
R-7 With respect to the C.I.A. and A.A.A. concepts, what risks are
posed by Trojan horses?
R-8 With respect to the C.I.A. and A.A.A. concepts, what risks are
posed by computer viruses?
R-9 With respect to the C.I.A. and A.A.A. concepts, what risks are
posed by packet sniffers, which monitor all the packets that are
transmitted in a wireless Internet access point?
R-10 With respect to the C.I.A. and A.A.A. concepts, what risks are
posed by someone burning songs from an online music store onto
a CD, then ripping those songs into their MP3 player software sys-
tem and making dozens of copies of these songs for their friends?
R-11 With respect to the C.I.A. and A.A.A. concepts, what risks are
posed by someone making so many download requests from an
online music store that it prevents other users from being able to
download any songs?
R-12 Compare and contrast symmetric encryption with public-key en-
cryption, including the strengths and weaknesses of each.
R-13 List at least three security risks that could arise when someone has
their laptop stolen.
46
Introduction
47
Introduction
Creativity
C-1 Describe an architecture for an email password reset system that is
more secure than the one described in Exercise R-23, but is still
highly usable.
C-2 Describe an instance of a file that contains evidence of its own
integrity and authenticity.
C-3 Suppose an Internet service provider (ISP) has a voice over IP
(VoIP) telephone system that it manages and sells. Suppose further
that this ISP is deliberately dropping 25% of the packets used in
its competitors VoIP system when those packets are going through
this ISP’s routers. Describe how a user could discover that his ISP
is doing this.
C-4 Computer viruses, by their very nature, have to be able to replicate
themselves. Thus, a computer virus must store a copy of itself in-
side its own code. Describe how this property of computer viruses
could be used to discover that a computer virus has infected a
certain operating system file.
48
Introduction
C-5 Suppose that you are a computer virus writer; hence, you know
that you need to store a copy of the code for your virus inside
the virus itself. Moreover, suppose you know that a security
administrator is also aware of this fact and will be using it to
detect the presence of your virus in operating systems files, as
described in the previous problem. Explain how you can hide the
embedded copy of your virus so that it is difficult for the security
administrator to find it.
C-6 Describe a hybrid scheme for access control that combines both
the access control list and capabilities models. Explain how the
records for this hybrid model can be cross-linked to support object
removal and subject removal in time proportional to their number
of associated access rights; hence, not in time proportional to all the
subject-object access right pairs.
C-7 Give two examples of attacks that compromise the integrity of the
meta data of files or directories in a file system.
C-8 A rootkit is a piece of malicious software that installs itself into an
operating system and then alters all of the operating system utility
programs that would normally be able to detect this software so
that they do not show its presence. Describe the risks that would
be posed by such software, how it could actually be discovered,
and how such an infection could be repaired.
C-9 Benny is a thief who tried to break into an Automated Teller Ma-
chine (ATM) using a screwdriver, but was only able to break five
different keys on the numeric keypad and jam the card reader, at
which point he heard Alice coming, so he hid. Alice walked up,
put in her ATM card, successfully entered her 4-digit PIN, and took
some cash. But she was not able to get her card back, so she drove
off to find help. Benny then went back to the ATM, and started
entering numbers to try to discover Alice’s PIN and steal money
from her account. What is the worst-case number of PINs that
Benny has to enter before correctly discovering Alice’s PIN?
C-10 As soon as Barack took office, he decided to embrace modern tech-
nology by communicating with cabinet members over the Internet
using a device that supports cryptographic protocols. In a first
attempt, Barack exchanges with Tim brief text messages, encrypted
with public-key cryptography, to decide the exact amounts of
bailout money to give to the largest 10 banks in the country. Let
p B and p T be the public keys of Barack and Tim, respectively. A
message m sent by Barack to Tim is transmitted as E pT (m) and the
reply r from Tim to Barack is transmitted as E pB (r ). The attacker
49
Introduction
50
Introduction
51
Introduction
C-18 Many Internet browsers “lock the lock” on an encrypted web site so
long as the digital certificate offered for this site matches the name
for this web server. Explain how this could lead to a false sense of
security in the case of a phishing attack.
C-19 Explain the risks to Bob if he is willing to sign a seemingly random
string using his private key.
C-20 Describe a good solution to the problem of having a group of
students collaborate on a software construction project using the
directory of one of the group members in such a way that it would
be difficult for nonmembers to discover and would not require the
help from a system administrator, assuming that the only access
rights the group leader can modify are those for “everyone.” You
may assume that access rights for directories are “read,” “write,”
and “exec,” where “read” means the files and subdirectories in that
directory can be listed, “write” means members of that directory
can be inserted, deleted, or renamed, and “exec” on a directory
or subdirectory means the user can change his location to that
directory or subdirectory so long as he specifies its exact name.
C-21 Suppose an operating system gives users an automatic second
chance functionality, so that any time a user asks to delete a file
it actually gets put into a special “recycle bin” directory, which is
shared by all users, with its access rights defined so that users can
get their files back even if they forget their names. Describe the
security risks that such a functionality poses.
C-22 Suppose, in a scenario based on a true story, a network computer
virus is designed so as soon as it is copied onto a computer, X, it
simply copies itself to six of X’s neighboring computers, each time
using a random file name, so as to evade detection. The virus itself
does no other harm, in that it doesn’t read any other files and it
doesn’t delete or modify any other files either. What harm would
be done by such a virus and how would it be detected?
Projects
P-1 Implement a “toy” file system, with about a dozen different users
and at least that many directories and files, that uses an access
control matrix to manage access control rights.
P-2 Perform the project of Problem P-1, but use access control lists.
P-3 Perform the project of Problem P-1, but use capabilities to define
the access control rights of each user.
52
Introduction
P-4 Perform a statistical analysis of all the spam you get in a week,
classifying each as to the types of attacks they are.
P-5 Implement a toy symmetric cryptosystem based on the following
method.
a. Keys are 16-bit values.
b. Messages are strings with an even number of characters. One
can always add a blank at the end of an odd-length string.
c. The encryption of a message M of length n (in bytes) is given
by
EK ( M) = M ⊕ (K ||K || · · · ),
where the key K is repeated n/2 times.
d. The decryption algorithm for a ciphertext C is the same as the
encryption algorithm:
DK (C ) = C ⊕ (K ||K || · · · ).
Chapter Notes
The ten principles of computer security are from the seminal paper by Saltzer and
Schroeder [86], who caution that the last two principles (work factor and com-
promise recording) are derived from physical security systems and “apply only
imperfectly to computer systems.” The open design principle was first formulated
in a paper by 19th-century French cryptographer Auguste Kerckhoffs [47]. Bruce
Schneier’s Crypto-Gram Newsletter has a well-written article on secrecy, security,
and obscurity [88]. A contemporary introduction to cryptography and its use in
computer systems is given in the book by Ferguson, Schneier and Konho [30]. The
redundancy of natural language was first formally studied by Claude Shannon in
his pioneering paper defining the information-theoretic concept of entropy [91].
Usability issues for email encryption are the subject of an experimental study by
Whitten and Tygar [107].
53
This page intentionally left blank
Physical Security
Contents
1 Physical Protections and Attacks
2 Locks and Safes
2.1 Lock Technology
2.2 Attacks on Locks and Safes
2.3 The Mathematics of Lock Security
3 Authentication Technologies
3.1 Barcodes
3.2 Magnetic Stripe Cards
3.3 Smart Cards
3.4 RFIDs
3 5. Biometrics
4 Direct Attacks Against Computers
4.1 Environmental Attacks and Accidents
4.2 Eavesdropping
4.3 TEMPEST
4.4 Live CDs
4.5 Computer Forensics
5 Special-Purpose Machines
5.1 Automated Teller Machines
5.2 Voting Machines
6 Physical Intrusion Detection
6.1 Video Monitoring
6.2 Human Factors and Social Engineering
7 Exercises
55
Physical Security
56
Physical Security
Figure 1: A pin tumbler lock: (1) When a key is not present, the pin stacks
are pushed down by the springs so that the driver (top) pins span the plug
and the outer casing, preventing the plug from rotating. Image included
with permission [108]. (2) When the correct key is inserted, the ridges of
the key push up the pin stacks so that the cuts of the pin stacks are aligned
with the shear line. Image included with permission [75]. (3) The alignment
of the cuts with the shear line allows the plug to be rotated. Image included
with permission [76].
57
Physical Security
The bottom pins are called the key pins, since they make contact with
the key when the key is inserted. The heights of the respective driver
and key pins can vary. When there is no key inserted, the springs force
the pin stacks down so that the driver pins span the plug and the outer
casing, preventing the plug from rotating. When the appropriate key is
inserted, however, the ridges of the key push up the pin stacks so that the
cut between each key pin and its driver pin is at the point where the plug
meets the outer casing, known as the shear line, allowing the plug to rotate
and open the lock.
Figure 2: Opening a tubular lock: (1) Closed lock. Image included with
permission [68]. (2) After inserting the key. Image included with permis-
sion [69]. (3) Open lock. Image included with permission [70].
58
Physical Security
A third type of lock in common usage is known as the wafer tumbler lock,
depicted in Figure 3. Again, the general principle of the lock relies on
preventing the rotation of a central plug. This time, the obstruction is a
series of wafers that initially sit in a groove at the bottom of the outer
casing. When the appropriate key is inserted, the wafers are raised out
of this groove and allow the plug to rotate. Wafer tumbler locks are used in
cars, filing cabinets, and other medium security applications.
Figure 3: Opening a wafer tumbler lock: (1) Closed lock. Image included
with permission [71]. (2) After inserting the key. Image included with
permission [72]. (3) Open lock. Image included with permission [73].
Combination Locks
59
Physical Security
When the disks are rotated to the correct combination, the notches
line up with the teeth of the pin, allowing it to be removed. Multiple-
dial combination locks are often used in briefcases, bicycle locks, and
other low-security applications, since it is often easy to quickly deduce the
combination because of mechanical imperfections. Single-dial combination
locks are generally considered more secure and are used in a wide variety
of applications, including safes, which are discussed later in this section.
Single-dial locks feature a series of disks attached to a numbered dial. When
the correct combination is entered using the dial, these disks line up in such
a way as to release a clasp or some other locking mechanism.
In an electronic combination lock, an electronic mechanism is used to
operate the lock using electromagnets or motors that are activated through
an event that either turns on or turns off an electric current. The event that
opens an electronic lock could be triggered by a number of different actions,
including the following (which could be used in conjunction):
• An electronic combination: the punching of an appropriate sequence
of numbers on a keypad in a given amount of time
• A magnetic stripe card: a plastic card with a magnetic stripe (Sec-
tion 3.2) that contains an authorizing digital combination
• A smart card: a small computational device contained in a card, as
discussed in Section 3.3, that performs an authorizing computation
to open the lock
• An RFID tag: a small radio frequency identification device that
contains a computational element or memory, as discussed in Sec-
tion 3.4, that either performs an authorizing computation or trans-
mits an electronic combination
• A biometric: a biological characteristic, as discussed in Section 3.5,
that is read and matches a characteristic authorized to open the lock
One advantage of electronic locks is that it is relatively easy to change
the combination or condition that opens such a lock—there is no need to
change a physical plug or swap out pins. For instance, most hotels employ
electronic lock systems for their guest rooms, allowing for easy changing of
locks between consecutive guests staying in the same room.
Another advantage is that electronic locks can be fitted with digital stor-
age devices or can be connected to a communication network to monitor
and manage when the locks are opened and closed. The monitoring can
even log who has entered and left through the doors that are fitted with
the various locks in a building, by using different digital combinations or
opening devices for different people. This type of monitoring was useful,
for example, in determining who murdered a Yale graduate student in 2009.
The monitoring system showed that the student had entered a secured
60
Physical Security
building, but never left, and it also allowed authorities to determine all
the people who had entered the specific room where her body was found.
Electronic locks are also frequently used in audit trails for regulatory com-
pliance, especially in the health care and financial sectors.
Safes
Valuables can be secured against theft by placing them in a safe. Safes
can range from small lockboxes in homes to large, high-security safes in
banks. Safes can feature any of the locking mechanisms discussed in this
chapter, but most high-security models employ a combination dial, with
the possible addition of biometric authentication and electronic auditing.
No safe is impenetrable. In fact, safes are rated by organizations such as
Underwriters Laboratories (UL) in terms of how long it would take a well-
equipped expert to compromise the safe. In their ratings, they consider both
destructive and nondestructive approaches. Owners of safes are advised
to ensure that the response time to alarms is less than the average time
required to crack the safe.
61
Physical Security
Lockpicking
The classic approach to bypassing locks is known as lockpicking, which
exploits mechanical imperfections in the locking mechanism that allow an
attacker to replicate the effect of an authorized entry. (See Figure 5.)
(a) (b)
62
Physical Security
between the key pin and the driver pin is in line with the shear line. At
this point, the plug will further rotate by a tiny amount until it is stopped
by the next binding pin. The driver pin of the previous binding pin will
now sit on a small ledge created by the additional rotation of the plug (it
is “bound”). The attacker then repeats the process for the remaining pins,
identifying and lifting them. When the last pin is picked, all of the pin
breaks are aligned with the shear line, and the rotational force applied by
the tension wrench will open the lock.
It takes a high degree of skill and intuition to determine when a pin
has bound. Lock pickers must practice extensively to recognize the feeling
of a pin binding in a locking mechanism. To make the process easier,
lock pickers often employ a method known as raking or scrubbing. In
this technique, a pick designed to lift several pins simultaneously is run
through the keyhole using a back and forth scrubbing motion in an attempt
to bind more than one pin at the same time. Once several pins are bound,
the remaining pins can be individually picked. Alternatively the attacker
can make another pass with the rake to attempt to set more pins. Pickers
typically use a snake or half-diamond rake for this purpose.
Another approach that can work on inexpensive locks is the use of a
comb pick. For simpler locks an attacker can lift all of the pins simultane-
ously above the shear line using a tool that resembles a hair comb. Once
the pins have been pushed all the way into the lock housing then the plug
is free to rotate. Well-made models combat this weakness by making sure
that the pin stack is long enough to always extend past the shear line.
Lock Bumping
Lock bumping is a technique that received widespread media attention
in 2006. The technique utilizes specially crafted bump keys, which are
unique to each particular brand of lock. (See Figure 6.)
Figure 6: Bump keys and hammer. Photo by Jennie Rogers included with
permission.
63
Physical Security
Several methods can be used to create a key for a given lock. A locksmith
can easily create a key duplicate if the original is available, for instance. It is
not always even necessary to have an original on-hand, however—a mere
photograph of the key can be used if the locksmith is able to deduce the
type of key and approximate its cut. Another technique used sometimes to
“capture” a key consists of briefly taking it and pressing it into a soft, clay-
like material that can later be hardened into a mold for key creation. A key
does not need to be made of metal to be effective.
Another technique that is used to bypass locks is known as key impres-
sioning. An attacker begins with a key blank matched to a specific lock
brand. The top of the blank is polished, and then the key is inserted into the
target lock. A rotational force is applied to the key, which is then jiggled up
and down. The blank is finally removed. Each pin that is not at the shear
line will have left a small scrape on the polished blank. At each scraped
location, the attacker files off a small amount of material. The process is
repeated until no scrapes are created, resulting in a key that can open the
lock. Key impressioning requires the use of keys blanks made of a soft
metal, such as brass. Also, the attacker must use a very precise filing tool,
such as a jeweler’s file.
64
Physical Security
65
Physical Security
Safe Cracking
There are many approaches to safe cracking. The classic approach, often
portrayed in movies, involves a highly skilled expert manipulating the dial
of the safe by feel and sound until they deduce the combination. To pre-
vent this attack, many safe manufacturers include additional components
inside the locking mechanism that are designed to prevent an attacker from
correctly interpreting sounds and tactile clues. In addition, the wheels of
the locking mechanism are often made with light materials such as nylon,
reducing the noise and friction created by manipulating the lock.
66
Physical Security
An attacker may also attempt to drill through the front of the safe to
see the lock’s inner workings or to directly manipulate the lock mechanism.
High-security safes incorporate composite hardplate, which is an extremely
rugged material designed to be resistant to drilling or other structural dam-
age. Only highly specialized drilling equipment can be used to breach these
materials. Brute-force techniques, such as explosives, may be employed,
but often these approaches are impractical, because they risk damaging the
contents of the safe. To further prevent drilling, many safes feature what is
known as a glass relocker, a thin glass plate that resides in the door of the
safe. If this glass is broken, by drilling or some other force, spring-loaded
bolts are released, permanently locking the safe.
Figure 7: A side channel attack vulnerability: the fire escape on the side of
the building may lead to an entry point that is easier to attack than the front
door. Photo by Jennie Rogers included with permission.
67
Physical Security
68
Physical Security
40 × 87 = 83,886,080.
If we know the specific key blank, the search space is much smaller. For
example, for a given key blank with 6 pin stacks and 5 possible key pin
heights, the number of possible keys is
56 = 15,625,
which is still large enough to prevent a brute-force attack. For this reason,
attacks such as picking, key impressioning, and bumping are employed
instead of brute-force techniques.
The mathematics of counting finite collections of objects is known as
combinatorics, by the way, and the above analysis is an example of a
combinatorial argument that quantifies the security of a pin tumbler lock.
Privilege Escalation
Matt Blaze published a paper detailing how an attacker can use combina-
torics to create a master key from an ordinary change key on a master-keyed
lock system. This attack, which is an iterative master-key construction, is
analogous to privilege escalation in computer security, where an attacker
leverages a low-privilege ability into a high-privilege ability.
The attack works as follows. Consider a lock having the same config-
uration of P and D as above. The attacker has a change key and wants to
build a master key using a small number of keys blanks. The only basic
operation used by the attacker is to test whether a given key opens the lock.
For simplicity, we will use the term pin to denote a key pin.
Starting with the first pin stack, the attacker creates D − 1 keys, each
keeping all pins but the first at the same height as in the change key, and
trying all possible variations for the first pin height (except for the height
of the first pin in the change key). The key that results in opening the lock
reveals the height for the first pin of the master key. The process is then
69
Physical Security
repeated for each of the remaining pins, and a final master key is made
using each pin’s successful key. The above attack requires a total number
of key blanks that is at most
P · ( D − 1).
Further Improvements
The search space in this case can be reduced even further, however, depend-
ing on the lock manufacturer. The maximum adjacent cut specification
(MACS) of a lock defines the maximum vertical distance allowed between
any two adjacent key cuts. If this distance is exceeded, the key will have
a steep spike that will be breakable, cause the lock to jam, or prevent a
pin from sitting properly. Removing all sequences that would violate the
MACS of a particular lock from the search space results in a significant
reduction in size. In addition, some master-keyed systems require that the
master key pins are higher on the pin stack than the change keys, which
further reduces the search space.
As another example of combinatorics at work, some brands of single-
dial combination padlocks have mechanical dependencies as a result of
the manufacturing process. As a result of these dependencies, it may be
possible to drastically reduce the number of combinations for testing. On
one brand, which has a dial ranging from 1 to 40 and requires a 3-number
combination, it is possible to reduce the search space from 60,000 (403 ) to
only 80, making a brute-force attack much more feasible.
It is important that single-dial combination locks have some sort of reset
mechanism that is triggered whenever someone attempts to open that lock
after trying a combination. If no such reset mechanism exists, the final digit
of the combination is essentially rendered useless, since it requires a trivial
amount of time to iterate through each final number, trying each one. This
is an example of a measure that prevents a reduction of the search space.
70
Physical Security
3 Authentication Technologies
3.1 Barcodes
Printed labels called barcodes were developed around the middle of the
20th century as a way to improve efficiency in grocery checkout, and are
now used universally in applications as diverse as identifying wildlife.
First-generation barcodes represent data as a series of variable-width, ver-
tical lines of ink, which is essentially a one-dimensional encoding scheme.
(See Figure 8a.)
Some more recent barcodes are rendered as two-dimensional patterns
using dots, squares, or other symbols that can be read by specialized optical
scanners, which translate a specific type of barcode into its encoded infor-
mation. Among the common uses of such barcodes are tracking postage,
purchasing mass merchandise, and ticket confirmation for entertainment
and sporting events. (See Figure 8b.)
(a) (b)
71
Physical Security
Barcode Applications
Developed in the late 1960s, the magnetic stripe card is one of the most per-
vasive means of electronic access control. Currently, magnetic stripe cards
are key components of many financial transactions, such as debit or credit
card exchanges, and are the standard format for most forms of personal
identification, including drivers’ licenses. These cards are traditionally
made of plastic and feature a stripe of magnetic tape contained in a plastic-
like film. Most cards adhere to strict standards set by the International
Organization for Standardization (ISO). These standards dictate the size
of the card, the location of the stripe, and the data format of the information
encoded into the stripe.
The magnetic stripe on standardized cards actually includes three tracks
for storing information. The first track is encoded using a 7-bit scheme,
featuring 6 bits of data and one parity bit per character, with a total of 79
characters. A parity bit is a bit whose value is a combinational function of
the others, such as exclusive-or. Since magnetic stripes cards can potentially
be worn down and subject to physical damage, the parity bit allows a stripe
reader to read a card even if there is a small amount of data loss.
72
Physical Security
The first track of a magnetic stripe card contains the cardholder’s full name
in addition to an account number, format information, and other data at
the discretion of the issuer. This first track is often used by airlines when
securing reservations with a credit card.
The second track is encoded using a 5-bit scheme (4 bits of data and
1 parity bit per character), with a total of 40 characters. This track may
contain the account number, expiration date, information about the issuing
bank, data specifying the exact format of the track, and other discretionary
data. It is most often used for financial transactions, such as credit card or
debit card exchanges.
The third track is much less commonly used.
One vulnerability of the magnetic stripe medium is that it is easy to read
and reproduce. Magnetic stripe readers can be purchased at relatively low
cost, allowing attackers to read information off cards. When coupled with a
magnetic stripe writer, which is only a little more expensive, an attacker can
easily clone existing cards. Because of this risk, many card issuers embed
a hologram into the card, which is harder to reproduce. Most credit cards
also include space for a customer signature, verifying the authenticity of
the card. Unfortunately, many vendors do not always check this signature.
One effective deterrent against card fraud is a requirement for additional
information known only to the owner, such as a personal identification
number (PIN).
ISO standards do not permit vendors to store money on magnetic stripe
cards. Account numbers can be stored instead, which can be used to
access information in remote databases. Still, many organizations use cards
that store contents of monetary value. For example, transportation tickets
often store “money” that is only available for payment of transportation
fees. So, vendors sometimes use proprietary technology that provides
the convenience of storing data on a magnetic stripe in a format storing
“points” or “credits” on the card that have monetary value.
Unfortunately, the use of a format that allows the cards to contain data
that actually has a monetary value poses serious security risks. Because the
money on the card is simply represented by data, attackers who know the
format of the information on the stripe could create their own cards and
provide themselves with free services. For this reason, it is essential that
vendors protect the secrecy of their data format specifications and provide
some means of validating data integrity, such as employing a cryptographic
signature algorithm.
73
Physical Security
74
Physical Security
75
Physical Security
SIM Cards
Many mobile phones use a special smart card called a subscriber identity
module card (SIM card), as show in Figure 9. A SIM card is issued by a
network provider. It maintains personal and contact information for a user
and allows the user to authenticate to the cellular network of the provider.
Many phones allow the user to insert their own SIM card, making the
process of switching phones simple and instantaneous. Standards for SIM
cards are maintained by the Global System for Mobile Communications
(GSM), which is a large international organization.
Figure 9: A SIM card used in a GSM cell phone, together with a dime to
show size. Photo by Dan Rosenberg included with permission.
76
Physical Security
After a SIM card has been authenticated to the network, the SIM card
A8.
produces a 64-bit ciphering key by encoding the user’s key and the previ-
ously sent random number, using another secret algorithm known as
Finally, the phone is ready to make the call, and all communications are
encrypted using the ciphering key with A5, another proprietary algorithm.
Initially, each of the algorithms used in protecting cellphone communi-
cation (A3, A5, and A8) were proprietary algorithms developed by GSM,
and were closely kept secrets. These proprietary algorithms were chosen
over other public options, such as 3DES or AES, because the newly de-
veloped algorithms were optimized for cell phone hardware at the time
and had significantly better performance. In many phones, the A3 and A8
algorithms are implemented as a single algorithm, known as COMP128.
77
Physical Security
GSM Vulnerabilities
78
Physical Security
3.4 RFIDs
Figure 11: An RFID tag, taken from a DVD package, together with a dime
to show size. Photo by Dan Rosenberg included with permission.
Like smart cards, RFID tags must be used in conjunction with a separate
reader or writer. While some RFID tags require a battery, many are passive
and do not. The effective range of RFID varies from a few centimeters to
several meters, but in most cases, since data is transmitted via radio waves,
it is not necessary for a tag to be in the line of sight of the reader.
This technology is being deployed in a wide variety of applications.
Many vendors are incorporating RFID for consumer-product tracking, to
either supplement or replace barcodes. Using RFID tags, a retailer can track
which items are selling best as well as use the tags for theft detection, just
by putting an RFID reader around the entrance to the shop. In addition,
RFID provides an advantage over barcodes in that chips are much more
difficult to replicate than simple ink on paper. Incidentally, RFID chips are
also used to identify and track animals in the wild.
Because RFID chips operate using radio waves, they can release infor-
mation without the need for direct physical contact. As such, it is crucial
that some mechanism is employed to protect the information contained on
RFID chips from unauthorized readers. If no such mechanism were used, a
malicious party could easily steal personal information from a distance.
79
Physical Security
Most modern vehicles feature a key fob that allows the owner to lock, un-
lock, or even start the engine of the vehicle from a distance. These fobs use
RFID technology to communicate with a receiver in the car. Similar devices
are commonly used to allow a driver to remotely open gates or garage
doors. Several security measures are in place to prevent an attacker from
eavesdropping on an RF transmission and recreating the signal, gaining
access to the vehicle or property. The controller chips in the key fob and the
receiver in the vehicle use what is known as a hopping code or rolling code
to accomplish this. The controllers use the same pseudo-random number
generator, so that each device produces the same sequence of unpredictable
numbers.
The challenge is to keep the two sequences synchronized. When the
owner presses a button, say, to unlock doors, the key fob transmits its
hopping code—the next number in the key fob’s sequence (along with a
command instructing the car to open its doors). The receiver in the car
stores a list of the next 256 hopping codes in its sequence, starting from
the last time the key fob and the car synchronized their sequences. If the
hopping code sent by the key fob matches one of these 256 codes, then
the receiver accepts the command and performs the requested action. The
receiver then updates its sequence to the next 256 numbers after the one just
sent by the key fob. Once a number is used, it is never used again. Thus,
even if an attacker can eavesdrop on the communication between the key
fob and the car, he cannot reuse that number to open the car.
The receiver keeps a list of 256 numbers in case the fob and the receiver
become desynchronized. For example, if the button on the key fob is
pressed while it is out of range of the receiver, it uses up the next number in
its sequence. In the event that a fob is used more than 256 times while out
of range, the receiver will no longer accept its transmissions and the two
will need to be resynchronized using a factory reset mechanism.
Because hopping codes are essentially random numbers, it is extremely
unlikely that a key fob would be able to successfully execute a command on
an unmatched receiver. Nevertheless, even though an eavesdropper cannot
reuse a successful communication between a key fob and its receiver, an
attack might be able to capture and replay a signal transmitted while the
fob is out of range. In this case, the receiver will not have incremented
its list of 256 acceptable hopping codes. To take advantage of this, some
car thieves employ a technique where they jam the radio channel used by
a key fob and simultaneously capture the transmission. This prevents the
owner from using their key fob but allows the attacker to unlock or start
the victim’s car by replaying the captured signal.
80
Physical Security
KeeLoq
More recently, the actual algorithms that generates hopping codes have
been subject to cryptographic attacks. The most common algorithm em-
ployed to generate the pseudo-random codes is known as KeeLoq, a pro-
prietary algorithm designed specifically for RFID hardware. The algorithm
requires a 32-bit key, which is then used to encrypt an initialization vector,
which in turn is incremented with each use.
Researchers have developed attacks on KeeLoq stemming from com-
mon key bits being used in certain car models. These attacks allowed
to reconstruct a fob’s encryption key, given a high number of captured
transmissions and several days of computing time. Subsequently, a side-
channel attack completely broke the KeeLoq system by measuring the
power consumption of a key fob during the encryption process and using
this information to recover the encryption key. Once the attacker had
acquired this key, it was possible to clone a remote entry fob after inter-
cepting two consecutive transmissions. It was also demonstrated that it
was possible to use this attack to reset the internal counter of the receiver,
effectively locking owners out of their cars or garages. These weaknesses
in the algorithm have been addressed by increasing the size of the KeeLoq
key to 60 bits, which prevents these attacks, but this change has yet to be
implemented on a mass scale.
Several automobile key fobs and tags for automatic payment systems at gas
stations use an RFID device called Digital Signature Transponder (DST),
which is manufactured by Texas Instruments. A DST stores a 40-bit secret
key and incorporates a proprietary encryption algorithm called DST40.
The main use of a DST is to execute a simple challenge-response protocol,
similar to the one for GSM phones (see Figure 10), where the reader
asks the DST to encrypt a randomly generated challenge to demonstrate
possession of the secret key.
Confirming once again the failure of “security by obscurity,” the DST40
algorithm has been reverse engineered and an attack that recovers the secret
key from two responses to arbitrary challenges has been demonstrated.
This attack allows to create a new device that fully simulates a DST and
can be used to spoof a reader (e.g., to charge gas purchases to the account
of the DST owner).
81
Physical Security
Electronic toll systems allow motor vehicle owners to place an RFID tag
near their dashboards and automatically pay tolls at designated collection
sites. These systems provide great convenience, since they remove the
hassle of dealing with cash and allow drivers to be tolled without coming
to a stop. Unfortunately, many implementations of electronic toll collection
systems provide no encryption mechanism to protect the contents of the
RFID tag.
Because the tag only contains a unique identifier that toll collection sites
use to deduct money from an account, it is not possible to actually alter the
money stored on a user’s account. Still, many tags may be easily cloned,
allowing a malicious party to impersonate a victim and charge tolls to their
account. In addition, it may be possible to create a “digital alibi” in the
event of a crime, if an attacker clones their own tag and places it on another
person’s automobile. If checked, the cloned tag may provide false evidence
that the attacker was not at the scene of the crime.
A typical defense mechanism against cloning attacks is to install cam-
eras to capture photographs of the license plates of vehicles that pass
through toll collection sites. This approach also allows authorities to iden-
tify and impose fines on drivers with missing or expired tags.
Passports
82
Physical Security
e-Passport
symbol
3.5 Biometrics
83
Physical Security
84
Physical Security
Reader
Biometric
Feature vector
Comparison algorithm
Reference vector
matches
t h d
doesn’t
’t match
t h
85
Physical Security
86
Physical Security
87
Physical Security
88
Physical Security
4.2 Eavesdropping
Eavesdropping is the process of secretly listening in on another person’s
conversation. Because of this threat, protection of sensitive information
must go beyond computer security and extend to the environment in which
this information is entered and read. Simple eavesdropping techniques
include using social engineering to allow the attacker to read informa-
tion over the victim’s shoulder, installing small cameras to capture the
information as it is being read, or using binoculars to view a victim’s
monitor through an open window. These direct observation techniques are
commonly referred to as shoulder surfing. Simple eavesdropping can be
prevented by good environmental design, such as avoiding the placement
of sensitive machines near open windows. Nonetheless, more complex
techniques of eavesdropping have emerged that are more difficult to pre-
vent.
Wiretapping
Given physical access to the cables of a network or computer, it may be
possible for an attacker to eavesdrop on all communications through those
cables. Many communication networks employ the use of inexpensive
coaxial copper cables, where information is transmitted via electrical im-
pulses that travel through the cables. Relatively inexpensive means exist
that measure these impulses and can reconstruct the data being transferred
through a tapped cable, allowing an attacker to eavesdrop on network
traffic. These wiretapping attacks are passive, in that there is no alteration
of the signal being transferred, making them extremely difficult to detect.
(See Figure 14.)
89
Physical Security
Many networks, including much of the telephone network and most com-
puter networks, use twisted pair cables, which feature two wires, usually
copper, that are entwined to eliminate electromagnetic interference. Un-
shielded twisted pair (UTP) cable is inexpensive compared to coaxial or
fiber optic cable. These cables are subject to the same types of signal leakage
attacks as coaxial cable, without a loss of signal strength.
A more common and less expensive approach, however, is to briefly
disconnect an Ethernet cable, insert a passive wiretapping device, and
reconnect it. While this may go undetected by human users, many intrusion
detection systems are triggered by the disconnection of network cables.
High-security networks often employ the use of fiber optic cable as
a more secure alternative. Fiber optic cables transmit light rather than
electricity, which prevents the signal leakage that occurs in coaxial cable.
It is still sometimes possible to eavesdrop on communications transmitted
over fiber optic cable, however. An attacker can place a fiber optic cable in
a micro-bend clamping device, which holds the cable in a bent position,
where it leaks a tiny amount of light. An attached photo sensor can
transmit the information via an optical-electrical converter, where it can be
reinterpreted by a computer. This attack results in a tiny drop in the signal
being transmitted over the network, so it may be detected by fiber optic
intrusion detection systems. More advanced attacks may employ means of
reboosting the signal to make up for this signal drop.
Both of these attacks demonstrate the importance of protecting not
only computer systems, but also the network cables over which sensitive
information is transmitted. Attacks on fiber optic cables are expensive and
may be detected, but are still a possibility. Many organizations use end-
to-end encryption to protect data being transmitted over the network—
eavesdropping is rendered useless if the contents are not readable by the
attacker.
90
Physical Security
Van Eck demonstrated that these emissions could be read from a dis-
tance and used to reconstruct the contents of a CRT screen. Since RF
emissions can travel through many nonmetallic objects, computer monitors
could be read regardless of whether they are within eye-shot of an attacker.
More recent research has extended this principle to modern Liquid
Crystal Display (LCD) screens. Fortunately, preventative measures have
been developed that utilize techniques to shield monitors and reduce these
emissions, but they are rarely deployed outside of high-security govern-
ment applications, due to a low prevalence of this type of attack and the
expensive cost of equipment necessary to perform it. In an environment
where other attacks are impossible due to security measures, however, this
form of eavesdropping is certainly within the realm of possibility.
Optical Emissions
A more recent attack has emerged that allows eavesdropping using emis-
sions in the range of visible light, rather than the RF range. The attack
requires the use of a photosensor, which is relatively cheap compared to
the expensive equipment needed for an RF eavesdropping attack. CRT
displays work by using an electron beam that scans the surface of the
screen, refreshing each pixel individually at incredibly fast speeds. At the
moment the electron beam hits a pixel, there is a brief burst of brightness,
which makes this attack possible. A photosensor can be trained on a wall in
the room, and by analyzing changes in the light of the room and applying
imaging technology to reduce “noise,” it is possible to reconstruct an image
of the contents of the screen. This attack has been proven to work from up to
50 meters away, requiring only that the attacker can train a photosensor on
any wall in the room. Fortunately, since the attack relies on visible light, as
long as a room is not in an attacker’s line of sight, it is safe from this attack.
Also, this attack does not work on LCD monitors, because of differences
in how pixels are refreshed on the screen. Like RF eavesdropping, this
attack is possible, but considered unlikely to occur in most contexts, and,
especially with the advent of LCD screens, it is not expected to be a high-
priority security concern in the future.
Acoustic Emissions
In addition to RF radiation and visible light, computer operations often
result in another byproduct, sound. Recent research has proven it possible
to use captured acoustic emissions to compromise computer security. These
techniques are still in their infancy, so they are unlikely to occur outside a
lab, but they may become security concerns later on.
91
Physical Security
sound recording
device
microphone to
capture keystroke
sounds
Hardware Keyloggers
A keylogger is any means of recording a victim’s keystrokes, typically
used to eavesdrop passwords or other sensitive information. There are
many ways of implementing software keyloggers. A newer innovation,
92
Physical Security
93
Physical Security
4.3 TEMPEST
TEMPEST is a U.S. government code word for a set of standards for
limiting information-carrying electromagnetic emanations from computing
equipment. More broadly, the term “TEMPEST” has come to be used for
the study, limitation, and protection of all types of information-carrying
emanations that come from computing equipment and devices. In terms of
a standard, TEMPEST establishes three zones or levels of protection:
1. An attacker has almost direct contact with the equipment, such as in
an adjacent room or within a meter of the device in the same room.
Emanation Blockage
One approach to limiting the release of information-carrying emanations is
to enclose the computing equipment in a way that blocks those emanations
from escaping into the general environment. Some examples of this type of
emanation limitation include the following:
• To block visible light emanations, we can enclose sensitive equipment
in a windowless room.
94
Physical Security
Emanation Masking
95
Physical Security
96
Physical Security
97
Physical Security
98
Physical Security
5 Special-Purpose Machines
There are certain types of computing machines that have a special purpose,
that is, particular jobs that they are specialized to do. These jobs might
involve sensitive information or tasks, of course, which presents particular
security requirements. In this section, we study two such machines—
automated teller machines and voting machines—and we discuss the par-
ticular types of risks that these machines have with respect to both their
physical and digital security.
99
Physical Security
ATM Encryption
3DES Encryption
Bank
ATM
Figure 19: ATM communications are typically encrypted using the 3DES
symmetric cryptosystem. (“Bank”) © Zlatko Guzmic/Shutterstock; (“ATM”)
© Glowimages-Artbox/Alamy
The 3DES secret keys installed on an ATM are either loaded on-site by
technicians or downloaded remotely from the ATM vendor. Because the
confidentiality of all transactions on an ATM relies on protecting the secrecy
of the cryptographic keys, any attempts to access the cryptoprocessor will
destroy the keys. It should be noted that since early ATM machines used the
obsolete DES cryptosystem with 56-bit keys, the 3DES cryptosystem was
chosen over the more secure AES cryptosystem because 3DES is backward
compatible with DES and thus moving to 3DES was seen as a simple and
inexpensive way to increase the key size. In addition, AES was not finalized
as a standard until 2001, roughly three years after 3DES was standardized.
100
Physical Security
Attacks on ATMs
There are several techniques used to perpetrate ATM fraud. One popular
attack involves the use of a thin sleeve of plastic or metal known as a
Lebanese loop. A perpetrator inserts this sleeve into the card slot of an
ATM. When a customer attempts to make a transaction and inserts their
credit card, it sits in the inconspicuous sleeve, out of sight from the cus-
tomer, who thinks that the machine has malfunctioned. After the customer
leaves, the perpetrator can then remove the sleeve with the victim’s card.
Another technique makes use of a device known as a skimmer, which
reads and stores magnetic stripe information when a card is swiped. An
attacker can install a skimmer over the card slot of an ATM and store cus-
tomers’ credit information without their knowledge. Later, this information
can be retrieved and used to make duplicates of the original credit cards.
Finally, some scammers may even install fake ATMs in remote locations
to capture both credit/debit cards and PINs at the same time. These fake
ATMs typically respond with a fake error message after the cards and PINs
have been captured, so as not to arouse the suspicions of the users.
In many cases, the card number or physical card is all that is necessary to
make financial transactions, but if an attacker wishes to withdraw money
from an ATM or make a debit transaction, a PIN is also required. Perpe-
trators may employ any number of eavesdropping techniques to acquire
PINs, including installing cameras at ATM locations. Some attackers may
install fake keypads that record customer PINs on entry. Collectively, these
attacks stress the importance of close surveillance at ATM sites. Cameras
and regular security checks are effective at deterring attacks as well as
identifying culprits.
101
Physical Security
102
Physical Security
103
Physical Security
104
Physical Security
105
Physical Security
7 Exercises
For help with exercises, please visit securitybook.net.
Reinforcement
R-1 Would increasing the number of pins in the design of a pin tumbler
lock increase its security?
R-2 Would increasing the number of available pin heights in the design
of a pin tumbler lock increase its security?
R-3 What do billiards and lock bumping have in common?
R-4 Given a change key for a certain type of lock, describe how to
derive from it a bump key that works with all the locks of that
type.
R-5 What is the full theoretical size of the search space for a pin tumbler
lock that has 30 possible key blanks and 8 pins, each with 12
different distinct heights? What is the corresponding theoretical
size of the search space for the corresponding iterative master-key
construction?
R-6 Consider a pin tumbler lock with 5 pins and 8 pin heights. Explain
why it is not actually possible to have 85 different change keys.
R-7 The Acme Combination is rated as a two-hour lock, meaning that
it takes two hours to crack this lock by an experienced thief. The
Smacme company has a half-hour lock that looks exactly the same
as the Acme lock and is much cheaper to buy. The XYZ Company
wanted to save money, so they bought one Acme lock and one
Smacme lock. They put one on their front door and one on the back
door of their building. Explain how an experienced thief should be
able to break into the XYZ Company’s building in about an hour or
less.
R-8 Explain why storing secret encryption/decryption keys in a remov-
able drive helps defend against cold boot attacks.
R-9 Among radio-frequency, optical, and radio emissions, which poses
the most significant privacy threat for a user? Consider the cases of
a home office, public library, and university department.
R-10 Explain why knowing in which language the user is typing helps
perform an eavesdropping attack based on analyzing acoustic key-
board emissions.
106
Physical Security
R-11 Discuss whether barcodes are more or less secure than magnetic
stripe cards.
R-12 Describe an application where smart cards provide sufficient secu-
rity but magnetic stripe cards do not.
R-13 What are the main security vulnerabilities of SIM cards?
R-14 What happens if you accidentally press a car key fob 257 times
while being far away from the car?
R-15 A salesperson at a high-end computer security firm wants to sell
you a protective cover for your passport, which contains an RFID
tag inside storing your sensitive information. The salesperson’s
solution costs “only” $79.99 and protects your passport from being
read via radio waves while it is in your pocket. Explain how you
can achieve the same thing for under $3.00.
R-16 How can you check if a public computer has a USB keylogger
installed?
R-17 Describe which properties, such as universality, distinctiveness,
etc., each of the following biometric identification characteristics
do and do not possess: DNA, dental x-ray, fingernail length, and
blood type.
Creativity
C-1 Describe a simple modification of the design of pin tumbler locks
to defend against lock-bumping attacks.
C-2 For safety reasons, external locked doors on commercial buildings
have mechanisms for people on the inside to escape without using
a key or combination. One common mechanism uses an infrared
motion detector to open an electronic lock for people moving to-
wards a door from the inside. Explain how an air gap under such
an external door could be exploited to open that door from the
outside?
C-3 A group of n pirates has a treasure chest and one unique lock and
key for each pirate. Using hardware that is probably already lying
around their ship, they want to protect the chest so that any single
pirate can open the chest using his lock and key. How do they set
this up?
C-4 A group of n red pirates and a group of n blue pirates have a shared
treasure chest and one unique lock and key for each pirate. Using
hardware that is probably already lying around their two ships,
they want to protect the chest so that any pair of pirates, one red
107
Physical Security
and one blue, can open the chest using their two locks and keys, but
no group of red or blue pirates can open the chest without having at
least one pirate from the other group. How do they set this up?
C-5 A group of four pirates has a treasure chest and one unique lock
and key for each pirate. Using hardware that is probably already
lying around their ship, they want to protect the chest so that
any subset of three of these pirates can open the chest using their
respective locks and keys, but no two pirates can. How do they set
this up?
C-6 A thief walks up to an electronic lock with a 10-digit keypad and
he notices that all but three of the keys are covered in dust while
the 2, 4, 6, and 8 keys show considerable wear. He thus can safely
assume that the 4-digit code that opens the door must be made up
of these numbers in some order. What is the worst case number
of combinations he must now test to try to open this lock using a
brute-force attack?
C-7 You want to plant a bug in Company X’s office to acquire business
intelligence because they are a competitor. The package needs to
get into their server room and get hooked up to sensitive hardware.
You know the complex hires several guards from a private security
company that regularly patrol and check for authentication by
using well-known badges. You know that they regularly outsource
several functions including janitorial staff, pest control, and pur-
chasing IT equipment (think Staples delivery trucks). These jobs
have a high turnover rate, but require authentication in order to get
access to the premises in the form of a work order for IT supplies
and pest control. The janitorial staff is a recurring service, but
with a lower turnover rate. They are also periodically inspected
by officials like the city or OSHA (Occupational Safety and Health
Administration, an agency of the United States Department of
Labor), but are usually provided with advanced notice of their
arrival. What is your high-level plan of action? A guard challenges
you when you enter, how do you continue your mission? What is
your legend? What is your story? Why is this a good plan? What
are your options for acquiring access to sensitive areas? You realize
you are a target to this attack. How will you defend against it?
C-8 You are planning an urban exploration journey into the abandoned
train tunnel of Providence. It has two ends, one of which is in
a place you vaguely know, in the woods off the road, and the
other is near a moderately populated street corner. Each end is
secured with a simple padlock. The doors are clearly marked
“no trespassing.” Which end do you select and why? How do
108
Physical Security
you justify being at the end of the tunnel if you are observed and
questioned? What are some of the dangers of this operation? What
time of day do you go on this trip? Weekday or weekend?
C-9 A variation of the following biometric authentication protocol was
experimentally tested several years ago at immigration check-
points in major U.S. airports. A user registers in person by show-
ing her credentials (e.g., passport and visa) to the registration
authority and giving her fingerprint (a “palmprint” was actually
used). The registration authority then issues to the user a tamper-
resistant smartcard that stores the reference fingerprint vector and
can execute the matching algorithm. The checkpoint is equipped
with a tamper resistant admission device that contains a fingerprint
reader and a smartcard reader. The user inserts her smartcard
and provides her fingerprint to the device, which forwards it to
the smartcard. The smartcard executes the comparison algorithms
and outputs the result (“match” or “no match”) to the device,
which admits or rejects the user accordingly. Clearly, an attacker
can defeat this scheme by programming a smartcard that always
outputs “match.” Show how to modify the scheme to make it more
secure. Namely, the admission device needs to make sure that
it is interacting with a valid smartcard issued by the registration
authority. You can assume that the smartcard can perform cryp-
tographic computations and that the admission device knows the
public key of the registration authority. The attacker can program
smartcards and is allowed to have an input-output interaction with
a valid smartcard but cannot obtain the data stored inside it.
C-10 To save on the cost of production and distribution of magnetic
stripe cards, a bank decides to replace ATM cards with printed two-
dimensional barcodes, which customers can download securely
from the bank web site, and to equip ATM machines with barcode
scanners. Assume that the barcode contains the same information
previously written to the magnetic stripe of the ATM card. Discuss
whether this system is more or less secure than traditional ATM
cards.
C-11 A bank wants to store the account number of its customers (an 8-
digit number) in encrypted form on magnetic stripe ATM cards.
Discuss the security of the following methods for storing the ac-
count number against an attacker who can read the magnetic
stripe: (1) store a cryptographic hash of the account number; (2)
store the ciphertext of the account number encrypted with the
bank’s public key using a public-key cryptosystem; (3) store the
109
Physical Security
110
Physical Security
Projects
P-1 Write a detailed comparison of the features of two high-security
locks, Medeco M3 and Abloy. Discuss whether they are resilient to
the attacks described in this chapter.
Java
P-2 Using the Java Card Development Kit, implement a vending card
application that supports the following operations: add value to
the card, pay for a purchase, and display the available balance.
The vending card should authenticate and distinguish between
two types of readers, those that can add value and those that can
decrease value. Both readers can obtain balance information.
P-3 Design and implement a program simulating the main security
functions of an ATM machine. In particular, your system should
authenticate users based on a PIN and should transmit data to
the bank in encrypted form. You should reduce the sensitive
information stored by the ATM machine in between transactions
to a minimum.
P-4 Write a term paper that discusses the different kinds of RFIDs,
including both self-powered and not. Address privacy concerns
raised by wide-spread RFID use, such as in e-passports. Use
research articles available on the Internet as source material.
P-5 Using a conductive material, such as aluminum foil, construct a
Faraday cage. Make it big enough to hold a cellphone or portable
FM radio receiver and confirm that it blocks RF signals to such de-
vices. Next, experiment with the size of holes in the exterior, to find
the size of holes that allows RF signals to reach the device inside.
Write a report documenting your construction and experiments.
Include photographs if possible.
111
Physical Security
Chapter Notes
Jennie Rogers contributed material to Section 2 (Locks and Safes). Basics lock
picking techniques are described in course notes by Matt Blaze [8] and in the”
Guide to Lock Picking” by Ted Tool [102]. For more information on safe-cracking,
refer to the paper “Safe-cracking for the Computer Scientist” by Matt Blaze [9].
The attack on the Medeco Biaxial system for locks is due to Tobias and Bluz-
manis [101] The iterative master-key construction attack is presented by Matt
Blaze [7]. The differential power analysis technique is described by Kocher,
Jaffe and Jun [49]. Messerges, Dabbish and Sloan have done pioneering work
on side-channels attacks on smart cards, showing that the RSA cryptosystem is
vulnerable to differential power analysis [59]. An overview of GSM’s encryption
technology is provided in Jeremy Quirke’s article “Security in the GSM System”
[80]. Cloning techniques for GSM SIM cards based on side-channel attacks are
presented by Rao, Rohatgi, Scherzer and Tinguely [81]. Several attacks have been
demonstrated that completely compromise the KeeLoq and DST algorithms used
in popular RFID devices [11, 19, 42, 67]. Jain, Ross and Prabhakar provide an
overview of the subject of biometric recognition [43]. The collection of articles
edited by Tuyls, Skoric and Kevenaar provides an advanced coverage of the
subject of privacy protection for biometric authentication [104]. Di Crescenzo,
Graveman, Ge and Arce propose a formal model and efficient constructions of
approximate message authentication codes, with applications to private biometric
authentication [25]. Wim van Eck pioneered the technique of eavesdropping on
CRT displays by analyzing their radio frequency emissions [105]. Markus Kuhn
has done notable work on eavesdropping techniques using radio frequency and
optical emissions [50, 51, 52]. Adi Shamir and Eran Tromer have investigated
acoustic cryptanalysis of CPUs [90]. Acoustic eavesdropping attacks on keyboards
are discussed by Asonov and Agrawal [2] and by Zhuang, Zhou and Tygar [111].
A survey of results on acoustic eavesdropping is written by Adi Purwono [79].
Wright, Kleiman, and Shyaam debunk the myth of the possibility of data recovery
after more than one pass of overwriting [110]. The cold boot attack to recover
cryptographic keys from the RAM of a computer is due to Halderman et al. [38].
Electronic voting technologies and their risks are discussed in the book “Brave
New Ballot” by Avi Rubin [85]. A security study by Feldman, Halderman and
Felten found significant vulnerabilities in a Diebold voting machine [29].
112
Operating Systems Security
Contents
113
Operating Systems Security
114
Operating Systems Security
Operating System
Hardware
Input/Output Devices
The input/output devices of a computer include things like its keyboard,
mouse, video display, and network card, as well as other more optional
devices, like a scanner, Wi-Fi interface, video camera, USB ports, and other
input/output ports. Each such device is represented in an operating system
using a device driver, which encapsulates the details of how interaction
with that device should be done. The application programmer interface
115
Operating Systems Security
System Calls
Since user applications don’t communicate directly with low-level hard-
ware components, and instead delegate such tasks to the kernel, there
must be a mechanism by which user applications can request the kernel to
perform actions on their behalf. In fact, there are several such mechanisms,
but one of the most common techniques is known as the system call, or
syscall for short. System calls are usually contained in a collection of
programs, that is, a library such as the C library (libc), and they provide
an interface that allows applications to use a predefined series of APIs
that define the functions for communicating with the kernel. Examples
of system calls include those for performing file I/O (open, close, read,
write) and running application programs (exec). Specific implementation
details for system calls depend on the processor architecture, but many
systems implement system calls as software interrupts—requests by the
application for the processor to stop the current flow of execution and
switch to a special handler for the interrupt. This process of switching
to kernel mode as a result of an interrupt is commonly referred to as a
trap. System calls essentially create a bridge by which processes can safely
facilitate communication between user and kernel space. Since moving into
kernel space involves direct interaction with hardware, an operating system
limits the ways and means that applications interact with its kernel, so as
to provide both security and correctness.
1.2 Processes
The kernel defines the notion of a process, which is an instance of a program
that is currently executing. The actual contents of all programs are initially
stored in persistent storage, such as a hard drive, but in order to actually be
executed, the program must be loaded into random-access memory (RAM)
and uniquely identified as a process. In this way, multiple copies of the
same program can be run by having multiple processes initialized with
116
Operating Systems Security
the same program code. For example, we could be running four different
instances of a word processing program at the same time, each in a different
window.
The kernel manages all running processes, giving each a fair share of the
computer’s CPU(s) so that the computer can execute the instructions for all
currently running applications. This time slicing capability is, in fact, what
makes multitasking possible. The operating system gives each running
process a tiny slice of time to do some work, and then it moves on to the
next process. Because each time slice is so small and the context switching
between running processes happens so fast, all the active processes appear
to be running at the same time to us humans (who process inputs at a much
slower rate than computers).
Process IDs
Each process running on a given computer is identified by a unique non-
negative integer, called the process ID (PID). In Linux, the root of the
process tree is init, with PID 0. In Figure 2, we show an example of the
process tree for a Linux system, in both a compact form and an expanded
form.
117
Operating Systems Security
init-+-Xprt init(1)-+-Xprt(1166)
|-6*[artsd] |-artsd(29493,shitov)
|-atd |-artsd(18719,accharle)
|-automount---22*[{automount}] |-artsd(25796,mdamiano)
|-avahi-daemon---avahi-daemon |-artsd(16834,mchepkwo)
|-3*[bonobo-activati---{bonobo-activati}] |-artsd(25213,xl1)
|-console-kit-dae---63*[{console-kit-dae}] |-artsd(27782,wc9)
|-cron |-atd(4031,daemon)
|-cupsd |-automount(3434)-+-{automount}(3435)
|-dbus-daemon | |-{automount}(3436)
|-dhclient3 | |-{automount}(3439)
|-dirmngr | |-{automount}(3442)
|-esd | |-{automount}(3443)
|-gdm---gdm-+-Xorg | |-{automount}(3444)
| `-gdmlogin | |-{automount}(3445)
|-6*[getty] | |-{automount}(3446)
|-gmond---6*[{gmond}] | |-{automount}(3447)
|-hald---hald-runner-+-hald-addon-acpi | |-{automount}(3448)
| |-hald-addon-inpu | |-{automount}(3449)
| `-hald-addon-stor | |-{automount}(3450)
|-hcid | |-{automount}(3451)
|-hogd | |-{automount}(3452)
|-inetd | |-{automount}(3453)
|-klogd | |-{automount}(3454)
|-lisa | |-{automount}(3455)
|-master-+-pickup | |-{automount}(3456)
| `-qmgr | |-{automount}(3457)
|-monit---{monit} | |-{automount}(3458)
|-nscd---8*[{nscd}] | |-{automount}(3459)
|-ntpd | `-{automount}(3460)
|-portmap |-avahi-daemon(2772,avahi)---avahi-daemon(2773)
|-privoxy |-bonobo-activati(6261,pmartada)---{bonobo-activati}(6262)
|-rpc.statd |-bonobo-activati(2059,jlalbert)---{bonobo-activati}(2060)
|-rwhod---rwhod |-bonobo-activati(2684,bcrow)---{bonobo-activati}(2690)
|-sshd---sshd---sshd---tcsh---pstree |-console-kit-dae(31670)-+-{console-kit-dae}(31671)
|-syslogd | |-{console-kit-dae}(31673)
|-system-tools-ba | |-{console-kit-dae}(31674)
|-udevd | |-{console-kit-dae}(31675)
|-vmnet-bridge | |-{console-kit-dae}(31676)
|-2*[vmnet-dhcpd] | |-{console-kit-dae}(31677)
|-vmnet-natd | |-{console-kit-dae}(31679)
|-2*[vmnet-netifup] | |-{console-kit-dae}(31680)
|-xfs
`-zhm …
(a) (b)
Process Privileges
118
Operating Systems Security
Inter-Process Communication
119
Operating Systems Security
Signals
Windows supports signals in its low-level libraries, but does not make
use of them in practice. Instead of using signals, Windows relies on the
other previously mentioned techniques and additional mechanisms known
as remote procedure calls (RPC), which essentially allow a process to call
a subroutine from another process’s program. To terminate a process,
Windows makes use of a kernel-level API appropriately named Termi-
nateProcess(), which can be called by any process, and will only execute
if the calling process has permission to kill the specified target.
Computers today run dozens of processes that run without any user in-
tervention. In Linux terminology, these background processes are known
as daemons, and are essentially indistinguishable from any other process.
They are typically started by the init process and operate with varying levels
of permissions. Because they are forked before the user is authenticated,
they are able to run with higher permissions than any user, and survive the
end of login sessions. Common examples of daemons are processes that
control web servers, remote logins, and print servers.
Windows features an equivalent class of processes known as services.
Unlike daemons, services are easily distinguishable from other processes,
and are differentiated in monitoring software such as the Task Manager.
120
Operating Systems Security
121
Operating Systems Security
File Permissions
File permissions are checked by the operating system to determine if a
file is readable, writable, or executable by a user or group of users. This
permission data is typically stored in the metadata of the file, along with
attributes such as the type of file. When a process attempts to access a
file, the operating system checks the identity of the process and determines
whether or not access should be granted, based on the permissions of the
file.
Several Unix-like operating systems have a simple mechanism for file
permissions known as a file permission matrix. This matrix is a represen-
tation of who is allowed to do what to the file, and contains permissions
for three classes, each of which features a combination of bits. Files have
an owner, which corresponds to the uid of some user, and a group, which
corresponds to some group id.
First, there is the owner class, which determines permissions for the
creator of the file. Next is the group class, which determines permissions
for users in the same group as the file. Finally, the others class determines
permissions for users who are neither the owner of the file nor in the same
group as the file.
Each of these classes has a series of bits to determine what permissions
apply. The first bit is the read bit, which allows users to read the file. Second
is the write bit, which allows users to alter the contents of the file. Finally,
there is the execute bit, which allows users to run the file as a program
or script, or, in the case of a directory, to change their current working
directory to that one. An example of a file permission matrix for a set of
files in a directory is shown in Figure 4.
122
Operating Systems Security
123
Operating Systems Security
Stack
Dynamic
BSS
Data
Text
124
Operating Systems Security
Each of the five memory segments has its own set of access permissions
(readable, writable, executable), and these permissions are enforced by the
operating system. The text region is usually read-only, for instance, because
it is generally not desirable to allow the alteration of a program’s code
during its execution. All other regions are writable, because their contents
may be altered during a program’s execution.
An essential rule of operating systems security is that processes are not
allowed to access the address space of other processes, unless they have
explicitly requested to share some of that address space with each other. If
this rule were not enforced, then processes could alter the execution and
data of other processes, unless some sort of process-based access control
system were put in place. Enforcing address space boundaries avoids many
serious security problems by protecting processes from changes by other
processes.
In addition to the segmentation of address space in order to adhere to
the Unix memory model, operating systems divide the address space into
two broad regions: user space, where all user-level applications run, and
kernel space, which is a special area reserved for core operating system
functionality. Typically, the operating system reserves a set amount of
space (one gigabyte, for example), at the bottom of each process’s address
space, for the kernel, which naturally has some of the most restrictive access
privileges of the entire memory.
125
Operating Systems Security
Virtual Memory
Even if all the processes had address spaces that could fit in memory, there
would still be problems. Idle processes in such a scenario would still retain
their respective chunks of memory, so if enough processes were running,
memory would be needlessly scarce.
To solve these problems, most computer architectures incorporate a
system of virtual memory, where each process receives a virtual address
space, and each virtual address is mapped to an address in real memory
by the virtual memory system. When a virtual address is accessed, a
hardware component known as the memory management unit looks up the
real address that it is mapped to and facilitates access. Essentially, processes
are allowed to act as if their memory is contiguous, when in reality it may be
fragmented and spread across RAM, as depicted in Figure 6. Of course,
this is useful, as it allows for several simplifications, such as supporting
applications that index into large arrays as contiguous chunks of memory.
Another
Program
Hard Drive
126
Operating Systems Security
Page Faults
There is a slight time trade-off for benefit we get from virtual memory,
however, since accessing the hard drive is much slower than RAM. Indeed,
accessing a hard drive can be 10,000 times slower than accessing main
memory.
So operating systems use the hard drive to store blocks of memory that
are not currently needed, in order to have most memory accesses being in
main memory, not the hard drive. If a block of the address space is not
accessed for an extended period of time, it may be paged out and written to
disk. When a process attempts to access a virtual address that resides in a
paged out block, it triggers a page fault.
When a page fault occurs, another portion of the virtual memory system
known as the paging supervisor finds the desired memory block on the hard
drive, reads it back into RAM, updates the mapping between the physical
and virtual addresses, and possibly pages out a different unused memory
block. This mechanism allows the operating system to manage scenarios
where the total memory required by running processes is greater than the
amount of RAM available. (See Figure 7.)
“Page fault,
Process let me fix that.”
Paging supervisor
old
Blocks in
RAM memory:
3. Paging
g g supervisor
p locates requested
q block
on the disk and brings it into RAM memory.
127
Operating Systems Security
There are two main implementations of VMs. The first is emulation, where
the host operating system simulates virtual interfaces that the guest oper-
ating system interacts with. Communications through these interfaces are
translated on the host system and eventually passed to the hardware. The
benefit of emulation is that it allows more hardware flexibility. For example,
one can emulate a virtual environment that supports one processor on a ma-
chine running an entirely different processor. The downside of emulation
is that it typically has decreased performance due to the conversion process
associated with the communication between the virtual and real hardware.
The second VM implementation is known simply as virtualization, and
removes the above conversion process. As a result, the virtual interfaces
within the VM must be matched with the actual hardware on the host
machine, so communications are passed from one to the other seamlessly.
This reduces the possibilities for running exotic guest operating systems,
but results in a significant performance boost.
128
Operating Systems Security
Advantages of Virtualization
Virtualization has several advantages:
• Hardware Efficiency. Virtualization allows system administrators to
host multiple operating systems on the same machine, ensuring an
efficient allocation of hardware resources. In these scenarios, the
hypervisor is responsible for effectively managing the interactions
between each operating system and the underlying hardware, and
for ensuring that these concurrent operations are both efficient and
safe. This management may be very complex—one set of hardware
may be forced to manage many operating systems simultaneously.
129
Operating Systems Security
2 Process Security
To protect a computer while it is running, it is essential to monitor and
protect the processes that are running on that computer.
Operating
System
130
Operating Systems Security
Hibernation
Modern machines have the ability to go into a powered-off state known
as hibernation. While going into hibernation, the operating system stores
the entire contents of the machine’s memory into a hibernation file on disk
so that the state of the computer can be quickly restored when the system
is powered back on. Without additional security precautions, hibernation
exposes a machine to potentially invasive forensic investigation.
Since the entire contents of memory are stored into the hibernation file,
any passwords or sensitive information that were stored in memory at the
time of hibernation are preserved. A live CD attack can be performed to
gain access to the hibernation file. Windows stores the hibernation file
as C:\hiberfil.sys. Security researchers have shown the feasibility of re-
versing the compression algorithm used in this file, so as to extract a view-
able snapshot of RAM at the time of hibernation, which opens the possibil-
ity of the attack shown in Figure 9.
131
Operating Systems Security
Attacks that modify the hiberfil.sys file have also been demonstrated, so
that the execution of programs on the machine is altered when the machine
is powered on. Interestingly, Windows does not delete the hibernation
file after resuming execution, so it may persist even after the computer is
rebooted several times. A related attack on virtual memory page files, or
swap files, is discussed in Section 3.1. To defend against these attacks,
hard disk encryption should be used to protect hibernation files and swap
files.
Event Logging
Operating systems therefore feature built-in systems for managing event
logging. For example, as depicted in Figure 10, Windows includes an
event logging system known simply as the Windows Event Log.
132
Operating Systems Security
133
Operating Systems Security
Process Monitoring
There are several scenarios where we would like to find out exactly which
processes are currently running on our computer. For example, our com-
puter might be sluggish and we want to identify an application using up
lots of CPU cycles or memory. Or we may suspect that our computer
has been compromised by a virus and we want to check for suspicious
processes. Of course, we would like to terminate the execution of such a
misbehaving or malicious process, but doing so requires that we identify
it first. Every operating system therefore provides tools that allow users
to monitor and manage currently running processes. Examples include
the task manager application in Windows and the ps, top, pstree, and kill
commands in Linux.
Process Explorer
Process monitoring tools might seem like they are aimed at expert users or
administrators, since they present a detailed listing of running processes
and associated execution statistics, but they are useful tools for ordinary
users too. In Figure 11, we show a screen shot of just such a tool—Process
Explorer—which is a highly customizable and useful tool for monitoring
processes in the Microsoft Windows operating system.
Process Explorer is a good example of the kind of functionality that can
be provided by a good process monitoring tool. The tool bar of Process
Explorer contains various buttons, including one for terminating processes.
The mini graphs show the usage histories of CPU time, main memory, and
I/O, which are useful for identifying malicious or misbehaving processes.
The processes tree pane shows the processes currently running and has a
tabular format.
The components of Process Explorer provide a large amount of infor-
mation for process monitoring and managing. The left column (Process)
displays the tree of processes, that is, the processes and their parent-child
relationship, by means of a standard outline view. Note, for example, in
our screen shot shown in Figure 11, that process explorer.exe is the parent
of many processes, including the Firefox web browser and the Thunderbird
email client. Next to the process name is the icon of the associated program,
which helps to facilitate visual identification. The remaining columns
display, from left to right, the process ID (PID), percentage of CPU time
used (CPU), size (in KB) of the process address space (Virtual Size), and
description of the process (Description).
Large usage of CPU time and/or address space often indicate problem-
atic processes that may need to be terminated. A customization window
for the background color of processes is also shown in this example. In
134
Operating Systems Security
Figure 11: Screen shot of the Process Explorer utility for Microsoft Win-
dows, by Mark Russinovich, configured with three components: a menu
bar (top), a tool bar and three mini graphs (middle), and a process tree pane
(bottom). Microsoft® and Windows® are registered trademarks of the Microsoft
Corporation in the U.S.A. and other countries. Screen shots and icons reprinted with
permission from the Microsoft Corporation. This book is not sponsored or endorsed
by or affiliated with the Microsoft Corporation.
135
Operating Systems Security
136
Operating Systems Security
Password Salt
One way to make the dictionary attack more difficult to launch is to use
salt, which is a cryptographic technique of using random bits as part of
the input to a hash function or encryption algorithm so as to increase the
randomness in the output. In the case of password authentication, salt
would be introduced by associating a random number with each userid.
Then, rather than comparing the hash of an entered password with a stored
hash of a password, the system compares the hash of an entered password
and the salt for the associated userid with a stored hash of the password
and salt. Let U be a userid and P be the corresponding password. When
using salt, the password file stores the triplet (U, S, h(S|| P)), where S is the
salt for U and h is a cryptographic hash function. (See Figure 12.)
137
Operating Systems Security
Without salt:
With salt:
2B × D,
where B is the number of bits of the random salt and D is the size of the list
of words for the dictionary attack. For example, if a system uses a 32-bit
salt for each userid and its users pick the kinds of passwords that would
be in a 500,000 word dictionary, then the search space for attacking salted
passwords would be
which is over 2 quadrillion. Also, even if an attacker can find the salt
associated with each userid (which the system should store in encrypted
form), by employing salted passwords, an operating system can limit his
dictionary attack to one userid at a time (since he would have to use a
different salt value for each one).
138
Operating Systems Security
139
Operating Systems Security
140
Operating Systems Security
Linux Permissions
Linux inherits most of its access control systems from the early Unix sys-
tems discussed previously. Linux features file permission matrices, which
determine the privileges various users have in regards to a file. All permis-
sions that are not specifically granted are implicitly denied, so there is no
mechanism (or need) to explicitly deny permissions. According to the path-
based access control principle, in order to access a file, each ancestor folder
(in the filesystem tree) must have execute permission and the file itself
must have read permission. Finally, owners of files are given the power
to change the permissions on those files—this is known as discretionary
access control (DAC).
In addition to the three basic permissions (read, write, and execute),
Linux allows users to set extended attributes for files, which are applied
to all users attempting to access these files. Example extended attributes
include making a file append-only (so a user may only write to the end
of the file) and marking a file as “immutable,” at which point not even
the root user can delete or modify the file (unless he or she removes the
attribute first). These attributes can be set and viewed with the chattr and
lsattr commands, respectively.
More recently, Linux has begun supporting an optional ACL-based
permissions scheme. ACLs on Linux can be checked with the getfacl
command, and set with the setfacl command. Within this scheme, each file
has basic ACEs for the owner, group, and other principals and additional
ACEs for specific users or groups, called named users and named groups,
can be created. There is also a mask ACE, which specifies the maximum
allowable permissions for the owning group and any named users and
groups. Let U be the euid of the process attempting access to the file or
folder with certain requested permissions. To determine whether to grant
access, the operating system tries to match the following conditions and
selects the ACE associated with the first matching condition:
• U is the userid of the file owner: the ACE for owner;
• U is one of the named users: the ACE for U;
• one of the groups of U is the owning group and the ACE for group
contains the requested permissions: the ACE for group;
• one of the groups of U is a named group G and its ACE contains the
requested permissions: the ACE for G;
• for each group G of U that is the owning group or a named group,
the ACE for G does not contain the requested permissions: the empty
ACE;
• otherwise: the ACE for other.
141
Operating Systems Security
If the ACE for owner or other or the empty ACE has been selected, then
its permissions determine access. Else, the selected ACE is “ANDed”
with the mask ACE and the permissions of the resulting ACE determine
access. Note that the although multiple ACEs could be selected in the
fourht condition, the access decision does not depend on the specific ACE
selected. At the time of this writing, Linux’s ACL scheme is not very widely
used, despite the fact that it allows for more flexibility in access control.
Some Linux distributions have even more advanced access control
mechanisms. Security-Enhanced Linux (SELinux), developed primarily
by the United States National Security Agency, is a series of security en-
hancements designed to be applied to Unix-like systems. SELinux features
strictly enforced mandatory access control, which defines virtually every
allowable action on a machine. Each rule consists of a subject, referring to
the process attempting to gain access, an object, referring to the resource
being accessed, and a series of permissions, which are checked by the
operating system appropriately. SELinux embodies the principle of least
privilege: limiting every process to the bare minimum permissions needed
to function properly, which significantly minimizes the effects of a security
breach. In addition, unlike DAC, users are not given the power to decide
security attributes of their own files. Instead, this is delegated to a central
security policy administrator. These enhancements allow SELinux to create
a much more restrictive security environment.
Windows Permissions
Windows uses an ACL model that allows users to create sets of rules for
each user or group. These rules either allow or deny various permissions
for the corresponding principal. If there is no applicable allow rule, access
is denied by default. The basic permissions are known as standard permis-
sions, which for files consist of modify, read and execute, read, write, and
finally, full control, which grants all permissions. Figure 13 depicts the
graphical interface for editing permissions in Windows XP.
To finely tune permissions, there are also advanced permissions, which
the standard permissions are composed of. These are also shown in Fig-
ure 13. For example, the standard read permission encompasses several
advanced permissions: read data, read attributes, read extended attributes,
and read permissions. Setting read to allow for a particular principal
automatically allows each of these advanced permissions, but it is also
possible to set only the desired advanced permissions.
As in Linux, folders have permissions too: read is synonymous with the
ability to list the contents of a folder, and write allows a user to create new
files within a folder. However, while Linux checks each folder in the path to
142
Operating Systems Security
143
Operating Systems Security
To solve this problem, Unix systems have an additional bit in the file
permission matrix known as a setuid bit. If this bit is set, then that program
runs with the effective user ID of its owner, rather than the process that
executed it. For example, the utility used to change passwords in Unix is
passwd. This program is owned by the root account, has the execute bit set
for the others class, and has the setuid bit set. When a user runs passwd,
the program runs with the permissions of the root user, allowing it to alter
the /etc/passwd file, which can only be written by the root user. Setuid
programs can also drop their higher privileges by making calls to the setuid
family of functions.
144
Operating Systems Security
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
145
Operating Systems Security
146
Operating Systems Security
An Example Vulnerability
#include <stdio.h>
#include <unistd.h>
147
Operating Systems Security
148
Operating Systems Security
149
Operating Systems Security
Arithmetic Overflow
The simplest kind of overflow condition is actually a limitation having
to do with the representation of integers in memory. In most 32-bit ar-
chitectures, signed integers (those that can be either positive or negative)
are expressed in what is known as two’s compliment notation. In hex
notation, signed integers 0x00000000 to 0x7ffffff (equivalent to 231 − 1)
are positive numbers, and 0x80000000 to 0xffffffff are negative numbers.
The threshold between these two ranges allows for overflow or under-
flow conditions. For example, if a program continually adds very large
numbers and eventually exceeds the maximum value for a signed integer,
0x7fffffff, the representation of the sum overflows and becomes negative
rather than positive. Similarly, if a program adds many negative numbers,
eventually the sum will underflow and become positive. This condition
also applies to unsigned integers, which consist of only positive numbers
from 0x00000000 to 0xffffffff. Once the highest number is reached, the next
sequential integer wraps around to zero.
An Example Vulnerability
This numerical overflow behavior can sometimes be exploited to trick an
application to perform undesirable behavior. As an example, suppose a
network service keeps track of the number of connections it has received
since it has started, and only grants access to the first five users. An unsafe
implementation can be found in Code Fragment 3.
150
Operating Systems Security
#include <stdio.h>
151
Operating Systems Security
#include <stdio.h>
152
Operating Systems Security
attacker’s input
malicious code
padding
buffer
(a) (b)
Figure 14: A stack smashing attack under the assumption that the attacker
knows the position of the return address. (a) Before the attack, the return
address points to a location in the program code. (b) Exploiting the unpro-
tected buffer, the attacker injects into the address space input consisting of
padding up to the return address location, a modified return address that
points to the next memory location, and malicious code. After completing
execution of the current routine, control is passed to the malicious code.
153
Operating Systems Security
NOP Sledding
NOP sledding is a method that makes it more likely for the attacker to
successfully guess the location of the code in memory by increasing the size
of the target. A NOP or No-op is a CPU instruction that does not actually
do anything except tell the processor to proceed to the next instruction.
To use this technique, the attacker crafts a payload that contains an ap-
propriate amount of data to overrun the buffer, a guess for a reasonable
return address in the process’s address space, a very large number of NOP
instructions, and finally, the malicious code. When this payload is provided
to a vulnerable program, it copies the payload into memory, overwriting the
return address with the attacker’s guess. In a successful attack, the process
will jump to the guessed return address, which is likely to be somewhere in
the high number of NOPs (known as the NOP sled). The processor will then
“sled through” all of the NOPs until it finally reaches the malicious code,
which will then be executed. NOP sledding is illustrated in Figure 15.
154
Operating Systems Security
Before Copying
Other
Return
Buffer Program
Address
Data
After Copying
Guessed
Address
Junk Padding of
NOPs Shellcode
Shellcode
Figure 15: The NOP sledding technique for stack smashing attacks.
Trampolining
Despite the fact that NOP sledding makes stack-based buffer overflows
much more likely to succeed, they still require a good deal of guesswork
and are not extremely reliable. Another technique, known as jump-to-
register or trampolining, is considered more precise. As mentioned above,
on initialization, most processes load the contents of external libraries
into their address space. These external libraries contain instructions that
are commonly used by many processes, system calls, and other low-level
operating system code. Because they are loaded into the process’s address
space in a reserved section of memory, they are in predictable memory
locations. Attackers can use knowledge of these external libraries to per-
form a trampolining attack. For example, an attacker might be aware of a
particular assembly code instruction in a Windows core system DLL and
suppose this instruction tells the processor to jump to the address stored in
one of the processor’s registers, such as ESP. If the attacker can manage
to place his malicious code at the address pointed to by ESP and then
overwrite the return address of the current function with the address of
this known instruction, then on returning, the application will jump and
execute the jmp esp instruction, resulting in execution of the attacker’s
malicious code. Once again, specific examples will vary depending on the
application and the chosen library instruction, but in general this technique
provides a reliable way to exploit vulnerable applications that is not likely
to change on subsequent attempts on different machines, provided all of the
machines involved are running the same version of the operating system.
155
Operating Systems Security
Shellcode
Once an attacker has crafted a stack-based buffer overflow exploit, they
have the ability to execute arbitrary code on the machine. Attackers often
choose to execute code that spawns a terminal or shell, allowing them to
issue further commands. For this reason, the malicious code included in an
exploit is often known as shellcode. Since this code is executed directly on
the stack by the CPU, it must be written in assembly language, low-level
processor instructions, known as opcodes, that vary by CPU architecture.
Writing usable shellcode can be difficult. For example, ordinary assembly
code may frequently contain the null character, 0x00. However, this code
cannot be used in most buffer overflow exploits, because this character
typically denotes the end of a string, which would prevent an attacker from
successfully copying his payload into a vulnerable buffer; hence, shellcode
attackers employ tricks to avoid null characters.
Buffer overflow attacks are commonly used as a means of privilege
escalation by exploiting SetUID programs. Recall that a SetUID program
can be executed by low-level users, but is allowed to perform actions on
behalf of its owner, who may have higher permissions. If a SetUID program
is vulnerable to a buffer overflow, then an attack might include shellcode
that first executes the setuid() system call, and then spawns a shell. This
would result in the attacker gaining a shell with the permissions of the
exploited process’s owner, and possibly allow for full system compromise.
156
Operating Systems Security
#include <stdio.h>
157
Operating Systems Security
158
Operating Systems Security
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
159
Operating Systems Security
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
160
Operating Systems Security
161
Operating Systems Security
The printf family of C library functions are used for I/O, including printing
messages to the user. These functions are typically designed to be passed an
argument containing the message to be printed, along with a format string
that denotes how this message should be displayed. For example, calling
printf(“%s”,message) prints the message variable as a string, denoted by
the format string %s. Format strings can also write to memory. The %n
format string specifies that the print function should write the number of
bytes output so far to the memory address of the first argument to the
function.
When a programmer does not supply a format string, the input ar-
gument to the print function controls the format of the output. If this
argument is user-supplied, then an attacker could carefully craft an input
that uses format strings, including %n, to write to arbitrary locations in
memory. This could allow an attacker to seize control and execute arbitrary
code in the context of the program by overwriting a return address, function
pointer, etc. An example of a program with a format string vulnerability can
be found in Code Fragment 9, where the printf() function is called without
providing a format string.
#include <stdio.h>
int main(int argc, char * argv[ ])
{
printf("Your argument is:\n");
// Does not specify a format string, allowing the user to supply one
printf(argv[1]);
}
Code Fragment 9: A C program vulnerable to a format string bug.
Once again, the solution to this attack lies in the hands of the program-
mer. To prevent format string attacks, programmers should always provide
format strings to the printf function family, as in Code Fragment 10.
#include <stdio.h>
int main(int argc, char * argv[ ])
{
printf("Your argument is:\n");
// Supplies a format string
printf("%s",argv[1]);
}
Code Fragment 10: A C program protected against a format string bug.
162
Operating Systems Security
163
Operating Systems Security
Next, the program will call open() on the symbolic link, which will be
successful because the program is SetUID root and has permission to open
any files accessible to the root user. Finally, the program will dutifully read
and print the contents of the file.
Note that this type of attack could not be done manually; the time
difference between two function calls is small enough that no human would
be able to change the files fast enough. However, it would be possible
to have a program running in the background that repeatedly switches
between the two files—one legitimate and one just a symbolic link—and
runs the vulnerable program repeatedly until the switch occurred in exactly
the right place.
To safely code the example above, the call to access() should be com-
pletely avoided. Instead, the program should drop its privileges using
seteuid() before calling open(). This way, if the user running the program
does not have permission to open the specified file, the call to open() will
fail. A safe version of the program can be found in Code Fragment 12.
164
Operating Systems Security
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
int main(int argc, char * argv[ ])
{
int file;
char buf[1024];
uid t uid, euid;
memset(buf, 0, 1024);
if(argc < 2) {
printf("Usage: printer [filename]\n");
exit(−1);
}
euid = geteuid();
uid = getuid();
/* Drop privileges */
seteuid(uid);
file = open(argv[1], O RDONLY);
read(file, buf, 1023);
close(file);
/* Restore privileges */
seteuid(euid);
printf("%s\n", buf);
return 0;
}
165
Operating Systems Security
5 Exercises
For help with exercises, please visit securitybook.net.
Reinforcement
R-1 How can multitasking make a single processor look like it is run-
ning multiple programs at the same time?
R-2 Give an example of three operating systems services that do not
belong in the kernel?
R-3 If a process forks two processes and these each fork two processes,
how many processes are in this part of the process tree?
R-4 What is the advantage of booting from the BIOS instead of booting
the operating system directly?
R-5 Can a process have more than one parent? Explain.
R-6 Describe two types of IPC. What are their relative benefits and
weaknesses?
R-7 Why would it be bad to mix the stack and heap segments of
memory in the same segment?
R-8 Describe the difference between a daemon and a service.
R-9 What are the benefits of virtual memory?
R-10 Why should a security-conscious Windows user inspect processes
with Process Explorer instead of Task Manager?
R-11 What is the purpose of salting passwords?
R-12 If a password is salted with a 24-bit random number, how big is the
dictionary attack search space for a 200,000 word dictionary?
R-13 Eve has just discovered and decrypted the file that associates each
userid with its 32-bit random salt value, and she has also discov-
ered and decrypted the password file, which contains the salted-
and-hashed passwords for the 100 people in her building. If she has
a dictionary of 500,000 words and she is confident all 100 people
have passwords from this dictionary, what is the size of her search
space for performing a dictionary attack on their passwords?
R-14 Suppose farasi is a member of group hippos in a system that uses
basic Unix permissions. He creates a file pool.txt, sets its group
as hippos and sets its permissions as u=rw,g=. Can farasi read
pool.txt?
166
Operating Systems Security
R-15 Dr. Eco claims that virtual machines are good for the environment.
How can he justify that virtualization is a green technology?
R-16 Alice, who uses a version of Unix, requires a better program to
manage her photos. She wants Bob to code this program for her.
However, she does not want Bob to be able to see some confidential
files she has in her account (for example, the solutions of some
homework). On the other hand, Bob wants to make sure that Alice
does not read his code, since this will probably be her CS032 final
project. Explain how this can be achieved by using the setuid and
chmod functions provided by UNIX. Also, assume for this question
only (regardless of real systems’ behavior), that a user cannot revert
to the real UID after using the effective UID that was set by the
setuid feature. Specifically consider the fact that Bob could embed
code in his program to transfer data it has access to, to a public
folder and/or a web server.
R-17 Is it possible to create a symbolic link to a symbolic link? Why or
why not?
R-18 Why is it pointless to give a symbolic link more restrictive access
privileges than the file it points to?
R-19 Describe the main differences between advanced file permissions
in Linux and Windows NTFS. Give an example to illustrate each
difference.
R-20 Dr. Blahbah claims that buffer overflow attacks via stack smashing
are made possible by the fact that stacks grow downwards (to-
wards smaller addresses) on most popular modern architectures.
Therefore, future architectures should ensure that the stack grows
upwards; this would provide a good defense against buffer over-
flow. Do you agree or disagree? Why?
R-21 Why is it important to protect the part of the disk that is used for
virtual memory?
R-22 Why is it unsafe to keep around the C:\hiberfil.sys file even after a
computer has been restored from hibernation?
Creativity
C-1 Bob thinks that generating and storing a random salt value for
each userid is a waste. Instead, he is proposing that his system
administrators use a SHA-1 hash of the userid as its salt. Describe
whether this choice impacts the security of salted passwords and
include an analysis of the respective search space sizes.
167
Operating Systems Security
C-2 Alice has a picture-based password system, where she has each
user pick a set of their 20 favorite pictures, say, of cats, dogs, cars,
etc. To login, a user is shown a series of pictures in pairs—one on
the left and one on the right. In each pair, the user has to pick the
one that is in his set of favorites. If the user picks the correct 20
out of the 40 he is shown (as 20 pairs), then the system logs him in.
Analyze the security of this system, including the size of the search
space. Is it more secure than a standard password system?
C-3 Charlie likes Alice’s picture-password system of the previous exer-
cise, but he has changed the login so that it just shows the user 40
different pictures in random order and they have to indicate which
20 of these are from their set of favorites. Is this an improvement
over Alice’s system? Why or why not?
C-4 Dr. Simplex believes that all the effort spent on access control
matrices and access control lists is a waste of time. He believes
that all file access permissions for every file should be restricted
to the owner of that file, period. Describe at least three scenarios
where he is wrong, that is, where users other than a file’s owner
need some kind of allowed access privileges.
C-5 On Unix systems, a convenient way of packaging a collection of
files is a SHell ARchive, or shar file. A shar file is a shell script
that will unpack itself into the appropriate files and directories.
Shar files are created by the shar command. The implementation
of the shar command in a legacy version of the HP-UX operating
system created a temporary file with an easily predictable filename
in directory /tmp. This temporary file is an intermediate file that
is created by shar for storing temporary contents during its execu-
tion. Also, if a file with this name already exists, then shar opens
the file and overwrites it with temporary contents. If directory /tmp
allows anyone to write to it, a vulnerability exists. An attacker can
exploit such a vulnerability to overwrite a victim’s file. (1) What
knowledge about shar should the attacker have? (2) Describe the
command that the attacker issues in order to have shar overwrite
an arbitrary file of a victim. Hint: the command is issued before
shar is executed. (3) Suggest a simple fix to the shar utility to
prevent the attack. Note that this is not a setuid question.
C-6 Java is considered to be “safe” from buffer overflows. Does that
make it more appropriate to use as a development language when
security is a concern? Be sure and weigh all of the risks involved in
product development, not just the security aspects.
C-7 Dr. Blahbah has implemented a system with an 8-bit random ca-
nary that is used to detect and prevent stack-based buffer overflow
168
Operating Systems Security
169
Operating Systems Security
domly generated. When there is a return from the function call, the
compiler checks if the canary value has been overwritten or not.
Do you think that this approach would work? If yes, please explain
why it works; if not, please give a counterexample.
C-10 Another approach to protecting against buffer overflows is to rely
on address space layout randomization (ASLR). Most implementa-
tions of ASLR offset the start of each memory segment by a number
that is randomly generated within a certain range at runtime. Thus,
the starting address of data objects and code segments is a random
location. What kinds of attacks does this technique make more
difficult and why?
Projects
P-1 Write a program in pseudocode that acts as a guardian for a file, al-
lowing anyone to append to the file, but to make no other changes
to it. This may be useful, e.g., to add information to a log file.
Your program, to be named append, should take two strings file1
and file2 as arguments, denoting the paths to two files. Operation
append(String file1, String file2) copies the contents of file1 to the
end of file2, provided that the user performing the operation has
read permission for file1 and file2. If the operation succeeds, 0 is
returned. On error, −1 is returned.
Assume that the operating system supports the setuid mechanism
and that append is a setuid program owned by a user called
guardian. The file to which other files get appended (file2) is also
owned by guardian. Anyone can read its contents. However, it can
be written only by guardian. Write your program in pseudocode
using the following Java-style system calls:
(1) int open(String path to file, String mode) opens a file in a given
mode and returns a positive integer that is the descriptor of the
opened file. String mode is one of READ ONLY or WRITE ONLY.
(2) void close(int file descriptor) closes a file given its descriptor.
(3) byte[] read(int file descriptor) reads the content of the given
file into an array of bytes and returns the array. (4) void write(int
file descriptor, byte[] source buffer) stores a byte array into a file,
replacing the previous content of the file. (5) int getUid() gets the
real user ID of the current process. (6) int getEuid() gets the effective
user ID of the current process. (7) void setEuid(int uid) sets the
effective user ID of the current process, where uid is either the real
user ID or the saved effective user ID of the process.
170
Operating Systems Security
171
Operating Systems Security
Chapter Notes
Operating systems are discussed in detail in the textbooks by Doeppner [27] and
Silberschatz, Galvin and Gagne [94]. Much of the content in this chapter on Unix-
based systems, especially Linux, draws heavily on open source documentation,
which can be accessed at http://www.manpagez.com/. Grünbacher describes in
detail Linux ACLs and the file access control algorithm based on ACLs [37].
Reference material on the Windows API can be found in the Microsoft Developer
Network [60]. A classic introduction to stack-based buffer overflows is given
by Aleph One [1]. Lhee and Chapin discuss buffer overflow and format string
exploitation [54]. A method for protecting against heap smashing attacks is
presented by Fetzer and Xiao [33]. The canary method for defending against
stack smashing attacks is incorporated in the StackGuard compiler extension by
Cowan et al. [20]. Address space randomization and its effectiveness in preventing
common buffer overflow attacks is discussed by Shacham et al. [89]. Project P-1
is from Tom Doeppner.
172
Malware
Contents
1 Insider Attacks
1.1 Backdoors
1.2 Logic Bombs
1.3 Defenses Against Insider Attacks
2 Computer Viruses
2.1 Virus Classification
2.2 Defenses Against Viruses
2.3 Encrypted Viruses
2.4 Polymorphic and Metamorphic Viruses
3 Malware Attacks
3.1 Trojan Horses
3.2 Computer Worms
3.3 Rootkits
3.4 Zero-Day Attacks
3.5 Botnets
4 Privacy-Invasive Software
4.1 Adware
4.2 Spyware
5 Countermeasures
5.1 Best Practices
5.2 The Impossibility of Detecting All Malware
5.3 The Malware Detection Arms Race
5.4 Economics of Malware
6 Exercises
173
Malware
1 Insider Attacks
This chapter is devoted to the ways that software systems can be attacked
by malicious software, which is also known as malware. Malicious soft-
ware is software whose existence or execution has negative and unintended
consequences. We discuss various kinds of malware, including some case
studies, and how systems and networks can be protected from malware.
We begin our coverage of malware with insider attacks. An insider
attack is a security breach that is caused or facilitated by someone who is
a part of the very organization that controls or builds the asset that should
be protected. In the case of malware, an insider attack refers to a security
hole that is created in a software system by one of its programmers. Such
an attack is especially dangerous because it is initiated by someone that
we should be able to trust. Unfortunately, such betrayals of trust are not
uncommon.
Insider attack code can come embedded in a program that is part of
a computer’s operating system or in a program that is installed later by
a user or system administrator. Either way, the embedded malware can
initiate privilege escalation, can cause damage as a result of some event, or
can itself be a means to install other malware.
1.1 Backdoors
A backdoor, which is also sometimes called a trapdoor, is a hidden feature
or command in a program that allows a user to perform actions he or
she would not normally be allowed to do. When used in a normal way,
this program performs completely as expected and advertised. But if the
hidden feature is activated, the program does something unexpected, often
in violation of security policies, such as performing a privilege escalation.
In addition, note that since a backdoor is a feature or command embedded
in a program, backdoors are always created by one of the developers or
administrators of the software. That is, they are a type of insider attack.
(See Figure 1.)
174
Malware
175
Malware
Deliberate Backdoors
Easter Eggs
176
Malware
if (trigger-condition
(trigger condition = true) {
unleash bomb;
}
177
Malware
dates as two digits, xy, to imply 19xy. When the year 2000 came, this prac-
tice caused several problems. Although Y2K didn’t have the catastrophic
effects that some were expecting, it did cause some problems with some
credit-card transactions and other date-dependent calculations. In spite of
these negative results, there was, as far as we know, no malice on the part
of programmers encoding dates in this way. Instead, these programmers
were trying to save some memory space with what they saw as the useless
storage of two redundant digits. Because of a lack of malicious intent,
the Y2K problem should not be considered a logic bomb although it had
a similar effect.
An example of a logic bomb comes in the classic movie Jurassic Park, where
the programmer, Nedry, installs a piece of code in the software for the
park’s security system that systematically turns off the locks on certain
fences, gates, and doors to allow him to steal some dinosaur embryos.
A real-life logic bomb was reported to have been inserted in 2008 into
the network software for Fannie Mae, a large financial enterprise sponsored
by the United States government, by a software contractor, Rajendrasinh
Makwana. He is said to have set a logic bomb to erase all of Fannie Mae’s
4,000 server computers 3 months after he had been terminated. Fortunately,
the code for this logic bomb was discovered prior to its activation date,
which avoided a digital disaster that would have had major implications in
the financial world.
An example of a logic bomb that was actually triggered and caused damage
is one that programmer Tim Lloyd was convicted of using on his former
employer, Omega Engineering Corporation. On July 31, 1996, a logic bomb
was triggered on the server for Omega Engineering’s manufacturing oper-
ations, which ultimately cost the company millions of dollars in damages
and led to it laying off many of its employees.
When authorities investigated, they discovered that the files on the
server were destroyed and that Tim Lloyd had been the administrator for
that server. In addition, when they searched for backup tapes for the server,
they only found two—at Tim Lloyd’s house—and they were both erased.
178
Malware
F:
◦ This focused subsequent commands to be run on the volume F,
which contained the server’s critical files.
F:\LOGIN\LOGIN 12345
◦ This is a login for a fictitious user, 12345, that had supervisory
and destroy permissions, but (surprisingly) had no password.
So all subsequent commands would run using the supervisory
permissions of user 12345.
CD \PUBLIC
◦ This is a DOS command to change the current directory to the
folder PUBLIC, which stored common programs and other pub-
lic files on Omega Engineering’s server.
FIX.EXE /Y F:\*.*
◦ FIX.EXE was an exact copy of the DOS program DELTREE,
which can delete an entire folder (and recursively its subfolders),
except that FIX.EXE prints on the screen the words “fixing ...”
instead of “deleting ...” for each file that is deleted. The /Y
option confirms that each file should indeed be deleted, and the
argument F:\*.* identifies all the files on volume F as the ones to
be deleted.
PURGE F:\/ALL
◦ Deleted files can often be easily recovered by a simple analysis of
the disk. This command eliminates the information that would
make such reconstruction easy, thereby making recovery of the
deleted files difficult.
Thus, this program was a time bomb, which was designed to delete all the
important files on Omega Engineering’s server after July 30, 1996. Based in
part on this evidence, Tim Lloyd was found guilty of computer sabotage.
179
Malware
• Avoid single points of failure. Let no one person be the only one to
create backups or manage critical systems.
• Use code walk-throughs. Have each programmer present her source
code to another programmer, line by line, so that he can help her
identify any missing conditions or undetected logic errors. Assuming
that there is no “ sleight of hand,” where she would present one set of
source code during the code walk-through and install a different set
later, she should be unable to discuss the code that defines a backdoor
or logic bomb without her partner noticing.
• Use archiving and reporting tools. Several other software engineer-
ing tools, such as automatic documentation generators and software
archiving tools, have a benefit of uncovering or documenting in-
sider attacks, in addition to their primary goals of producing quality
software. Software engineering tools often create visual artifacts or
archival digests, which are often reviewed by managers, not just the
programmers, so using these tools makes it harder for an insider
who is a malware author to have her malicious code go undetected.
Likewise, when program code is archived, it becomes harder for a
team member to avoid the existence of malware source code to go
undiscovered after an attack.
• Limit authority and permissions. Use a least privilege principle,
which states that each program or user in a system should be given
the least privilege required for them to do their job effectively.
• Physically secure critical systems. Important systems should be kept
in locked rooms, with redundant HVAC and power systems, and
protected against flood and fire.
• Monitor employee behavior. Be especially on the lookout for system
administrators and programmers that have become disgruntled.
• Control software installations. Limit new software installations to
programs that have been vetted and come from reliable sources.
180
Malware
2 Computer Viruses
A computer virus, or simply virus, is computer code that can replicate itself
by modifying other files or programs to insert code that is capable of further
replication. This self-replication property is what distinguishes computer
viruses from other kinds of malware, such as logic bombs. Another distin-
guishing property of a virus is that replication requires some type of user
assistance, such as clicking on an email attachment or sharing a USB drive.
Often, a computer virus will perform some malicious task as well, such as
deleting important files or stealing passwords.
Computer viruses share a number of properties with biological viruses.
When released, biological viruses use their environment to spread to unin-
fected cells. A virus can often lie dormant for a period of time, waiting until
it encounters the right kind of uninfected cell. When a virus encounters
such a cell, it attacks that cell’s defenses at the margins. If it is able to
penetrate the cell, the virus uses the cell’s own reproductive processes to
make copies of the virus instead, which eventually are released from the cell
in great numbers, so as to repeat the process. (See Figure 3.) In this way,
computer viruses mimic biological viruses, and we even use the biological
term vectors to refer to vulnerabilities that malware, such as computer
viruses, exploit to perform their attacks.
Attack Penetration
181
Malware
4. Action phase. In this phase, the virus performs the malicious action
that it was designed to perform, called payload. This action could in-
clude something seemingly innocent, like displaying a silly picture on
a computer’s screen, or something quite malicious, such as deleting
all essential files on the hard drive.
These phases characterize many different types of computer viruses.
One way to classify the many varieties of viruses is according to the way
they spread or the types of files that they infect.
Types of Viruses
A program virus, also known as a file virus, infects a program by modifying
the file containing its object code. Once the infection occurs, a program
virus is sure to be run each time the infected program executes. If the
infected program is run often, as with a common operating system pro-
gram or a popular video game, then the virus is more likely to be able
to be maintained and to replicate. Thus, the most common and popular
programs are also the most natural targets for program viruses. Figure 4
gives schematic examples of infected program files, which contain both the
original program code and the virus code.
Several document preparation programs, such as Microsoft Word, sup-
port powerful macro systems that allow for automating sequences of com-
mands. When used benevolently, macros provide, e.g., dynamic updating
of facts, figures, names, and dates in documents when the underlying
information changes. But macro systems often incorporate a rich set of
operations, such as file manipulation and launching other applications.
Since a macro can behave similarly to an executable program, it can become
a target for viruses.
182
Malware
Header
Jump
Virus
Code Header Virus
Code Original
Virus Program
Code Part 1
Header Header
Jump
Virus Code
Part 1
Original Jump
Original Program Original
Program Program
Original
Program
Part 2
Halt
Virus Code
Part 2
Jump
(a) (b)
Figure 4: How a virus injects itself into a program file: (a) A simple
injection at the beginning of a program. (b) A more complex injection that
splits the virus code into two parts and injects them at different points in
the program. Jump instructions are used to begin execution with the virus
code and then pass control to the original program code.
A boot sector virus is a special type of program virus that infects the
code in the boot sector of a drive, which is run each time the computer is
turned on or restarted. This type of virus can be difficult to remove, since
the boot program is the first program that a computer runs. Thus, if the
boot sector is infected with a virus, then that virus can make sure it has
copies of itself carefully placed in other operating system files. As a result,
antivirus software routinely monitors the integrity of the boot sector.
183
Malware
• Melissa. This was the first recorded virus that spread itself via mass
emailing. It is a macro virus that infects Microsoft Word 97 or 2000
documents and Excel 97 or 98 documents. Once an infected document
is opened, the Melissa virus would email infected documents to the
first 40 or 50 addresses in the victim’s address book. It would also
infect other Word and Excel documents. When initially launched, the
Melissa virus spread so fast that a number of email servers had to be
temporarily shut down because they were overloaded with so many
emails. It has a number of variants, such as Papa, Syndicate, and
Marauder, which differ in the messages and filenames included in the
contents of the emails that are sent. In each case, the goal is to entice
the recipient to open an enclosed document and further the spread of
the virus.
• Elk Cloner. This is a boot sector virus that infected Apple II operating
systems in the early 1980s It infected systems by writing itself to
the hard drive any time an infected disk was inserted. It was fairly
harmless, however, in that its payload simply printed out a poem each
50th time the computer was booted.
184
Malware
Virus Signatures
A computer virus unleashed into the wild may get past the generic defenses
of several systems and spread rapidly. This spread inevitably attracts the
attention of systems managers, who in turn provide sample infected files to
antivirus software companies. Experts then study the infected files looking
for code fragments that are unique to this particular computer virus. Once
they have located such a set of characteristic instructions, they can construct
a character string that uniquely identifies this virus.
This character string is known as a signature for the virus; it amounts to
a kind of digital fingerprint. Then, much like our immune system attacking
a viral infection, a virus detection program is then loaded up with the
signatures of all known viruses. Virus detection software packages have
to be frequently updated, so that they always are using the most up-to-date
database of virus signatures. Detecting the presence of a virus signature
in a file is an instance of a pattern-matching problem, which consists of
finding a search pattern in a text. Several efficient pattern matching algo-
rithms have been devised, which are able to search for multiple patterns
concurrently in a single scan of the file.
185
Malware
Decryption Decryption
Code Code
Key Key
Encrypted
Virus Code Encrypt
Virus Code
By encrypting the main part of its code, a virus hides many of its distin-
guishing features, including its replication code and, more importantly, its
payload, such as searching for and deleting important files. As illustrated
in Figure 5, this modification results in the virus code taking on a different
structure: the decryption code, the key, and the encrypted virus code.
Alternatively, a short encryption key is used (e.g., a 16-bit key) and the
decryption code is replaced by code for a brute-force decryption attack. The
goal of encryption is to make it harder for an antivirus program to identify
the virus. However, note that code for decrypting the main virus body
must itself remain unencrypted. Interestingly, this requirement implies that
an encrypted virus has a telltale structure, which itself is a kind of virus
signature.
Even though this structure doesn’t tell a security expert exactly what
computations the virus performs, it does suggest to look for pieces of code
that perform decryption as a way of locating potential computer viruses. In
this way, the virus arms race continues, with the attack of signature-based
detection being counterattacked with encrypted viruses, which in turn are
themselves counterattacked with virus detection software that looks for
encryption code.
186
Malware
187
Malware
3 Malware Attacks
When malware was first discovered as a r