Os Unit 5
Os Unit 5
Goals of Protection
Principles of Protection
• The principle of least privilege dictates that programs, users, and systems be given just
enough privileges to perform their tasks.
• This ensures that failures do the least amount of harm and allow the least of harm to be done.
• For example, if a program needs special privileges to perform a task, it is better to make it a
SGID program with group ownership of "network" or "backup" or some other pseudo group,
rather than SUID with root ownership. This limits the amount of damage that can occur if
something goes wrong.
• Typically each user is given their own account, and has only enough privilege to modify their
own files.
• The root account should not be used for normal day to day activities - The System
Administrator should also have an ordinary account, and reserve use
Domain of Protection
Domain Structure
An Example: UNIX
An Example: MULTICS
• Rings are numbered from 0 to 7, with outer rings having a subset of the privileges of
the inner rings.
• Each file is a memory segment, and each segment description includes an entry that
indicates the ring number associated with that segment, as well as read, write, and
execute privileges.
• Each process runs in a ring, according to the current-ring-number, a counter
associated with each process.
• A process operating in one ring can only access segments associated with higher
( farther out ) rings, and then only according to the access bits. Processes cannot
access segments associated with lower rings.
• Domain switching is achieved by a process in one ring calling upon a process
operating in a lower ring, which is controlled by several factors stored with each
segment descriptor:
o An access bracket, defined by integers b1 <= b2.
o A limit b3 > b2
o A list of gates, identifying the entry points at which the segments may be
called.
• If a process operating in ring i calls a segment whose bracket is such that b1 <= i <=
b2, then the call succeeds and the process remains in ring i.
• Otherwise a trap to the OS occurs, and is handled as follows:
o If i < b1, then the call is allowed, because we are transferring to a procedure
with fewer privileges. However if any of the parameters being passed are of
segments below b1, then they must be copied to an area accessible by the
called procedure.
o If i > b2, then the call is allowed only if i <= b3 and the call is directed to one
of the entries on the list of gates.
• Overall this approach is more complex and less efficient than other protection
schemes.
Access Matrix
• The model of protection that we have been discussing can be viewed as an access matrix, in
which columns represent different system resources and rows represent different protection
domains. Entries within the matrix indicate what access that domain has to that resource.
Access matrix.
• Domain switching can be easily supported under this model, simply by providing "switch"
access to other domains:
• The ability to copy rights is denoted by an asterisk, indicating that processes in that domain
have the right to copy that access within the same column, i.e. for the same object. There are
two important variations:
o If the asterisk is removed from the original access right, then the right
is transferred, rather than being copied. This may be termed a transfer right as
opposed to a copy right.
o If only the right and not the asterisk is copied, then the access right is added to the
new domain, but it may not be propagated further. That is the new domain does not
also receive the right to copy the access. This may be termed a limited copy right, as
shown in Figure 14.5 below:
Figure 14.5 - Access matrix with copy rights.
• The owner right adds the privilege of adding new rights or removing existing ones:
• Copy and owner rights only allow the modification of rights within a column. The addition
of control rights, which only apply to domain objects, allow a process operating in one
domain to affect the rights available in other domains. For example in the table below, a
process operating in domain D2 has the right to control any of the rights in domain D4.
Global Table
• The simplest approach is one big global table with < domain, object, rights > entries.
• Unfortunately this table is very large ( even if sparse ) and so cannot be kept in
memory ( without invoking virtual memory techniques. )
• There is also no good way to specify groupings - If everyone has access to some
resource, then it still needs a separate entry for every domain.
• Each column of the table can be kept as a list of the access rights for that particular
object, discarding blank entries.
• For efficiency a separate list of default access rights can also be kept, and checked
first.
• In a similar fashion, each row of the table can be kept as a list of the capabilities of
that domain.
• Capability lists are associated with each domain, but not directly accessible by the
domain or any user process.
• Capability lists are themselves protected resources, distinguished from other data in
one of two ways:
o A tag, possibly hardware implemented, distinguishing this special type of
data. ( other types may be floats, pointers, booleans, etc. )
o The address space for a program may be split into multiple segments, at least
one of which is inaccessible by the program itself, and used by the operating
system for maintaining the process's access right capability list.
A Lock-Key Mechanism
Comparison
• Each of the methods here has certain advantages or disadvantages, depending on the
particular situation and task at hand.
• Many systems employ some combination of the listed methods.
Access Control
Program Threats
• There are many common threats to modern systems. Only a few are discussed here.
Trojan Horse
Trap Door
Logic Bomb
• A Logic Bomb is code that is not designed to cause havoc all the time, but only when
a certain set of circumstances occurs, such as when a particular date or time is
reached or some other noticeable event.
• A classic example is the Dead-Man Switch, which is designed to check whether a
certain person ( e.g. the author ) is logging in every day, and if they don't log in for a
long time ( presumably because they've been fired ), then the logic bomb goes off and
either opens up security holes or causes other problems.
Viruses
• Most of the threats described above are termed program threats, because they attack specific
programs or are carried and distributed in programs. The threats in this section attack the
operating system or the network itself, or leverage those systems to launch their attacks.
Worms
• A worm is a process that uses the fork / spawn process to make copies of itself in
order to wreak havoc on a system. Worms consume system resources, often blocking
out other, legitimate processes. Worms that propagate over networks can be
especially problematic, as they can tie up vast amounts of network resources and
bring down large-scale systems.
• One of the most well-known worms was launched by Robert Morris, a graduate
student at Cornell, in November 1988. Targeting Sun and VAX computers running
BSD UNIX version 4, the worm spanned the Internet in a matter of a few hours, and
consumed enough resources to bring down many systems.
• This worm consisted of two parts:
1. A small program called a grappling hook, which was deposited on the target
system through one of three vulnerabilities, and
2. The main worm program, which was transferred onto the target system and
launched by the grappling hook program.
• The three vulnerabilities exploited by the Morris Internet worm were as follows:
1. rsh ( remote shell ) is a utility that was in common use at that time for
accessing remote systems without having to provide a password. If a user had
an account on two different computers ( with the same account name on both
systems ), then the system could be configured to allow that user to remotely
connect from one system to the other without having to provide a password.
Many systems were configured so that any user ( except root ) on system A
could access the same account on system B without providing a password.
2. finger is a utility that allows one to remotely query a user database, to find
the true name and other information for a given account name on a given
system. For example "finger [email protected]" would access the
finger daemon at somemachine.edu and return information regarding
joeUser. Unfortunately the finger daemon ( which ran with system
privileges ) had the buffer overflow problem, so by sending a special 536-
character user name the worm was able to fork a shell on the remote system
running with root privileges.
3. sendmail is a routine for sending and forwarding mail that also included a
debugging option for verifying and testing the system. The debug feature was
convenient for administrators, and was often left turned on. The Morris worm
exploited the debugger to mail and execute a copy of the grappling hook
program on the remote system.
• Once in place, the worm undertook systematic attacks to discover user passwords:
1. First it would check for accounts for which the account name and the
password were the same, such as "guest", "guest".
2. Then it would try an internal dictionary of 432 favorite password choices. (
I'm sure "password", "pass", and blank passwords were all on the list. )
3. Finally it would try every word in the standard UNIX on-line dictionary to try
and break into user accounts.
• Once it had gotten access to one or more user accounts, then it would attempt to use
those accounts to rsh to other systems, and continue the process.
• With each new access the worm would check for already running copies of itself, and
6 out of 7 times if it found one it would stop. ( The seventh was to prevent the worm
from being stopped by fake copies. )
• Fortunately the same rapid network connectivity that allowed the worm to propagate
so quickly also quickly led to its demise - Within 24 hours remedies for stopping the
worm propagated through the Internet from administrator to administrator, and the
worm was quickly shut down.
• There is some debate about whether Mr. Morris's actions were a harmless prank or
research project that got out of hand or a deliberate and malicious attack on the
Internet. However the court system convicted him, and penalized him heavy fines and
court costs.
• There have since been many other worm attacks, including the W32.Sobig.F@mm
attack which infected hundreds of thousands of computers and an estimated 1 in 17 e-
mails in August 2003. This worm made detection difficult by varying the subject line
of the infection-carrying mail message, including "Thank You!", "Your details", and
"Re: Approved".
Port Scanning
• Port Scanning is technically not an attack, but rather a search for vulnerabilities to
attack. The basic idea is to systematically attempt to connect to every known ( or
common or possible ) network port on some remote machine, and to attempt to make
contact. Once it is determined that a particular computer is listening to a particular
port, then the next step is to determine what daemon is listening, and whether or not it
is a version containing a known security flaw that can be exploited.
• Because port scanning is easily detected and traced, it is usually launched
from zombie systems, i.e. previously hacked systems that are being used without the
knowledge or permission of their rightful owner. For this reason it is important to
protect "innocuous" systems and accounts as well as those that contain sensitive
information or special privileges.
• There are also port scanners available that administrators can use to check their own
systems, which report any weaknesses found but which do not exploit the weaknesses
or cause any problems. Two such systems
are nmap ( http://www.insecure.org/nmap ) and nessus ( http://www.nessus.org ).
The former identifies what OS is found, what firewalls are in place, and what services
are listening to what ports. The latter also contains a database of known security
holes, and identifies any that it finds.
Denial of Service
• Denial of Service ( DOS ) attacks do not attempt to actually access or damage
systems, but merely to clog them up so badly that they cannot be used for any useful
work. Tight loops that repeatedly request system services are an obvious form of this
attack.
• DOS attacks can also involve social engineering, such as the Internet chain letters that
say "send this immediately to 10 of your friends, and then go to a certain URL",
which clogs up not only the Internet mail system but also the web server to which
everyone is directed. ( Note: Sending a "reply all" to such a message notifying
everyone that it was just a hoax also clogs up the Internet mail service, just as
effectively as if you had forwarded the thing. )
• Security systems that lock accounts after a certain number of failed login attempts are
subject to DOS attacks which repeatedly attempt logins to all accounts with invalid
passwords strictly in order to lock up all accounts.
• Sometimes DOS is not the result of deliberate maliciousness. Consider for example:
o A web site that sees a huge volume of hits as a result of a successful
advertising campaign.
o CNN.com occasionally gets overwhelmed on big news days, such as Sept 11,
2001.
o CS students given their first programming assignment involving fork( ) often
quickly fill up process tables or otherwise completely consume system
resources. :-)
o ( Please use ipcs and ipcrm when working on the inter-process
• Within a given computer the transmittal of messages is safe, reliable and secure, because the
OS knows exactly where each one is coming from and where it is going.
• On a network, however, things aren't so straightforward - A rogue computer ( or e-mail sender
) may spoof their identity, and outgoing packets are delivered to a lot of other computers
besides their ( intended ) final destination, which brings up two big questions of security:
o Trust - How can the system be sure that the messages received are really from the
source that they say they are, and can that source be trusted?
o Confidentiality - How can one ensure that the messages one is sending are received
only by the intended recipient?
• Cryptography can help with both of these problems, through a system of secrets and keys. In
the former case, the key is held by the sender, so that the recipient knows that only the
authentic author could have sent the message; In the latter, the key is held by the recipient, so
that only the intended recipient can receive the message accurately.
• Keys are designed so that they cannot be divined from any public information, and must be
guarded carefully. ( Asymmetric encryption involve both a public and a private key. )
Encryption
• The basic idea of encryption is to encode a message so that only the desired recipient
can decode and read it. Encryption has been around since before the days of Caesar,
and is an entire field of study in itself. Only some of the more significant computer
encryption schemes will be covered here.
• The basic process of encryption is shown in Figure 15.7, and will form the basis of
most of our discussion on encryption. The steps in the procedure and some of the key
terminology are as follows:
1. The sender first creates a message, m in plaintext.
2. The message is then entered into an encryption algorithm, E, along with
the encryption key, Ke.
3. The encryption algorithm generates the ciphertext, c, = E(Ke)(m). For any
key k, E(k) is an algorithm for generating ciphertext from a message, and
both E and E(k) should be efficiently computable functions.
4. The ciphertext can then be sent over an unsecure network, where it may be
received by attackers.
5. The recipient enters the ciphertext into a decryption algorithm, D, along
with the decryption key, Kd.
6. The decryption algorithm re-generates the plaintext message, m, = D(Kd)(c).
For any key k, D(k) is an algorithm for generating a clear text message from
a ciphertext, and both D and D(k) should be efficiently computable functions.
7. The algorithms described here must have this important property: Given a
ciphertext c, a computer can only compute a message m such that c = E(k)(m)
if it possesses D(k). ( In other words, the messages can't be decoded unless
you have the decryption algorithm and the decryption key. )
Symmetric Encryption
• With symmetric encryption the same key is used for both encryption and
decryption, and must be safely guarded. There are a number of well-known
symmetric encryption algorithms that have been used for computer security:
o The Data-Encryption Standard, DES, developed by the National
Institute of Standards, NIST, has been a standard civilian encryption
standard for over 20 years. Messages are broken down into 64-bit
chunks, each of which are encrypted using a 56-bit key through a
series of substitutions and transformations. Some of the
transformations are hidden ( black boxes ), and are classified by the
U.S. government.
o DES is known as a block cipher, because it works on blocks of data
at a time. Unfortunately this is a vulnerability if the same key is used
for an extended amount of data. Therefore an enhancement is to not
only encrypt each block, but also to XOR it with the previous block,
in a technique known as cipher-block chaining.
o As modern computers become faster and faster, the security of DES
has decreased, to where it is now considered insecure because its
keys can be exhaustively searched within a reasonable amount of
computer time. An enhancement called triple DES encrypts the data
three times using three separate keys ( actually two encryptions and
one decryption ) for an effective key length of 168 bits. Triple DES is
in widespread use today.
o The Advanced Encryption Standard, AES, developed by NIST in
2001 to replace DES uses key lengths of 128, 192, or 256 bits, and
encrypts in blocks of 128 bits using 10 to 14 rounds of
transformations on a matrix formed from the block.
o The twofish algorithm, uses variable key lengths up to 256 bits and
works on 128 bit blocks.
o RC5 can vary in key length, block size, and the number of
transformations, and runs on a wide variety of CPUs using only basic
computations.
o RC4 is a stream cipher, meaning it acts on a stream of data rather
than blocks. The key is used to seed a pseudo-random number
generator, which generates a keystream of keys. RC4 is used
in WEP, but has been found to be breakable in a reasonable amount
of computer time.
Asymmetric Encryption
• With asymmetric encryption, the decryption key, Kd, is not the same as the
encryption key, Ke, and more importantly cannot be derived from it, which
means the encryption key can be made publicly available, and only the
decryption key needs to be kept secret. ( or vice-versa, depending on the
application. )
• One of the most widely used asymmetric encryption algorithms
is RSA, named after its developers - Rivest, Shamir, and Adleman.
• RSA is based on two large prime numbers, p and q, ( on the order of 512 bits
each ), and their product N.
o Ke and Kd must satisfy the relationship:
( Ke * Kd ) % [ ( p - 1 ) * ( q - 1 ) ] = = 1
o The encryption algorithm is:
c = E(Ke)(m) = m^Ke % N
o The decryption algorithm is:
m = D(Kd)(c) = c^Kd % N
• An example using small numbers:
o p=7
o q = 13
o N = 7 * 13 = 91
o ( p - 1 ) * ( q - 1 ) = 6 * 12 = 72
o Select Ke < 72 and relatively prime to 72, say 5
o Now select Kd, such that ( Ke * Kd ) % 72 = = 1, say 29
o The public key is now ( 5, 91 ) and the private key is ( 29, 91 )
o Let the message, m = 42
o Encrypt: c = 42^5 % 91 = 35
o Decrypt: m = 35^29 % 91 = 42
Encryption and decryption using RSA asymmetric cryptography
Authentication
Key Distribution
• One solution to the above problem involves digital certificates, which are public keys
that have been digitally signed by a trusted third party. But wait a minute - How do
we trust that third party, and how do we know they are really who they say they are?
Certain certificate authorities have their public keys included within web browsers
and other certificate consumers before they are distributed.
Implementation of Cryptography
User Authentication
Passwords
• Passwords are the most common form of user authentication. If the user is in
possession of the correct password, then they are considered to have identified
themselves.
• In theory separate passwords could be implemented for separate activities, such as
reading this file, writing that file, etc. In practice most systems use one password to
confirm user identity, and then authorization is based upon that identification. This is
a result of the classic trade-off between security and convenience.
Password Vulnerabilities
Encrypted Passwords
• Modern systems do not store passwords in clear-text form, and hence there is no
mechanism to look up an existing password.
• Rather they are encrypted and stored in that form. When a user enters their password,
that too is encrypted, and if the encrypted version match, then user authentication
passes.
• The encryption scheme was once considered safe enough that the encrypted versions
were stored in the publicly readable file "/etc/passwd".
o They always encrypted to a 13 character string, so an account could be
disabled by putting a string of any other length into the password field.
o Modern computers can try every possible password combination in a
reasonably short time, so now the encrypted passwords are stored in files that
are only readable by the super user. Any password-related programs run as
setuid root to get access to these files. ( /etc/shadow )
o A random seed is included as part of the password generation process, and
stored as part of the encrypted password. This ensures that if two accounts
have the same plain-text password that they will not have the same encrypted
password. However cutting and pasting encrypted passwords from one
account to another will give them the same plain-text passwords.
One-Time Passwords
• One-time passwords resist shoulder surfing and other attacks where an observer is
able to capture a password typed in by a user.
o These are often based on a challenge and a response. Because the challenge
is different each time, the old response will not be valid for future challenges.
▪ For example, The user may be in possession of a secret function f( x
). The system challenges with some given value for x, and the user
responds with f( x ), which the system can then verify. Since the
challenger gives a different ( random ) x each time, the answer is
constantly changing.
▪ A variation uses a map ( e.g. a road map ) as the key. Today's
question might be "On what corner is SEO located?", and tomorrow's
question might be "How far is it from Navy Pier to Wrigley Field?"
Obviously "Taylor and Morgan" would not be accepted as a valid
answer for the second question!
o Another option is to have some sort of electronic card with a series of
constantly changing numbers, based on the current time. The user enters the
current number on the card, which will only be valid for a few seconds.
A two-factor authorization also requires a traditional password in addition to
the number on the card, so others may not use it if it were ever lost or stolen.
o A third variation is a code book, or one-time pad. In this scheme a long list of
passwords is generated, and each one is crossed off and cancelled as it is
used. Obviously it is important to keep the pad secure.
Biometrics
• Biometrics involve a physical characteristic of the user that is not easily forged or
duplicated and not likely to be identical between multiple users.
o Fingerprint scanners are getting faster, more accurate, and more economical.
o Palm readers can check thermal properties, finger length, etc.
o Retinal scanners examine the back of the users' eyes.
o Voiceprint analyzers distinguish particular voices.
o Difficulties may arise in the event of colds, injuries, or other physiological
changes.
Implementing Security Defenses
Security Policy
• A security policy should be well thought-out, agreed upon, and contained in a living
document that everyone adheres to and is updated as needed.
• Examples of contents include how often port scans are run, password requirements,
virus detectors, etc.
Vulnerability Assessment
Intrusion Detection
Virus Protection
• Auditing, accounting, and logging records can also be used to detect anomalous
behavior.
• Some of the kinds of things that can be logged include authentication failures and
successes, logins, running of suid or sgid programs, network accesses, system calls,
etc. In extreme cases almost every keystroke and electron that moves can be logged
for future analysis. ( Note that on the flip side, all this detailed logging can also be
used to analyze system performance. The down side is that the logging
also affects system performance ( negatively! ), and so a Heisenberg effect applies. )
• "The Cuckoo's Egg" tells the story of how Cliff Stoll detected one of the early UNIX
break ins when he noticed anomalies in the accounting records on a computer system
being used by physics researchers.
• Firewalls are devices ( or sometimes software ) that sit on the border between two security
domains and monitor/log activity between them, sometimes restricting the traffic that can pass
between them based on certain criteria.
• For example a firewall router may allow HTTP: requests to pass through to a web server
inside a company domain while not allowing telnet, ssh, or other traffic to pass through.