PadhaikoAll subjects

Security and System Administration

Operating System (ENCT 254)

Open in the Padhaiko app

6.1 OS security: Cryptography, multi-factor authentication (MFA), secure boot and sandboxing

An operating system is secure when its hardware, software, and stored data are accessed and used strictly as intended. OS security rests on the CIA Triad:

A vulnerability is a weakness in system code or policy, a threat is the potential for violation, and an attack is an active attempt (masquerade, replay, modification, denial of service) or passive attempt (eavesdropping, traffic analysis) to exploit a vulnerability—including insider threats (logic bombs, trap doors, login spoofing) and malware (Trojan horses, viruses, worms, spyware, botnets).

Cryptography

Cryptography transforms readable plaintext () into unreadable ciphertext () using an encryption algorithm and key so that only authorized parties can recover the plaintext.

Definition

Symmetric vs. Asymmetric Cryptography

  1. Secret-Key (Symmetric) Cryptography: Both sender and receiver share a single secret key for encryption and decryption:
  1. Public-Key (Asymmetric) Cryptography: Each participant holds a mathematically linked key pair: a public key (, shared openly) and a private key (, kept strictly secret).
    • Confidentiality mode: Anyone encrypts a message with the receiver's ; only the receiver can decrypt it with .
    • Trade-off: Solves key distribution without a pre-shared secret, though slower than symmetric ciphers (e.g., RSA, ECC).
Definition

Cryptographic Hashing and Digital Signatures

A digital signature proves the sender's identity (authentication), guarantees non-repudiation, and detects tampering (integrity):

  1. The sender passes the document through a one-way cryptographic hash function that produces a fixed-size digest (e.g., MD5: , SHA-1: , SHA-256: , SHA-512: ; MD5 and SHA-1 are now deprecated for security-critical signing in favor of SHA-256/SHA-512).
  2. The sender encrypts (signs) the hash digest using their private key to produce a signature block, and attaches it to .
  3. The receiver recomputes independently, decrypts the signature block using the sender's public key to obtain , and verifies . Any mismatch means or the signature was altered.

Multi-Factor Authentication (MFA)

Authentication verifies a user's claimed identity before granting a login session. Relying on a username and password alone is vulnerable to phishing, guessing, and login spoofing. Multi-Factor Authentication (MFA) requires combining two or more independent categories of credentials:

Three Factors of Authentication in MFA
Factor CategoryBasisExamples
Knowledge (Something you know)Secret memorized by the userPasswords, PINs, security challenge answers
Possession (Something you have)Physical or hardware-backed tokenSmart cards, FIDO2/USB security keys, TOTP authenticator apps, hardware OTP tokens
Inherence (Something you are)Biometric characteristicFingerprint scan, facial recognition, iris/retina pattern

Two-factor authentication (2FA)—such as a password plus a challenge-response token or biometric check—is the most common deployment of MFA in modern OS logins and enterprise systems.

Secure Boot

Secure Boot is a firmware-level security standard (part of UEFI) that prevents rootkits, bootkits, and tampered OS kernels from loading before the operating system takes control.

Definition

UEFI Secure Boot Verification Chain

Secure Boot establishes a cryptographic chain of trust anchored in firmware key databases:

At power-on, UEFI verifies the digital signature of the bootloader against db (and confirms it is not in dbx). The bootloader in turn verifies the OS kernel image, and the kernel verifies signed kernel modules/drivers before execution. Any unsigned or tampered component halts the boot sequence.

Sandboxing

Sandboxing isolates an untrusted or network-facing program inside a tightly constrained execution environment so that even if the application is compromised, it cannot harm the host OS or read other applications' data.


6.2 Access control: Policies, lists, and OS support

Once a user is authenticated, the OS must decide which process may perform which operation on which resource.

Protection Domains and the Access Matrix

A computer system consists of hardware and software objects (CPUs, memory segments, printers, files, databases, semaphores), each supporting a finite set of operations.

