Chapter 6 Security and Protection
Chapter 6 Security and Protection
Chapter 6
Protection
Control access by limiting file types
accessed by different users
#include <stdio.h>
#define BUFFER SIZE 256
int main(int argc, char *argv[])
{
char buffer[BUFFER SIZE];
int other_data;
if (argc < 2)
return -1;
else {
strcpy(buffer,argv[1]);
return 0;
}
}
Viruses
A virus is a fragment of code embedded in an
otherwise legitimate program, designed to
replicate itself ( by infecting other programs ),
and ( eventually ) wreaking havoc.
Viruses are more likely to infect PCs than UNIX or
other multi-user systems, because programs in
the latter systems have limited authority to
modify other programs or to access critical
system structures ( such as the boot block. )
Viruses are delivered to systems in a virus
dropper, usually some form of a Trojan Horse,
and usually via e-mail or unsafe downloads.
Viruses take many forms. Figure below shows
typical operation of a boot sector virus.
A Boot Sector Virus
Forms of Viruses
File - A file virus attaches itself to an executable file, causing it
to run the virus code first and then jump to the start of the
original program. These viruses are termed parasitic, because
they do not leave any new files on the system, and the original
program is still fully functional.
Boot - A boot virus occupies the boot sector, and runs before
the OS is loaded. These are also known as memory viruses,
because in operation they reside in memory, and do not appear
in the file system.
Macro - These viruses exist as a macro ( script ) that are run
automatically by certain macro-capable programs such as MS
Word or Excel. These viruses can exist in word processing
documents or spreadsheet files.
Source code viruses look for source code and infect it in order
to spread.
Polymorphic viruses change every time they spread - Not their
underlying functionality, but just their signature, by which
virus checkers recognize them.
Encrypted viruses travel in encrypted form to escape
detection. In practice they are self-decrypting, which then
allows them to infect other files.
Stealth viruses try to avoid detection by modifying parts
of the system that could be used to detect it. For
example the read( ) system call could be modified so that
if an infected file is read the infected part gets skipped
and the reader would see the original unadulterated file.
Tunneling viruses attempt to avoid detection by
inserting themselves into the interrupt handler chain, or
into device drivers.
Multipartite viruses attack multiple parts of the system,
such as files, boot sector, and memory.
Armored viruses are coded to make them hard for anti-
virus researchers to decode and understand. In addition
many files associated with viruses are hidden, protected,
or given innocuous looking names such as "...".
System and Network Threats
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.
Vulnerabilities of Morris Internet worm
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.
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..
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.
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.
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.
Security systems that lock accounts after a
certain number of failed login attempts are
Cryptography as a Security Tool
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:
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?
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.
Basic process of Encryption
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:
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.
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.
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.
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.
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.
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.
Ke and Kd must satisfy the relationship:
( Ke * Kd ) % [ ( p - 1 ) * ( q - 1 ) ] = = 1
The encryption algorithm is:
c = E(Ke)(m) = m^Ke % N
The decryption algorithm is:
m = D(Kd)(c) = c^Kd % N
Authentication
Authentication involves verifying the identity of the entity who
transmitted a message.
For example, if D(Kd)(c) produces a valid message, then we
know the sender was in possession of E(Ke).
This form of authentication can also be used to verify that a
message has not been modified
Authentication revolves around two functions, used
for signatures ( or signing), and verification:
A signing function, S(Ks) that produces an authenticator, A,
from any given message m.
A Verification function, V(Kv,m,A) that produces a value of "true"
if A was created from m, and "false" otherwise.
Obviously S and V must both be computationally efficient.
More importantly, it must not be possible to generate a valid
authenticator, A, without having possession of S(Ks).
Furthermore, it must not be possible to divine S(Ks) from the
combination of ( m and A ), since both are sent visibly across
networks.
Understanding authenticators begins with an
understanding of hash functions, which is the first step:
Hash functions, H(m) generate a small fixed-size block of
data known as a message digest, or hash value from any
given input data.
For authentication purposes, the hash function must
be collision resistant on m. That is it should not be
reasonably possible to find an alternate message m' such
that H(m') = H(m).
Popular hash functions are MD5, which generates a 128-bit
message digest, and SHA-1, which generates a 160-bit
digest.
Message digests are useful for detecting ( accidentally )
changed messages, but are not useful as authenticators,
because if the hash function is known, then someone
could easily change the message and then generate a
new hash value for the modified message. Therefore
authenticators take things one step further by encrypting
the message digest.
A message-authentication code, MAC, uses symmetric
encryption and decryption of the message digest, which means
that anyone capable of verifying an incoming message could
also generate a new message.
An asymmetric approach is the digital-signature
algorithm, which produces authenticators called digital
signatures. In this case Ks and Kv are separate, Kv is the
public key, and it is not practical to determine S(Ks) from public
information.
There are three good reasons for having separate algorithms
for encryption of messages and authentication of messages:
1. Authentication algorithms typically require fewer calculations,
making verification a faster operation than encryption.
2. Authenticators are almost always smaller than the messages,
improving space efficiency. (?)
3. Sometimes we want authentication only, and not
confidentiality, such as when a vendor issues a new software
patch.
Another use of authentication is non-repudiation, in which a
person filling out an electronic form cannot deny that they
were the ones who did so.
Implementation of Cryptography
Network communications are implemented in multiple
layers - Physical, Data Link, Network, Transport, and
Application being the most common breakdown.
Encryption and security can be implemented at any layer
in the stack, with pros and cons to each choice:
Because packets at lower levels contain the contents of
higher layers, encryption at lower layers automatically
encrypts higher layer information at the same time.
However security and authorization may be important to
higher levels independent of the underlying transport
mechanism or route taken.
At the network layer the most common standard
is IPSec, a secure form of the IP layer, which is used to
set up Virtual Private Networks, VPNs.
At the transport layer the most common implementation
is SSL, described below.
Example - SSL
Insertion of cryptography at one layer of the ISO
network model (the transport layer)
SSL – Secure Socket Layer (also called TLS)
Cryptographic protocol that limits two computers to
only exchange messages with each other
Very complicated, with many variations
Used between web servers and browsers for secure
communication (credit card numbers)
The server is verified with a certificate assuring
client is talking to correct server
Asymmetric cryptography used to establish a secure
session key (symmetric encryption) for bulk of
communication during session
Communication between each computer uses
symmetric key cryptography
Example –
Windows
Security is based on 7
user accounts
Each user has unique security ID
Login to ID creates security access token
Includes security ID for user, for user’s groups, and
special privileges
Every process gets copy of token
System checks token to determine if access allowed or
denied
Uses a subject model to ensure access security. A
subject tracks and manages permissions for each
program that a user runs
Each object in Windows XP has a security attribute
defined by a security descriptor
For example, a file has a security descriptor that
indicates the access permissions for all users
Security
Classifications
U.S. Department of Defense outlines four
divisions of computer security: A, B, C, and D.
D – Minimal security.
C – Provides discretionary protection through
auditing. Divided into C1 and C2. C1
identifies cooperating users with the same
level of protection. C2 allows user-level
access control.
B – All the properties of C, however each
object may have unique sensitivity labels.
Divided into B1, B2, and B3.
A – Uses formal design and verification
techniques to ensure security.