Operating Systems
Unit 6: Protection & Security
From access matrices to ransomware defence — master OS-level protection, authentication, and security mechanisms that safeguard modern systems.
⏱️ 6 hrs theory + 4 hrs lab | 💰 Earning Potential: ₹5K–₹20K/month | 📝 30 MCQs (Bloom's Mapped)
💼 Jobs this unlocks: Security Engineer (₹6–12 LPA) | Linux Admin (₹4–8 LPA)
Opening Hook — When an OS Fails to Protect
🏥 AIIMS Delhi Ransomware Attack — November 2022
On 23rd November 2022, India's most prestigious hospital — All India Institute of Medical Sciences, New Delhi — went dark. Ransomware crippled the hospital's entire IT infrastructure. Patient registration, lab reports, billing, smart-lab systems, and the outpatient department all ground to a halt. Doctors were forced to switch to pen-and-paper records for nearly two weeks.
The root cause? A buffer overflow vulnerability in an unpatched server. Attackers exploited this OS-level flaw to inject malicious code, escalated privileges, and deployed ransomware that encrypted 5 servers and 1.3 terabytes of data. An estimated 40 million patient records — including those of VVIPs, diplomats, and politicians — were at risk.
The attackers demanded cryptocurrency in exchange for decryption keys. CERT-In, NIA, and Delhi Police's IFSO were called in. It took 15 days to restore full operations. Total estimated damage: ₹200+ crores in disruption, reputation loss, and recovery.
Could OS-level protection mechanisms have stopped this? Could proper access control, buffer overflow protections, and security hardening have prevented a national health crisis? That's exactly what this chapter answers.
Learning Outcomes — Bloom's Taxonomy Mapped
| Bloom's Level | Learning Outcome |
|---|---|
| 🔵 Remember | List the types of malware (virus, worm, trojan, ransomware, spyware) and define buffer overflow, trapdoor, and access matrix |
| 🔵 Understand | Explain how the access matrix model enforces protection domains and how ACLs differ from capability lists |
| 🟢 Apply | Demonstrate Linux file permissions (chmod, chown, setuid) and implement password hashing using Python's hashlib |
| 🟢 Analyze | Analyze how the AIIMS ransomware attack exploited OS vulnerabilities and identify which protection mechanisms were missing |
| 🟠 Evaluate | Evaluate the effectiveness of India's IT Act 2000, CERT-In guidelines, and DPDP Act 2023 in preventing cyberattacks |
| 🟠 Create | Design a Linux Security Hardening Checklist for a small business server, applying the principle of least privilege |
Concept Explanation — OS Protection & Security from Scratch
1. Need for Security in Operating Systems
An operating system sits at the heart of every computer. It manages files, memory, processes, and hardware. If the OS is compromised, everything running on it is compromised — your passwords, your banking app, your medical records, your photos. The OS is the last line of defence between your data and an attacker.
🛡️ Why Does an OS Need Protection & Security?
Protection = Controlling access of processes and users to resources (files, memory, CPU). It's an internal concern — making sure that one user's process can't corrupt another user's files.
Security = Defending the system from external and internal threats — hackers, malware, unauthorized access, data theft.
Why Both Matter:• Multi-user systems: In a Linux server with 50 users, User A must not be able to read User B's private files.
• Networked systems: Servers connected to the internet are constantly probed by attackers. Without OS-level security, a single vulnerability can compromise millions of records.
• Critical infrastructure: Hospital systems (AIIMS), banking systems (UPI), government databases (Aadhaar) — all run on operating systems. A breach isn't just a tech problem; it's a national crisis.
Analogy: Think of the OS as the security system of a large apartment building. Protection is the lock on each flat's door (internal access control). Security is the boundary wall, CCTV cameras, and watchman (external threat defence). You need both — a lock without a boundary wall is useless, and a wall without locks is meaningless.
2. Security Vulnerabilities
2.1 Buffer Overflow — The #1 OS Vulnerability
Plain English: Imagine you have a glass that holds 250ml of water. Someone pours 500ml into it. The water overflows and spills onto the table, ruining your books and electronics. A buffer overflow is exactly this — a program writes more data into a memory buffer than it can hold, and the excess data overwrites adjacent memory, potentially overwriting the return address of a function to hijack program execution.
Technical Detail: In C/C++, arrays don't have bounds checking. If a program allocates a 64-byte buffer for user input but the user sends 200 bytes, the extra bytes overwrite the stack — including the return address. An attacker can craft this overflow to redirect execution to their malicious code (shellcode).
C // VULNERABLE CODE — Buffer Overflow Example #include <stdio.h> #include <string.h> void login() { char password[16]; // Buffer: only 16 bytes allocated printf("Enter password: "); gets(password); // DANGER! gets() doesn't check buffer size // If user enters 200 chars, it overflows! if (strcmp(password, "secret123") == 0) { printf("Access granted!\n"); } else { printf("Access denied!\n"); } } int main() { login(); return 0; }
🔍 How Stack Smashing Works
Step 1: Program allocates password[16] on the stack. The stack also holds the saved return address (where the function should return after execution).
Step 2: Attacker enters 200 characters instead of 16. The excess bytes overflow past the buffer boundary.
Step 3: The overflow overwrites the saved return address with the address of the attacker's shellcode.
Step 4: When login() returns, instead of going back to main(), it jumps to the attacker's code — giving them shell access.
[password buffer: 16 bytes] [saved frame pointer: 4 bytes] [return address: 4 bytes]
[AAAAAAAAAAAAAAAA] [AAAA] [attacker's address → shellcode]
• ASLR (Address Space Layout Randomization): Randomizes memory addresses, making it hard to predict where shellcode lands.
• Stack Canaries: A secret value placed before the return address. If overwritten, the OS detects the overflow and kills the process.
• DEP/NX (Data Execution Prevention): Marks the stack as non-executable — even if shellcode lands there, it can't run.
• Safe functions: Use
fgets() instead of gets(), strncpy() instead of strcpy().
2.2 Trapdoors & Backdoors
Trapdoor (Backdoor): A secret entry point in a program that bypasses normal authentication. Developers sometimes leave these intentionally for debugging — but if discovered by attackers, they become devastating vulnerabilities.
Example: A developer hardcodes if (username == "debug_admin") grant_access(); in the login system for testing, then forgets to remove it before deployment. Any attacker who discovers this username gets full admin access without a password.
2.3 Cache Poisoning
DNS Cache Poisoning: An attacker corrupts the DNS cache of a resolver, redirecting users to a fake website even though they typed the correct URL. You type www.sbi.co.in but land on a fake SBI login page that steals your credentials.
ARP Cache Poisoning: On a local network, attackers send fake ARP responses, tricking devices into sending traffic through the attacker's machine (enabling Man-in-the-Middle attacks).
3. Authentication
3.1 Password-Based Authentication in Linux
Linux uses a two-file system for password storage — a design that's a masterclass in security:
| File | Purpose | Permissions | Content |
|---|---|---|---|
/etc/passwd | User account info (username, UID, GID, home dir, shell) | Readable by all users (644) | ravi:x:1001:1001:Ravi Kumar:/home/ravi:/bin/bash |
/etc/shadow | Encrypted password hashes | Readable only by root (640) | ravi:$6$salt$hashvalue:19500:0:99999:7::: |
Why two files? In early Unix, password hashes were stored directly in /etc/passwd (readable by everyone). Attackers could copy the hashes and crack them offline. The /etc/shadow file was introduced to store hashes separately with root-only access — a classic application of the principle of least privilege.
The x in the password field of /etc/passwd indicates that the actual hash is in /etc/shadow. The $6$ prefix in the shadow file indicates SHA-512 hashing (the current default on most Linux distributions).
3.2 Password Hashing — MD5, SHA-256, and Salting
Why hash? Storing passwords in plain text is catastrophic. If a database is breached, all passwords are exposed. Hashing converts a password into a fixed-length, irreversible string. Even if an attacker gets the hash, they can't easily reverse it to get the password.
Salting: A random string added to the password before hashing. Two users with the password "password123" will have different hashes because of different salts. This defeats rainbow table attacks.
Python import hashlib import os # --- MD5 Hashing (WEAK — don't use in production!) --- password = "secure@123" md5_hash = hashlib.md5(password.encode()).hexdigest() print(f"MD5: {md5_hash}") # Output: MD5: a fixed 32-char hex string # --- SHA-256 Hashing (STRONG — industry standard) --- sha256_hash = hashlib.sha256(password.encode()).hexdigest() print(f"SHA-256: {sha256_hash}") # Output: SHA-256: a fixed 64-char hex string # --- SHA-256 with SALT (RECOMMENDED) --- salt = os.urandom(16).hex() # Random 16-byte salt salted_password = salt + password salted_hash = hashlib.sha256(salted_password.encode()).hexdigest() print(f"Salt: {salt}") print(f"Salted: {salted_hash}") # Store BOTH salt and hash in the database # To verify: re-hash the entered password with the same salt and compare
3.3 Secure Communication — SSL/TLS Handshake (Simplified)
When you visit https://www.sbi.co.in, your browser and SBI's server perform a TLS handshake to establish an encrypted connection:
🔐 SSL/TLS Handshake — Simplified Steps
Step 1 — Client Hello: Your browser sends: "I want to connect securely. Here are the encryption algorithms I support."
Step 2 — Server Hello: SBI's server responds: "Let's use AES-256. Here's my digital certificate (proves I'm really SBI, signed by a Certificate Authority like DigiCert)."
Step 3 — Key Exchange: Browser verifies the certificate, generates a random session key, encrypts it with SBI's public key, and sends it.
Step 4 — Secure Session: Both sides now share the same session key. All further communication is encrypted with AES-256. The 🔒 icon appears in your browser.
4. Application Security — Malware & Program Threats
4.1 Malware Comparison
| Type | Self-Replicates? | Needs Host? | Behaviour | Indian Example |
|---|---|---|---|---|
| Virus | ✅ Yes | ✅ Yes (attaches to files) | Infects files/programs, activates when host runs | CIH virus damaged BIOS chips of thousands of Indian PCs (1998) |
| Worm | ✅ Yes | ❌ No (standalone) | Spreads via networks automatically, consumes bandwidth | Slammer worm affected BSNL networks (2003) |
| Trojan | ❌ No | ❌ No (disguised app) | Appears legitimate but contains malicious payload | Fake "Aarogya Setu" APKs distributed via WhatsApp (2020) |
| Ransomware | Sometimes | ❌ No | Encrypts files, demands ransom for decryption key | AIIMS Delhi attack (2022), WannaCry in Indian railways (2017) |
| Spyware | ❌ No | ❌ No | Silently monitors user activity, captures keystrokes | Pegasus spyware on Indian journalists' phones (2021) |
4.2 Program Threats
Logic Bomb: Malicious code that lies dormant until a specific condition is triggered (date, event, action). Example: A disgruntled IT employee at an Indian bank embeds code that deletes salary records if they're ever terminated from the system.
Privilege Escalation: An attacker gains higher access than intended. Vertical escalation: Normal user → root/admin. Horizontal escalation: User A accesses User B's data without authorisation.
5. Protection Mechanisms
5.1 Goals & Principles of Protection
The fundamental goal of protection is to ensure that each system resource is accessed only by authorised users in authorised ways. The key principle:
🎯 Principle of Least Privilege
Every program, user, and system component should operate with the minimum set of privileges necessary to complete its task.
• A web server should NOT run as root. It only needs to read web files and listen on port 80/443.
• A database user for a reporting tool should have read-only access, not write/delete permissions.
• Your phone's calculator app should NOT have access to your contacts, camera, or messages.
Why It Matters:If a component is compromised, the damage is limited to only the resources it could access. In the AIIMS attack, if the compromised server had only read access to patient scheduling (not the full database), 40 million records wouldn't have been at risk.
5.2 Domain of Protection — Domain Switching
A protection domain defines a set of resources (objects) and the operations (rights) a process can perform on them. Each process executes in a specific domain.
Domain Switching: A process may need to switch domains to perform different tasks. Example: When you run passwd in Linux to change your password, the process temporarily switches from your user domain to the root domain (via the setuid bit) because only root can write to /etc/shadow. Once done, it switches back.
| Domain | Objects Accessible | Rights |
|---|---|---|
| D₁ (Normal User) | Own files, /tmp | Read, Write, Execute (own files only) |
| D₂ (Web Server) | /var/www/html, port 80 | Read (web files), Listen (port) |
| D₃ (Root/Admin) | All files, all processes, hardware | Read, Write, Execute, Delete — everything |
5.3 Access Matrix — The Core Protection Model
The Access Matrix is a theoretical model that defines the rights of each subject (user/process) over each object (file/resource). It's a table where:
- Rows = Subjects (users, processes, domains)
- Columns = Objects (files, devices, memory segments)
- Cells = Access rights (read, write, execute, delete, owner)
📊 Access Matrix — Example
| Subject \ Object | File1 (marks.txt) | File2 (salary.xls) | Printer | Network Port 80 |
|---|---|---|---|---|
| Student (Ravi) | Read | — | — | |
| Faculty (Dr. Sharma) | Read, Write | Read | — | |
| Admin (Root) | Read, Write, Delete, Owner | Read, Write, Delete, Owner | Print, Configure | Listen, Configure |
| Web Server Process | — | — | — | Listen |
Reading the matrix: Ravi can only Read marks.txt and Print. He cannot access salary.xls at all. Dr. Sharma can read and write marks but only read salaries. Only Root has full control over everything.
5.4 Implementation: Access Control Lists (ACLs) vs Capability Lists
The access matrix is a conceptual model. In practice, it's too large and sparse to store as a full table. Two practical implementations:
| Feature | Access Control List (ACL) | Capability List (C-List) |
|---|---|---|
| Stored With | Each object (file/resource) | Each subject (user/process) |
| Perspective | "Who can access this file?" | "What can this user access?" |
| Analogy | Guest list at a club door (object-centric) | VIP pass that lets you enter multiple venues (subject-centric) |
| Easy To | Check/revoke access to a specific file | Check all resources a user can access |
| Hard To | Find all files a user can access (must scan all ACLs) | Revoke access to a specific file (must scan all C-Lists) |
| Real-World Use | Linux file permissions, Windows NTFS, AWS IAM policies | Android app permissions, capability-based OS (seL4) |
| Security | Easier revocation per resource | Better for delegation (passing capabilities) |
Linux uses ACLs. When you run ls -l, you see the ACL for each file: -rwxr-x--- 1 ravi staff 4096 Jan 15 file.txt. This says: Owner (ravi) has rwx, group (staff) has r-x, others have no access.
6. System & Network Threats
6.1 Denial of Service (DoS) & Distributed DoS (DDoS)
DoS Attack: Flooding a server with so many requests that it can't serve legitimate users. Like 10,000 people crowding a small shop — real customers can't get in.
DDoS Attack: Same attack but launched from thousands of compromised machines (botnet) simultaneously. Much harder to defend against because traffic comes from many different IPs.
6.2 Man-in-the-Middle (MITM) Attack
The attacker secretly intercepts and potentially alters communication between two parties who believe they're talking directly to each other.
Indian Example: You're at a café in Connaught Place, Delhi, using free public Wi-Fi. An attacker on the same network performs ARP cache poisoning, routing all your traffic through their laptop. When you log into your bank, they capture your credentials. This is why HTTPS is critical — even if traffic is intercepted, it's encrypted.
6.3 SQL Injection
An attacker inserts malicious SQL code into input fields to manipulate the backend database. If a login form doesn't sanitize input:
SQL -- Normal login query: SELECT * FROM users WHERE username='ravi' AND password='secure123'; -- Attacker enters username: ' OR '1'='1' -- -- Resulting query: SELECT * FROM users WHERE username='' OR '1'='1' --' AND password='anything'; -- This always returns TRUE → attacker gains access without a password!
6.4 Port Scanning
Attackers use tools like Nmap to scan a server's ports to find open services. An open port 22 (SSH) with a weak password is an invitation for brute-force attacks. An open port 3306 (MySQL) exposed to the internet is a database breach waiting to happen.
7. Indian Cybersecurity Legal Framework
| Law/Body | Year | Key Provisions |
|---|---|---|
| IT Act 2000 | 2000 (amended 2008) | India's primary cyber law. Section 43: Penalty for unauthorized access. Section 66: Computer-related offences. Section 72: Breach of confidentiality/privacy. Section 43A: Compensation for failure to protect data. |
| CERT-In | 2004 | Indian Computer Emergency Response Team. National agency for cybersecurity incidents. Issues advisories, coordinates incident response. Mandatory 6-hour breach reporting rule (April 2022). |
| DPDP Act 2023 | 2023 | Digital Personal Data Protection Act. India's equivalent of GDPR. Mandates consent for data collection, right to erasure, data fiduciary obligations, penalties up to ₹250 crore for violations. |
Learn by Doing — 3-Tier Lab Structure
🟢 Tier 1 — GUIDED TASK: Linux File Permissions Lab
Objective
Understand Linux file permissions, ownership, setuid, and inspect /etc/shadow.
Step 1: Open a Linux Terminal
Use Ubuntu (native, WSL on Windows, or online: replit.com). Open the terminal.
Step 2: Create Test Files and Users
Bash # Create a test directory mkdir ~/security_lab cd ~/security_lab # Create test files echo "Student marks: Ravi=85, Priya=92" > marks.txt echo "Top Secret: Admin Password List" > secret.txt echo "Public announcement: College closed tomorrow" > notice.txt
Step 3: View Current Permissions
Bash ls -la # Output will look like: # -rw-rw-r-- 1 ravi ravi 38 Jan 15 10:00 marks.txt # -rw-rw-r-- 1 ravi ravi 40 Jan 15 10:00 secret.txt # -rw-rw-r-- 1 ravi ravi 48 Jan 15 10:00 notice.txt
Understanding the output:
| Symbol | Meaning |
|---|---|
-rw-rw-r-- | [type] [owner: rw-] [group: rw-] [others: r--] |
r | Read (value: 4) |
w | Write (value: 2) |
x | Execute (value: 1) |
- | Permission not granted (value: 0) |
Step 4: Change Permissions with chmod
Bash # Make secret.txt readable ONLY by owner (no group, no others) chmod 600 secret.txt ls -l secret.txt # -rw------- 1 ravi ravi 40 Jan 15 10:00 secret.txt # ↑ Only owner can read/write. Nobody else can even see contents. # Make notice.txt readable by everyone, writable only by owner chmod 644 notice.txt ls -l notice.txt # -rw-r--r-- 1 ravi ravi 48 Jan 15 10:00 notice.txt # Make marks.txt readable/writable by owner and group, no access for others chmod 660 marks.txt ls -l marks.txt # -rw-rw---- 1 ravi ravi 38 Jan 15 10:00 marks.txt # Symbolic mode: remove ALL permissions for others on all files chmod o-rwx *.txt
Step 5: Change Ownership with chown
Bash # Change owner of marks.txt to root (requires sudo) sudo chown root:root marks.txt ls -l marks.txt # -rw-rw---- 1 root root 38 Jan 15 10:00 marks.txt # Now even ravi can't read this file! (ravi is not root and not in root group) # Try to read it as normal user cat marks.txt # Permission denied! ← Access control in action
Step 6: Understanding setuid (Dangerous but Important)
Bash # The passwd command lets normal users change their password # But passwords are stored in /etc/shadow (owned by root!) # How? The setuid bit! ls -l /usr/bin/passwd # -rwsr-xr-x 1 root root 63960 Jan 15 /usr/bin/passwd # ↑ 's' in owner execute = setuid bit # When ANY user runs passwd, it executes with ROOT privileges # This is "domain switching" — the process temporarily enters root's domain # Find all setuid programs on your system find / -perm -4000 -type f 2>/dev/null # Lists all programs that run with elevated privileges # Security tip: Minimize setuid programs — each is a potential attack vector
Step 7: Inspect /etc/shadow
Bash # Try to read as normal user cat /etc/shadow # Permission denied! ← Correct — only root can read password hashes # Read as root sudo cat /etc/shadow | head -5 # root:$6$xyz...:19500:0:99999:7::: # ravi:$6$abc...:19501:0:99999:7::: # ↑ $6$ = SHA-512 hash. The long string after second $ is the salt+hash. # Check permissions on both password files ls -l /etc/passwd /etc/shadow # -rw-r--r-- 1 root root 2345 /etc/passwd ← readable by all # -rw-r----- 1 root shadow 1580 /etc/shadow ← readable only by root
🎉 Lab Complete! You've demonstrated access control, the principle of least privilege, domain switching (setuid), and secure password storage — all core OS protection mechanisms.
🟡 Tier 2 — SEMI-GUIDED TASK: Password Hash Demo in Python
Your Mission:
Build a Python script that demonstrates password hashing with hashlib and bcrypt. Implement user registration (store salted hashes) and login verification.
Hints:
- Setup: Install bcrypt:
pip install bcrypt - hashlib approach: Use
hashlib.sha256()withos.urandom(16)for salt. Storesalt:hashpairs in a dictionary. - bcrypt approach: Use
bcrypt.hashpw(password.encode(), bcrypt.gensalt()). bcrypt handles salting automatically. - Build these functions:
register_user(username, password)→ hash the password, store in dictlogin_user(username, password)→ hash the entered password, compare with stored hashshow_database()→ print the stored usernames and their hashes (NOT passwords)
- Test: Register 3 users. Log in with correct and incorrect passwords. Observe that the same password for different users produces different hashes (because of salts).
- Compare: Time how long it takes to hash 1000 passwords with SHA-256 vs bcrypt. bcrypt should be significantly slower — that's its strength against brute force.
🔴 Tier 3 — OPEN CHALLENGE: Linux Security Hardening Checklist
The Brief:
You've been hired as a junior security consultant by a small Indian e-commerce startup running Ubuntu Server 22.04. Their server handles customer orders, payment data, and inventory. Create a comprehensive Linux Security Hardening Checklist that their sysadmin can follow.
Your checklist should cover:
- User Account Security: Password policies, disabling root SSH login, sudo configuration
- File Permissions: Securing sensitive files (/etc/shadow, /etc/ssh/sshd_config), removing unnecessary setuid programs
- Network Security: Firewall rules (UFW/iptables), closing unnecessary ports, SSH key-based auth
- Software Updates: Automatic security updates, removing unused packages
- Monitoring: Log monitoring (/var/log/auth.log), intrusion detection (fail2ban), file integrity monitoring
- Backup: Automated encrypted backups, offsite storage
- Compliance: Mapping to CERT-In guidelines and DPDP Act 2023 requirements
Deliverable: A professional 5–8 page PDF document with the checklist, commands, and explanations. Include a priority matrix (Critical / High / Medium / Low).
Industry Spotlight — A Day in the Life
👩💻 Deepa Nair, 29 — Security Engineer at Samsung R&D, Bangalore
Background: B.Tech (CSE) from NIT Calicut. Interned at a Bangalore startup doing basic pen-testing. Self-taught Linux security and got CEH (Certified Ethical Hacker) certification in final year. Joined Samsung R&D as Associate Security Engineer through campus placement.
A Typical Day:
9:00 AM — Morning standup with the platform security team. Review overnight vulnerability scan results from Nessus and Qualys.
10:00 AM — Analyze a new CVE (Common Vulnerabilities and Exposures) reported in the Linux kernel. Assess if Samsung's Tizen OS or Galaxy devices are affected. Write an impact assessment report.
11:30 AM — Code review: Check a colleague's kernel module patch for potential buffer overflow or race condition vulnerabilities. Use static analysis tools (Coverity).
1:00 PM — Lunch at Samsung's Bangalore campus cafeteria. Discuss the latest OWASP Top 10 updates with teammates.
2:00 PM — Implement SELinux policy updates for a new Samsung Knox feature. Test access control rules to ensure apps can't access unauthorized data partitions.
4:00 PM — Pen-testing session: Attempt privilege escalation on a staging server to test recently deployed patches. Document findings in Jira.
5:30 PM — Learning hour: Study for OSCP (Offensive Security Certified Professional) certification. Practice on HackTheBox machines.
| Detail | Info |
|---|---|
| Tools Used Daily | Nessus, Burp Suite, Wireshark, Nmap, GDB, Ghidra, SELinux, Git, Jira |
| Entry Salary (2024) | ₹6–10 LPA + benefits |
| Mid-Level (3–5 yrs) | ₹12–22 LPA |
| Senior (7+ yrs) | ₹25–50 LPA |
| Companies Hiring | Samsung R&D, Google, Microsoft, Amazon, Flipkart, Paytm, TCS (Cyber Security), Wipro, Quick Heal, Palo Alto Networks, CrowdStrike India |
Earn With It — Freelance & Income Roadmap
💰 Your Earning Path After This Chapter
Portfolio Piece: "Linux Security Hardening Audit Report" — a professional checklist document with vulnerability assessment, remediation steps, and compliance mapping.
Beginner Gig Ideas:
• Linux server security audit for small businesses — ₹5,000–₹15,000/project
• WordPress/website security hardening (SSL, permissions, firewall) — ₹3,000–₹10,000
• Password policy review and implementation for startups — ₹2,000–₹8,000
• Security awareness training session for small teams — ₹5,000–₹20,000/session
| Platform | Best For | Typical Rate |
|---|---|---|
| Internshala | Indian student internships & security projects | ₹5,000–₹15,000/project |
| Fiverr | Global clients, server hardening gigs | $20–$100/gig (₹1,600–₹8,000) |
| Upwork | Longer security audit projects | $25–$60/hour |
| BugCrowd / HackerOne | Bug bounty programs — find vulnerabilities, get paid | ₹5,000–₹5,00,000/bug |
| Direct outreach to Indian startups needing security | ₹5,000–₹20,000/project |
⏱️ Time to First Earning: 3–4 weeks (if you complete all 3 labs and create an Upwork/BugCrowd profile)
MCQ Assessment Bank — 30 Questions (Bloom's Mapped)
Remember / Identify (Q1–Q5)
A buffer overflow occurs when:
- A program runs out of RAM
- A program writes more data to a buffer than it can hold, overwriting adjacent memory
- A buffer is too large for the hard disk
- The CPU cache is full
In Linux, password hashes are stored in:
/etc/passwd/etc/shadow/etc/security/var/log/auth.log
/etc/shadow stores encrypted password hashes with root-only read access. /etc/passwd stores user info but not hashes (marked with 'x').Which malware type encrypts files and demands payment for decryption?
- Virus
- Worm
- Spyware
- Ransomware
The Access Matrix model has rows representing ______ and columns representing ______.
- Files; Users
- Subjects (users/processes); Objects (files/resources)
- Passwords; Permissions
- Ports; Protocols
The chmod 700 file.txt command gives:
- Read-only access to everyone
- Full access to owner; no access to group and others
- Full access to everyone
- Write access to group only
Understand / Explain (Q6–Q10)
Why does Linux store password hashes in /etc/shadow instead of /etc/passwd?
- Because
/etc/passwdis too small - Because
/etc/passwdis readable by all users, exposing hashes to offline cracking attacks - Because
/etc/shadowis faster to read - Because passwords are not needed in modern systems
/etc/passwd has 644 permissions (world-readable) because many programs need user info. Storing hashes there lets any user copy them for offline brute-force attacks. /etc/shadow restricts access to root only.What is the purpose of "salting" in password hashing?
- To make the password longer
- To add a random value so identical passwords produce different hashes, defeating rainbow table attacks
- To encrypt the password for network transmission
- To compress the hash for faster storage
How does an Access Control List (ACL) differ from a Capability List?
- ACL is stored with each object; Capability List is stored with each subject
- ACL is faster; Capability List is slower
- ACL uses encryption; Capability List uses hashing
- There is no difference
Why is the Principle of Least Privilege important in OS security?
- It makes systems faster
- It reduces the potential damage if a component is compromised
- It eliminates the need for passwords
- It prevents hardware failures
What does the setuid bit on a Linux executable do?
- Deletes the file after execution
- Runs the program with the file owner's privileges, regardless of who executes it
- Encrypts the file contents
- Prevents the file from being modified
/usr/bin/passwd runs as root so users can update /etc/shadow.Apply / Demonstrate (Q11–Q15)
You want a file to be readable and writable by the owner, readable by the group, and not accessible by others. What chmod command would you use?
chmod 640 file.txtchmod 777 file.txtchmod 600 file.txtchmod 755 file.txt
In the C code char buf[8]; gets(buf);, what happens if the user enters "AAAAAAAAAAAAAAAA" (16 A's)?
- The program truncates input to 8 characters
- Buffer overflow: excess data overwrites adjacent stack memory
- The program rejects the input gracefully
- The buffer automatically resizes to 16 bytes
gets() does not check buffer boundaries. Writing 16 bytes into an 8-byte buffer overflows onto the stack, overwriting saved frame pointer and return address.To hash a password using SHA-256 in Python, which code is correct?
hashlib.sha256("password")hashlib.sha256("password".encode()).hexdigest()hashlib.encrypt("password", "sha256")sha256.hash("password")
.encode()) and .hexdigest() returns the hash as a hexadecimal string.A web server process should ideally run with which level of file access?
- Root access to all files
- Read-only access to web content directory (/var/www/html) only
- Write access to all system logs
- Full access to /etc/shadow
An attacker enters ' OR '1'='1' -- in a login form. This is an example of:
- Buffer overflow
- DDoS attack
- SQL injection
- DNS spoofing
Analyze / Compare (Q16–Q20)
In the AIIMS Delhi ransomware attack, the root cause was a buffer overflow in an unpatched server. Which OS-level defence could have most directly prevented the initial exploitation?
- A stronger Wi-Fi password
- ASLR (Address Space Layout Randomization) and regular security patching
- A bigger hard disk
- Faster internet connection
Compare a virus and a worm. Which statement is correct?
- Both need a host program to spread
- A virus needs a host program; a worm is standalone and spreads via networks
- A worm needs a host; a virus spreads independently
- Neither can replicate themselves
A hospital's patient database uses an access matrix. The receptionist should be able to read patient names and appointment times but NOT medical records. The doctor should have full read/write access. Which matrix configuration is correct?
- Receptionist: {PatientInfo: Read, MedicalRecords: Read} / Doctor: {PatientInfo: Read, MedicalRecords: Read}
- Receptionist: {PatientInfo: Read} / Doctor: {PatientInfo: Read+Write, MedicalRecords: Read+Write}
- Both have identical full access
- Neither has any access
Why is bcrypt preferred over SHA-256 for password hashing?
- bcrypt produces shorter hashes
- bcrypt is intentionally slow (adjustable work factor), making brute-force attacks impractical
- bcrypt doesn't require a salt
- SHA-256 is no longer available in modern systems
In a DDoS attack vs a single DoS attack, the key difference is:
- DDoS is less dangerous than DoS
- DDoS uses multiple compromised machines (botnet) to attack simultaneously, making it harder to filter
- DoS uses multiple machines; DDoS uses one
- They are identical in technique
Evaluate / Judge (Q21–Q25)
A startup stores user passwords as MD5 hashes without salting. Their security consultant says this is "adequately secure." Is this assessment correct?
- Yes, MD5 is a standard hashing algorithm
- No — MD5 is fast to compute (brute-forceable) and unsalted hashes are vulnerable to rainbow table attacks
- Yes, as long as the database is encrypted
- No, but only because MD5 hashes are too long
India's CERT-In mandates that organisations report cybersecurity incidents within 6 hours. Evaluate whether this is practical for small businesses.
- Fully practical — 6 hours is very generous
- Impractical for small businesses lacking dedicated security teams, but necessary for national security visibility
- Too slow — reporting should be instant
- Unnecessary — small businesses are never attacked
A company implements ACLs for all files but doesn't use any network security (no firewall, open SSH). How would you evaluate their security posture?
- Excellent — ACLs are sufficient
- Incomplete — file-level access control without network security leaves the system vulnerable to remote attacks
- Over-engineered — they don't need both
- ACLs automatically protect against network threats
The DPDP Act 2023 imposes penalties up to ₹250 crore for data protection failures. Is this proportionate?
- Too harsh — it will bankrupt companies
- Proportionate for large companies but may be disproportionate for SMEs; graduated penalties would be better
- Too lenient — penalties should be higher
- Penalties are irrelevant to data protection
A system administrator runs all services (web server, database, email) as root for "convenience." Evaluate this practice.
- Efficient — avoids permission issues
- Extremely dangerous — violates least privilege; a compromise of any service gives root access to everything
- Acceptable for small servers
- Recommended by Linux best practices
Create / Design (Q26–Q30)
You're designing the access matrix for a university portal. Which access rights should a "Student" role have?
- Read+Write to all student records, faculty records, and admin settings
- Read own grades and attendance; no access to other students' data or admin settings
- Full admin access for self-service
- No access to any data
Design a secure password policy for an Indian e-commerce startup. Which combination is most appropriate?
- Minimum 4 characters, no special requirements
- Minimum 12 characters, requiring uppercase + lowercase + number + special character, bcrypt hashing with salt, account lockout after 5 failed attempts
- Minimum 8 characters, MD5 hashing, no lockout
- No password required — use OTP only
You need to secure a Linux web server. Which combination of measures provides defence-in-depth?
- Just a strong root password
- Disable root SSH login + SSH key auth + UFW firewall (allow only 80, 443, 22) + fail2ban + automatic security updates + web server running as www-data user
- Only enable HTTPS
- Just install antivirus software
Design an incident response plan for a small hospital (like AIIMS) experiencing a ransomware attack. What should be the FIRST step?
- Pay the ransom immediately
- Isolate affected systems from the network to prevent lateral spread
- Reformat all computers
- Send an email to all staff about the attack
Create a permission scheme for a shared Linux server with three user types: Admin, Developer, and Intern. The /var/www/html web directory should be:
- 777 for everyone (full access)
- Admin: rwx, Developer: rwx (via group), Intern: r-x (read+execute, no write)
- 000 (no access for anyone)
- Same permissions for all three roles
Short Answer Questions (5 Questions)
Q1: Explain the difference between Protection and Security in an OS. Why are both necessary?
Model Answer:
Protection is an internal mechanism that controls how users and processes access system resources (files, memory, devices). It ensures that one user's process cannot interfere with another's data. Example: Linux file permissions (chmod 600) prevent other users from reading your private files.
Security is the defence against external and internal threats — hackers, malware, unauthorized access. It includes authentication (passwords, biometrics), encryption (SSL/TLS), and intrusion detection (firewalls, fail2ban).
Why both? Protection without security is like having locks on apartment doors but no boundary wall — internal residents are safe from each other, but anyone from outside can walk in. Security without protection is like a strong boundary wall but no locks on doors — outsiders can't enter, but insiders can access each other's flats. A secure OS needs both layers.
Q2: Describe how a buffer overflow attack works. Include the role of the stack and return address.
Model Answer:
A buffer overflow occurs when a program writes data beyond the allocated boundary of a buffer (e.g., an array). In C, functions like gets() don't check input length.
How it works on the stack:
1. When a function is called, the stack stores: local variables (buffer), saved frame pointer, and the return address (where execution should go after the function ends).
2. If the buffer is 16 bytes but the input is 200 bytes, the excess overwrites the saved frame pointer and return address.
3. The attacker crafts the input so the overwritten return address points to malicious shellcode (also placed in the overflow data).
4. When the function returns, it jumps to the attacker's code instead of the caller, giving them control — potentially root access.
Defences: ASLR, stack canaries, DEP/NX bit, using safe functions (fgets instead of gets).
Q3: What is the Access Matrix? Explain with an example and describe two ways it is implemented in practice.
Model Answer:
The Access Matrix is a protection model that defines which subjects (users/processes) can perform which operations on which objects (files/resources). It's a 2D table where rows = subjects, columns = objects, and cells = access rights (read, write, execute, delete).
Example: In a university system — Student can Read grades.txt; Faculty can Read+Write grades.txt; Admin can Read+Write+Delete grades.txt.
Implementations:
1. Access Control List (ACL): Each object stores a list of (subject, rights) pairs. Column-wise decomposition. Example: Linux file permissions. Easy to check "who can access this file" but hard to find "all files a user can access."
2. Capability List: Each subject stores a list of (object, rights) pairs. Row-wise decomposition. Example: Android app permissions. Easy to check "what can this user access" but hard to revoke access to a specific object across all users.
Q4: Explain the Principle of Least Privilege with two real-world examples.
Model Answer:
The Principle of Least Privilege states that every user, process, and program should operate with the minimum set of permissions necessary to complete its task — nothing more.
Example 1 — Web Server: An Apache web server process should only have read access to /var/www/html (to serve web pages) and should NOT run as root. If the web server is compromised, the attacker can only read web files, not the entire filesystem or /etc/shadow.
Example 2 — Mobile Apps: A calculator app on your Android phone should NOT request access to contacts, camera, or location. If it does, it's likely violating least privilege and may be spyware. Android 13+ enforces granular permission controls.
In the AIIMS attack: If the compromised server had been restricted to only patient scheduling data (not the entire database), the 40 million patient records wouldn't have been at risk.
Q5: Compare viruses, worms, and trojans. How does each spread and what makes each dangerous?
Model Answer:
| Feature | Virus | Worm | Trojan |
|---|---|---|---|
| Self-Replicates? | Yes | Yes | No |
| Needs Host? | Yes (attaches to files) | No (standalone) | No (disguised as legit app) |
| Spread Method | Infected files shared via USB, email, downloads | Network — auto-spreads via vulnerabilities | User downloads/installs fake app |
| Primary Danger | Corrupts/destroys files | Consumes bandwidth, crashes networks | Creates backdoors, steals data |
| Example | CIH/Chernobyl virus | WannaCry, Slammer | Fake Aarogya Setu APK |
Key Insight: A virus is like a disease that infects healthy files. A worm is like a contagious plague that spreads through the network on its own. A trojan is like a spy disguised as a friend — it doesn't spread, but it opens the door for attackers.
Case Studies
📋 Case Study 1: AIIMS Delhi Ransomware Attack (November 2022)
Background:
AIIMS Delhi, India's premier medical institution, suffered a devastating ransomware attack on 23rd November 2022. The attack encrypted data across 5 servers hosting approximately 1.3 TB of data. Hospital operations — including OPD, emergency, lab reports, and billing — were disrupted for nearly 15 days. An estimated 30–40 million patient records were at risk, including those of former Prime Ministers, Supreme Court judges, and senior bureaucrats.
Technical Analysis:
- Entry Point: A buffer overflow vulnerability in an unpatched server allowed initial code execution.
- Lateral Movement: After gaining access, attackers escalated privileges and moved laterally through the network, which lacked proper segmentation.
- Encryption: Ransomware encrypted critical databases. The attackers demanded ₹200 crore in cryptocurrency.
- Recovery: CERT-In, NIA, and Delhi Police IFSO were involved. Data was eventually recovered from backups (though some were outdated).
Security Failures Identified:
- Unpatched servers (known vulnerability exploited)
- Lack of network segmentation — one compromised server gave access to the entire network
- Services running with excessive privileges (violation of least privilege)
- Outdated backup strategy — no recent offline backups
- No intrusion detection system (IDS) to flag suspicious activity
Discussion Questions:
Q1: Map each security failure to a specific protection mechanism discussed in this chapter. Which mechanism would have prevented each failure?
Q2: The ransom demand was ₹200 crore. Should AIIMS have paid? Discuss the ethical and practical considerations.
Q3: Design a post-incident security architecture for AIIMS using the principle of least privilege, network segmentation, and mandatory access control.
📋 Case Study 2: Aadhaar Data Breach Controversy
Background:
In January 2018, The Tribune newspaper reported that Aadhaar data (name, address, phone number, email, and even bank details linked to Aadhaar) of over 1 billion Indians was being sold on WhatsApp for as little as ₹500. The seller provided an unauthorized login to the UIDAI system that allowed searches by Aadhaar number. A few months later, a French security researcher demonstrated that an unprotected API endpoint could be used to access Aadhaar details.
Technical Analysis:
- Access Control Failure: API endpoints were not properly authenticated. Some endpoints allowed unauthenticated queries.
- Excessive Access Rights: Authorized users (ration shop operators, telecom agents) had broader access than needed — violating the principle of least privilege.
- Lack of Audit Trails: Unauthorized access was not detected for months, indicating insufficient logging and monitoring.
- Scale: With 1.4 billion Aadhaar numbers, even a small vulnerability affects hundreds of millions.
UIDAI's Response:
- Denied large-scale breach; claimed data was encrypted with 2048-bit encryption
- Filed FIR against The Tribune journalist (controversial — criticised as shooting the messenger)
- Implemented Virtual ID system — users can generate a temporary virtual Aadhaar number for verification instead of sharing actual Aadhaar number
- Enhanced API security with token-based authentication and rate limiting
Discussion Questions:
Q1: How could a proper Access Matrix implementation have prevented unauthorized data access by ration shop operators?
Q2: Evaluate the DPDP Act 2023's effectiveness in preventing future Aadhaar-like breaches. What additional measures would you recommend?
Q3: UIDAI filed an FIR against the journalist who exposed the breach. Discuss: Is this approach beneficial or harmful to cybersecurity?
Chapter Summary
🔑 Key Takeaways — Unit 6: Protection & Security
1. Protection vs Security: Protection controls internal access to resources (file permissions, access matrices). Security defends against external/internal threats (authentication, encryption, malware defence). Both are essential.
2. Buffer Overflow: The #1 OS vulnerability. Writing beyond buffer boundaries can overwrite return addresses, letting attackers hijack execution. Defences: ASLR, stack canaries, DEP, safe coding practices.
3. Authentication: Linux uses /etc/passwd + /etc/shadow for secure password storage. Passwords should be hashed (bcrypt/Argon2) with salts. SSL/TLS secures network communication.
4. Malware Types: Virus (host-dependent), Worm (self-spreading via network), Trojan (disguised), Ransomware (encrypts for ransom), Spyware (monitors silently). Each requires different defence strategies.
5. Access Matrix: Rows = subjects, Columns = objects, Cells = rights. Implemented as ACLs (object-centric, used in Linux/Windows) or Capability Lists (subject-centric, used in Android).
6. Principle of Least Privilege: Every component should have minimum necessary access. Limits damage when breaches occur.
7. Network Threats: DoS/DDoS (flooding), MITM (interception), SQL injection (database manipulation), Port scanning (reconnaissance).
8. Indian Legal Framework: IT Act 2000 (cyber offences), CERT-In (6-hour incident reporting), DPDP Act 2023 (data protection, ₹250 crore penalties).
Earning Checkpoint — What You Can Do Now
| Skill Learned | Tool/Platform | Portfolio Deliverable | Earning Ready? |
|---|---|---|---|
| Linux File Permissions | Ubuntu, chmod, chown | Permissions Lab Screenshot + Report | ✅ Yes — sysadmin entry skill |
| Password Hashing | Python hashlib, bcrypt | Password Security Demo Script | ✅ Yes — backend security skill |
| Security Concepts | Conceptual | — | ✅ Yes — interview ready |
| Security Hardening | Linux CLI, UFW, fail2ban | Linux Hardening Checklist PDF | ✅ Yes — ₹5K–₹20K/project |
| Access Control Design | Conceptual + Linux ACLs | Access Matrix Design Document | ✅ Yes — can pitch to startups |
| Indian Cyber Law | IT Act, DPDP Act | — | ✅ Yes — compliance consulting |
✅ Unit 6 complete. MCQs: 30. Ready for Unit 7: Memory Management!
[QR: Link to EduArtha video tutorial — OS Protection & Security]