Definition

Protection Domain and Access Matrix

Because most domains have no rights on most objects, storing the full access matrix in memory or on disk wastes huge space. Operating systems therefore store only non-empty entries using Access Control Lists (ACLs) (by column) or Capability Lists (by row).

Access Control Lists (ACLs)

An Access Control List (ACL) stores one column of the access matrix directly with each object: an ordered list of (subject, rights) entries specifying which users or groups are allowed (or explicitly denied) specific permissions such as Read, Write, Execute, Delete, Create, Modify, List, or Full Control.

AspectAccess Control List (ACL)Capability List
Matrix DecompositionStored per object (column of the matrix)Stored per domain/process (row of the matrix)
Permission LookupOS checks the object's ACL when a subject requests accessProcess presents an unforgeable capability ticket for the object
RevocationEasy—edit or remove the entry in the object's ACLHarder—must locate and invalidate distributed tickets
Typical OS UsageUNIX/Linux POSIX ACLs, Windows NTFS DACLsMicrokernels, object-capability systems (e.g., seL4, Capsicum)

Access Control Policies

Definition

DAC, MAC, and RBAC Policies

  1. Discretionary Access Control (DAC): The resource owner decides who may access the object and can transfer permissions (e.g., standard Linux chmod / Windows file sharing). Flexible, but vulnerable to Trojan horses acting with the owner's privileges.
  2. Mandatory Access Control (MAC): A central system-wide security policy labels both subjects (clearance) and objects (classification); individual owners cannot override it (e.g., Bell–LaPadula confidentiality model, SELinux, AppArmor).
  3. Role-Based Access Control (RBAC): Permissions are assigned to organizational roles (e.g., DatabaseAdmin, Auditor, Student), and users are assigned to one or more roles. Simplifies administration in large organizations.

OS Support for Access Control


6.3 System administration: User management, environment setup and tools (AWK, shell scripts, make)

System administration is the operational management of computers, operating systems, application software, networks, and users in an organization. Core administrator duties include applying OS updates and patches, installing hardware/software, managing user accounts, tuning performance, running backups, auditing security, inspecting system logs, and troubleshooting failures.

User Management

Multi-user operating systems isolate each person's workspace into an individual user account, each maintaining its own profile, application settings, private data folder, security privileges, and file system permissions.

Standard Account Types
Account TypePrivilege ScopeIntended Use & Notes
Standard UserCan run apps, manage personal files/settings, connect to networks, and use external USB devices; cannot make system-wide changes or install driversDefault account for everyday work (follows the principle of least privilege)
Administrator (root / Admin)Full system control: installs software/drivers, modifies OS files, configures firewalls/UAC, performs full backups, and creates/deletes user accountsUsed strictly for administrative tasks; on Linux invoked temporarily via sudo
GuestMinimal temporary access with no persistent profile and no access to other users' files or system settingsDisabled by default for security

On Linux, administrators manage accounts and groups from the CLI using useradd / adduser, usermod, passwd, userdel, and groupadd, backed by /etc/passwd, /etc/shadow (hashed passwords), and /etc/group. On Windows, account creation, password resets, account type changes, and deletion are performed via Control Panel / Settings or net user / PowerShell.

Environment Setup

When provisioning a new user or workstation, the administrator configures a working operational environment so users can log in and launch required tools without editing shell internals manually:

System Administration Tools: AWK, Shell Scripts, and Make

1. AWK

AWK (named after Aho, Weinberger, and Kernighan) is an interpreted pattern-scanning and text-processing language widely used by administrators to filter logs, extract columns, and generate formatted reports without compiling a program.

Definition

AWK Execution Model and Syntax

AWK Command SyntaxText
awk [options] 'pattern { action }' input-file

