OS - Lecture -- OS Security & Protection
OS - Lecture -- OS Security & Protection
Protection
References:
1. Abraham Silberschatz, Greg Gagne, and Peter Baer Galvin, "Operating System Concepts, Ninth Edition ", Chapter 14
14.1 Goals of Protection
• Obviously to prevent malicious misuse of the system by users or programs. See chapter 15 for a more thorough coverage of this goal.
• To ensure that each shared resource is used only in accordance with system policies, which may be set either by system designers or
by system administrators.
• To ensure that errant programs cause the minimal amount of damage possible.
• Note that protection systems only provide the mechanisms for enforcing policies and ensuring reliable systems. It is up to
administrators and users to implement those mechanisms effectively.
14.2 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 of the root account for only those tasks which need the root privileges
14.3 Domain of Protection
• A computer can be viewed as a collection of processes and objects ( both HW & SW ).
• The need to know principle states that a process should only have access to those objects it needs to accomplish its task, and
furthermore only in the modes for which it needs access and only during the time frame when it needs access.
• The modes available for a particular object may depend upon its type.
14.3.1 Domain Structure
• A protection domain specifies the resources that a process may access.
• Each domain defines a set of objects and the types of operations that may be invoked on each object.
• An access right is the ability to execute an operation on an object.
• A domain is defined as a set of < object, { access right set } > pairs, as shown below. Note that some domains may be disjoint while
others overlap.
2
Figure 14.6 - Access matrix with owner rights.
OS - Lecture OS Security & Protection
• 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.
• Two solutions to Trojan Horses are to have the system print usage statistics on logouts, and to require the typing of non-trappable key
sequences such as Control-Alt-Delete in order to log in. ( This is why modern Windows systems require the Control-Alt-Delete
sequence to commence logging in, which cannot be emulated or caught by ordinary programs. I.e. that key sequence always transfers
control over to the operating system. )
• Spyware is a version of a Trojan Horse that is often included in "free" software downloaded off the Internet. Spyware programs
generate pop-up browser windows, and may also accumulate information about the user and deliver it to some central site. ( This is an
example of covert channels, in which surreptitious communications occur. ) Another common task of spyware is to send out spam e-
mail messages, which then purportedly come from the infected user.
15.2.2 Trap Door
• A Trap Door is when a designer or a programmer ( or hacker ) deliberately inserts a security hole that they can use later to access the
system.
• Because of the possibility of trap doors, once a system has been in an untrustworthy state, that system can never be trusted again.
Even the backup tapes may contain a copy of some cleverly hidden back door.
• A clever trap door could be inserted into a compiler, so that any programs compiled with that compiler would contain a security hole.
This is especially dangerous, because inspection of the code being compiled would not reveal any problems.
15.2.3 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.
15.2.4 Stack and Buffer Overflow
• This is a classic method of attack, which exploits bugs in system code that allows buffers to overflow. Consider what happens in the
following code, for example, if argv[ 1 ] exceeds 256 characters:
o The strcpy command will overflow the buffer, overwriting adjacent areas of memory.
o ( The problem could be avoided using strncpy, with a limit of 255 characters copied plus room for the null byte. )
#include
#define BUFFER_SIZE 256
int main( int argc, char * argv[ ] )
{
char buffer[ BUFFER_SIZE ];
if( argc < 2 )
return -1;
else {
strcpy( buffer, argv[ 1 ] );
return 0;
}
}
Figure 15.2 - C program with buffer-overflow condition. 5
OS - Lecture OS Security & Protection
• So how does overflowing the buffer cause a security breach? Well the first step is to understand the structure of the stack in memory:
o The "bottom" of the stack is actually at a high memory address, and the stack grows towards lower addresses.
o However the address of an array is the lowest address of the array, and higher array elements extend to higher addresses. ( I.e. an
array "grows" towards the bottom of the stack.
o In particular, writing past the top of an array, as occurs when a buffer overflows with too much input data, can eventually overwrite
the return address, effectively changing where the program jumps to when it returns.
Figure 15.4 - Hypothetical stack frame for Figure 15.2, (a) before and (b) after.
• Unfortunately famous hacks such as the buffer overflow attack are well published and well known, and it doesn't take a lot of skill to
follow the instructions and start attacking lots of systems until the law of averages eventually works out. ( Script Kiddies are those
hackers with only rudimentary skills of their own but the ability to copy the efforts of others. )
• Fortunately modern hardware now includes a bit in the page tables to mark certain pages as non-executable. In this case the buffer-
overflow attack would work up to a point, but as soon as it "returns" to an address in the data space and tries executing statements
there, an exception would be thrown crashing the program.
• ( More details about stack-overflow attacks are available on-line from http://www.insecure.org/stf/smashstack.txt )
15.2.5 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 ( see below. ) Figure 15.5 shows typical operation of a boot sector virus:
• Some of the forms of viruses include:
o 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.
o 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.
6
OS - Lecture OS Security & Protection
o 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.
o Source code viruses look for source code and infect it in order to spread.
o Polymorphic viruses change every time they spread - Not their underlying functionality, but just their signature, by which virus
checkers recognize them.
o Encrypted viruses travel in encrypted form to escape detection. In practice they are self-decrypting, which then allows them to infect
other files.
o 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.
o Tunneling viruses attempt to avoid detection by inserting themselves into the interrupt handler chain, or into device drivers.
o Multipartite viruses attack multiple parts of the system, such as files, boot sector, and memory.
o 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 "...".
• In 2004 a virus exploited three bugs in Microsoft products to infect hundreds of Windows servers ( including many trusted sites )
running Microsoft Internet Information Server, which in turn infected any Microsoft Internet Explorer web browser that visited any of
the infected server sites. One of the back-door programs it installed was a keystroke logger, which records users keystrokes, including
passwords and other sensitive information.
• There is some debate in the computing community as to whether a monoculture, in which nearly all systems run the same hardware,
operating system, and applications, increases the threat of viruses and the potential for harm caused by them.
9
OS - Lecture OS Security & Protection
▪ 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.
15.5.5 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.
15.6.5 Auditing, Accounting, and Logging
• 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.
15.7 Firewalling to Protect Systems and Networks
• 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.
• A common architecture is to establish a de-militarized zone, DMZ, which sort of sits "between" the company domain and the outside
world, as shown below. Company computers can reach either the DMZ or the outside world, but outside computers can only reach the
DMZ. Perhaps most importantly, the DMZ cannot reach any of the other company computers, so even if the DMZ is breached, the
attacker cannot get to the rest of the company network. ( In some cases the DMZ may have limited access to company computers,
such as a web server on the DMZ that needs to query a database on one of the other company computers. )