Operating Systems · Unit 5
Security and Protection
An operating system runs programs from many users at once and keeps everyone's data on the same disks. It must make sure each user and program can do only what it is allowed to, and it must defend the whole system against attack. These two jobs are called protection and security.
1. Protection and security
DefinitionsProtection is the set of mechanisms inside the OS that control which processes and users may access which resources. Security is the wider task of defending the system against internal and external threats, such as theft of data, damage or misuse.
Security aims to keep three properties, often called the CIA triad:
- Confidentiality – only authorised people can read the data.
- Integrity – only authorised people can change the data, and changes can be trusted.
- Availability – the system and data are there when legitimate users need them.
Two design principles guide protection:
- Principle of least privilege – give each user and program only the rights it needs to do its job, and no more. A compromised program can then do limited harm.
- Defence in depth – use several layers of protection, so one failure does not open the whole system.
2. Domains and the access matrix
A protection domain is a set of objects (files, devices, memory) together with the operations allowed on each. A process runs in one domain at a time. The access matrix shows every domain as a row and every object as a column; each cell lists the allowed operations.
| Domain | File F1 | File F2 | File F3 | Printer |
| D1 (student) | read | | read | |
| D2 (teacher) | read, write | read, write | read | print |
| D3 (backup job) | read | read | read | |
A real matrix is huge and mostly empty, so it is stored in one of two ways:
| Point | Access control list (ACL) | Capability list |
| Stores | One column: for each object, who may do what | One row: for each domain, what it may do to which objects |
| Kept with | The object (for example a file) | The domain or process |
| Easy to answer | "Who can access this file?" | "What can this process access?" |
| Removing a right | Easy: edit the object's list | Hard: capabilities may be spread across many processes |
3. UNIX file permissions, solved
UNIX keeps a short ACL for every file: read (r), write (w) and execute (x) rights for three classes, the owner, the group and others. Each right has a value: r = 4, w = 2, x = 1. Adding them gives one digit per class.
| Octal | Owner | Group | Others | Shown as |
| 750 | 7 = r + w + x | 5 = r + x | 0 = none | rwxr-x--- |
| 644 | 6 = r + w | 4 = r | 4 = r | rw-r--r-- |
| 700 | 7 = r + w + x | 0 = none | 0 = none | rwx------ |
The command chmod 644 notes.txt lets the owner read and write the file while everyone else can only read it.
4. Authentication
Before the OS can apply rights, it must know who the user is. Common methods:
- Passwords – the most common method. The system should never store passwords as plain text. It stores a salted hash: a random salt is added to the password and the result is passed through a slow one-way function such as bcrypt or Argon2, so a stolen password file is hard to reverse.
- One-time passwords – a code that works only once, for example sent by SMS or produced by an authenticator app.
- Biometrics – fingerprints or face recognition.
- Two-factor authentication – combines two different kinds of proof: something you know (a password), something you have (a phone) or something you are (a fingerprint).
Exam tipAuthentication answers "who are you?". Authorisation (the access matrix) answers "what are you allowed to do?". Do not mix the two words up in answers.
5. Threats
| Threat | What it is |
| Trojan horse | A program that looks useful but secretly does harm, such as stealing passwords. |
| Trap door (back door) | A hidden way into a program that skips the normal security checks, left by its programmer. |
| Logic bomb | Code that does harm only when a condition is met, such as a certain date. |
| Buffer overflow | A program writes more data into a buffer than it can hold, overwriting nearby memory; an attacker can use this to run their own code. |
| Virus | Code that attaches itself to another program or file and spreads when that program runs. |
| Worm | A standalone program that copies itself across a network without needing a host program. |
| Denial of service (DoS) | Floods a system with requests so that legitimate users cannot use it. When many machines attack together it is a distributed DoS (DDoS). |
| Port scanning | Probing a computer's network ports to find services that could be attacked. |
6. Defences
- Cryptography – symmetric encryption (such as AES) uses one shared key and is fast; asymmetric encryption (such as RSA) uses a public key to encrypt and a private key to decrypt, which solves the problem of sharing keys. Secure websites (HTTPS) use asymmetric cryptography to agree a key, then symmetric encryption for the data.
- Firewalls – allow or block network traffic according to rules.
- Intrusion detection – watches system and network activity for signs of attack.
- Updates and patches – fix known weaknesses before attackers use them.
- Auditing and logs – record who did what, so misuse can be traced.
- Antivirus software – detects known malware by signatures and suspicious behaviour.
7. Quick revision
- Protection controls access inside the system; security defends against threats.
- CIA: confidentiality, integrity, availability.
- Least privilege: give only the rights that are needed.
- Access matrix: rows are domains, columns are objects.
- ACL = column, kept with the object. Capability list = row, kept with the domain.
- UNIX rights: r = 4, w = 2, x = 1, for owner, group and others.
- Store passwords as salted hashes, never as plain text.
- A virus needs a host program; a worm spreads on its own.
8. Practice questions
Q1. Write the permission string for octal 754.
Answer: 7 = rwx, 5 = r-x, 4 = r--, so the string is rwxr-xr--.
Q2. What is the difference between a virus and a worm?
Answer: A virus attaches to another program and spreads when that program runs. A worm is a standalone program that spreads by itself across a network.
Q3. Why is it easier to remove a user's right to a file with an ACL than with capability lists?
Answer: The ACL is stored with the file, so one list is edited. Capabilities are held by the processes themselves and may be copied to many places.
|