For every input line (record), AWK automatically:

  1. Splits the line into whitespace-delimited fields (or using a custom delimiter via -F fs): , , ..., , while holds the entire line.
  2. Evaluates pattern (a regex /text/ or boolean condition like , or BEGIN/END).
  3. Executes { action } on every matching line (-f prog.awk reads rules from a file). Built-in variables include NR (current record/line number) and NF (number of fields in the current line).
Common AWK Commands on employee.txtText
# Print every line (default action when no pattern is given)
awk '{print}' employee.txt

# Print only lines matching the pattern "manager"
awk '/manager/ {print}' employee.txt

# Print columns 1 (Name) and 4 (Salary) using space or ':' delimiter
awk '{print $1, $4}' employee.txt
awk -F ':' '{print $1, $3}' /etc/passwd

Compared to sed, AWK provides native numeric arithmetic, variables, control flow (if/for), built-in string/math functions, and automatic field splitting in a C-like syntax.

2. Shell Scripts

A shell script is a plain-text file containing a sequence of OS commands, variables, conditionals, and loops executed by a command interpreter (such as /bin/sh or /bin/bash) to automate repetitive administration tasks (backups, log rotation, bulk account creation).

Automated Backup and Disk-Usage Alert Shell ScriptText
#!/bin/bash
# backup_check.sh - Archive /home and warn if disk usage exceeds 80%

BACKUP_DIR="/var/backups"
DATE_TAG=$(date +%F)
tar -czf "$BACKUP_DIR/home-$DATE_TAG.tar.gz" /home

USAGE=$(df / | awk 'NR==2 {gsub(/%/, "", $5); print $5}')
if [ "$USAGE" -gt 80 ]; then
    echo "WARNING: Root filesystem at ${USAGE}% capacity"
    exit 1
fi
echo "Backup complete; disk usage normal (${USAGE}%)."
exit 0

3. Make

make is a build-and-task automation utility driven by a file named Makefile. Instead of running every compile or setup command blindly from scratch, make builds a dependency graph and compares file modification timestamps—re-executing only the steps whose inputs (prerequisites) are newer than their output (target).

Sample Makefile for Incremental C Compilation and Admin TasksText
CC = gcc
CFLAGS = -Wall -O2

app: main.o utils.o
	$(CC) $(CFLAGS) -o app main.o utils.o

main.o: main.c defs.h
	$(CC) $(CFLAGS) -c main.c

utils.o: utils.c defs.h
	$(CC) $(CFLAGS) -c utils.c

clean:
	rm -f *.o app

Each rule has the form target: prerequisites followed by tab-indented recipe commands. If only utils.c is edited, running make recompiles utils.o and relinks app, skipping main.o. Beyond C builds, administrators use Makefiles to automate configuration regeneration (e.g., rebuilding /etc/aliases or deploying config templates).


Worked Out Examples

Example 6.1

6.1

In a small-scale RSA public-key cryptosystem, choose primes and with public exponent .

  1. Compute the modulus , Euler's totient , and the private exponent .
  2. Encrypt the plaintext integer to obtain ciphertext , and verify decryption back to .

Computing and :

Finding the private exponent : is the modular inverse of modulo , satisfying :

Public key is and private key is .

Encrypting and decrypting :

  • Encryption: (since and ).
  • Decryption: . Since :

Dividing , we recover .

Answer:

, , ; ciphertext is , which decrypts back to .

Example 6.2

6.2

  1. Convert the following Access Matrix into Access Control Lists (ACLs) per object:
    • Alice: report.doc (Read, Write), backup.sh (Read, Write, Execute), printer (Use)
    • Bob: report.doc (Read), backup.sh (Execute)
    • Charlie: printer (Use)
  2. Express the Linux permission strings -rwxr-x--- and -rw-r----- in octal form for chmod.

Deriving the ACL for each object (column-wise extraction):

  • ACL(report.doc): [(Alice: R, W), (Bob: R)]
  • ACL(backup.sh): [(Alice: R, W, X), (Bob: X)]
  • ACL(printer): [(Alice: Use), (Charlie: Use)]

Notice that empty cells (such as Charlie on report.doc) are omitted.

Computing octal chmod values ():

  • For -rwxr-x---:
    • Owner (rwx):
    • Group (r-x):
    • Others (---):
    • Octal mode =
  • For -rw-r-----:
    • Owner (rw-):
    • Group (r--):
    • Others (---):
    • Octal mode =
Answer:

ACLs: report.doc (Alice: RW, Bob: R), backup.sh (Alice: RWX, Bob: X), printer (Alice: Use, Charlie: Use). Octal modes: -rwxr-x--- = 750, -rw-r----- = 640.

Example 6.3

6.3

Given employee.txt with records:

Write a single AWK command that prints each manager's name and salary, and at the end prints the total manager payroll. Trace its exact output.

Writing the pattern-action AWK command: We match /manager/ (or ) in the body rule, accumulate sum += ..., and print the accumulated total inside an END block:

AWK Script for Manager PayrollText
awk '$2 == "manager" { print $1, $4; sum += $4 } END { print "Total:", sum }' employee.txt

Tracing line-by-line execution:

  • Line 1 (ajay manager ...): matches prints ajay 45000, sum = 45000.
  • Line 2 (sunil clerk ...): skipped.
  • Line 3 (varun manager ...): matches prints varun 50000, sum = 45000 + 50000 = 95000.
  • Line 4 (amit manager ...): matches prints amit 47000, sum = 95000 + 47000 = 142000.
  • Line 5 (tarun peon ...): skipped.
  • End of file (END block): prints Total: 142000.
Answer:

Output: ajay 45000, varun 50000, amit 47000, Total: 142000.


Exercises

Exercise — Security and System Administration

Question 1

Differentiate between secret-key (symmetric) and public-key (asymmetric) cryptography, and explain how a digital signature verifies both authenticity and integrity. Using RSA with primes , , and , find the private key , encrypt message , and verify decryption.

Symmetric vs. asymmetric cryptography and digital signatures:

  • Secret-key cryptography uses one shared secret key for encryption and decryption (fast, but requires secure key distribution).
  • Public-key cryptography uses a public encryption key and a secret private decryption key.
  • For a digital signature, the sender hashes the document (e.g., SHA-256) and signs the hash with their private key; the receiver hashes the received document and compares it with the digest decrypted by the sender's public key.

Computing RSA parameters ():

We solve : since , we get .

Encrypting and checking decryption:

  • Ciphertext: .
  • Decryption: . Using , , , :
Answer:

Private key (with ); ciphertext is , which decrypts back to .

Question 2

Explain Multi-Factor Authentication (MFA), Secure Boot, and Sandboxing, noting the specific OS threat each mechanism mitigates.

Multi-Factor Authentication (MFA): Requires credentials from at least two independent factors—knowledge (password/PIN), possession (hardware token/authenticator app), and inherence (biometrics). It mitigates password theft, brute-force cracking, and phishing.

Secure Boot: UEFI verifies cryptographic signatures (against PK/KEK/db and checking revocation list dbx) at every early boot stage from firmware to bootloader to OS kernel. It prevents bootkits and kernel-level rootkits from executing before the OS loads.

Sandboxing: Confines untrusted applications using syscall filtering (seccomp), isolated namespaces/filesystems, and minimal capabilities so a compromised program (e.g., a browser tab or mobile app) cannot tamper with the host OS or read other users' files.

Answer:

MFA blocks credential theft by combining knowledge, possession, and biometric factors; Secure Boot prevents pre-OS bootkits via a firmware-to-kernel signature chain; Sandboxing contains compromised apps by restricting syscalls, namespaces, and file access.

Question 3

Compare Discretionary Access Control (DAC), Mandatory Access Control (MAC), and Role-Based Access Control (RBAC), and explain why operating systems implement ACLs or Capability Lists instead of storing a full Protection Matrix.

Comparing access control policies:

  • DAC: Resource owners control and share permissions on their own objects (e.g., chmod, NTFS permissions).
  • MAC: Central kernel policy enforces security labels regardless of owner wishes (e.g., SELinux, AppArmor).
  • RBAC: Access rights are bundled into roles (Admin, Instructor) and users inherit rights by role membership.

Why ACLs/Capabilities replace the full Protection Matrix: A full Protection Matrix of domains objects is mostly empty (sparse), wasting memory/disk space and lookup time. Storing non-empty entries by column yields an ACL (fast per-object auditing and easy revocation), whereas storing by row yields a Capability List (fast per-process token verification).

Answer:

DAC is owner-controlled, MAC is system-enforced via labels, and RBAC maps rights to roles. ACLs (columns) and Capability Lists (rows) avoid storing the huge, sparse Protection Matrix.

Question 4

Distinguish between Standard User, Administrator, and Guest accounts in OS user management. Also calculate the numeric chmod octal values for -rwxr--r-- and -rw-rw----, and explain what each digit grants.

Account types:

  • Standard User: Runs applications and modifies personal files/settings only; cannot alter system files or install drivers.
  • Administrator: Has unrestricted control over OS configuration, software installation, firewalls, backups, and all user accounts.
  • Guest: Temporary, tightly restricted account without persistent profile storage (disabled by default for security).

Calculating octal permission modes ():

  • -rwxr--r--: Owner , Group , Others 744 (owner can read/write/execute; group and others can read only).
  • -rw-rw----: Owner , Group , Others 660 (owner and group can read/write; others have no access).
Answer:

Standard accounts perform daily non-system tasks, Administrator accounts control system-wide changes, and Guest accounts provide temporary minimal access. -rwxr--r-- = 744; -rw-rw---- = 660.

Question 5

Suppose /etc/staff.csv uses : as a delimiter (name:role:dept:salary) and contains: ajay:manager:acct:45000, sunil:clerk:acct:25000, varun:manager:sales:50000, amit:manager:acct:47000, satvik:director:purch:80000. Write an AWK command to print the names of employees earning more than and compute their average salary. Verify the resulting average.

Constructing the AWK command with -F ':': We specify -F ':' so field is name and field is salary:

AWK Filter and Average CalculationText
awk -F ':' '$4 > 30000 { print $1; sum += $4; count++ } END { if (count > 0) print "Average:", sum / count }' /etc/staff.csv

Computing the matched rows and average: Four employees satisfy salary > 30000: ajay (), varun (), amit (), and satvik ().

Answer:

Names printed: ajay, varun, amit, satvik; Average salary = 55500.

Question 6

Explain the roles of shell scripts and make in system administration. Write a Makefile for a C program consisting of main.c, net.c, and net.h producing executable monitor, and explain what happens if only net.c is modified before running make.

Roles of shell scripts and make:

  • Shell scripts automate sequential administrative tasks (backups, log checks, user provisioning) using OS commands, variables, conditionals, and loops.
  • make automates dependency-driven builds or configuration updates via a Makefile, comparing file timestamps so only out-of-date targets are rebuilt.

Writing the Makefile:

Makefile for monitorText
CC = gcc
CFLAGS = -Wall -O2

monitor: main.o net.o
	$(CC) $(CFLAGS) -o monitor main.o net.o

main.o: main.c net.h
	$(CC) $(CFLAGS) -c main.c

net.o: net.c net.h
	$(CC) $(CFLAGS) -c net.c

Incremental rebuild behavior when net.c changes: main.o is still newer than both main.c and net.h, so make skips recompiling main.o. Because net.c is newer than net.o, make recompiles net.o, and since net.o is now newer than monitor, make relinks monitor.

Answer:

Shell scripts automate sequential workflows, while make performs timestamp-based incremental builds. Modifying net.c causes make to recompile only net.o and relink monitor, leaving main.o untouched.

Past exam questions for Operating System

← File SystemsHypervisors and Virtual Systems →