🖥️ Chapter 10 — Operating System Security Cheat Sheet
🗺️ Big Picture
OS Security
│
├── Why OS? → First line of defense; primary attack target
├── Core Concepts → Separation, Protection Levels, Protected Objects
├── Memory Protection → Fence / Base-Bounds / Tagged / Segmentation / Paging
├── Memory Corruption Defense → ASLR, Stack Canary, Buffer Overflow
├── OS Hardening → Install → Remove → Configure → Add Controls → Test
├── Linux/Windows Security → Patches, Permissions, Logging, UAC, BitLocker
├── Defense in Depth → Multiple layers from hardware to data
├── Virtualization Security → Hypervisor, VM Hardening, vSwitch, VMI
└── Hardware Security → TPM + Trusted Boot + TEE (Intel SGX, ARM TrustZone)
1. Why OS Security Matters
- OS is the fundamental controller of all system resources → makes it the primary attack target
- OS is the first line of defense against unwanted behavior:
- Protects one user from another
- Protects critical memory/storage from unauthorized processes
- Performs identification & authentication
- Ensures fair sharing of hardware resources
🏢 Analogy: The OS is the building's security guard — controls who gets in, who goes where, and stops intruders from damaging things.
OS Must Protect
- Users from each other
- Resources (memory, CPU, I/O, files, networks)
- Itself — including from harm modules, drivers, and add-ons
OS Security Functions
| Function | Description |
|---|---|
| Access Control | Controls who can access what |
| Identity & Credential Management | Authenticate users and processes |
| Information Flow | Control how data moves between processes/users |
| Audit & Integrity Protection | Logging + memory protection |
2. OS History → Why Protection Is Needed
| Era | Situation | Protection needed? |
|---|---|---|
| Single user | One user at a time | ❌ No |
| Multiprogramming | Multiple programs in memory simultaneously | ✅ Yes — programs interfere |
| Multitasking / Multi-user | Multiple users + processes concurrently | ✅ Yes — users interfere |
Modern OS must: protect one user from another + share resources (CPU, memory, files) safely.
3. OS Layered Structure
┌────────────────────────────────────┐ ← Subprocesses of User Processes
├────────────────────────────────────┤ ← User Processes
├────────────────────────────────────┤ ← Compilers, Database Managers
├────────────────────────────────────┤ ← Utility Functions
├────────────────────────────────────┤ ← File Systems, Device Allocation
├────────────────────────────────────┤ ← Scheduling, Sharing, Memory Mgmt
├────────────────────────────────────┤ ← Synchronization, Allocation
├────────────────────────────────────┤ ← Security Functions
└────────────────────────────────────┘ ← Hardware (rootkits, bootkits live here!)
⚠️ Each layer is vulnerable to attacks from below. If the hardware layer (foundation) is compromised, nothing above it is safe.
4. Types of Separation
| Type | How | Example |
|---|---|---|
| Physical | Different processes → different physical hardware | Separate machines |
| Temporal | Different security processes run at different times | Batch jobs at off-hours |
| Logical | OS makes each process feel like it's alone | VMs, containers |
| Cryptographic | Encrypt data/processes to conceal from others | Full Disk Encryption, FileVault |
Each type has different security strength, implementation complexity, and resource utilization.
5. Levels of Protection (0 → 5)
| Level | Name | Description |
|---|---|---|
| 0 | No protection | User protects themselves via temporal separation |
| 1 | Isolation | Processes run concurrently but are hidden from each other; each has own space |
| 2 | Full or no sharing | Owner declares resource as shared or private |
| 3 | Access Control | Access rights (policy) determine per-user, per-object access |
| 4 | Sharing by capabilities | Dynamic access rights; depends on user + context + object (like ABAC) |
| 5 | Limit use of object | Can view but can't copy; can see summary but not individual records |
Level 5 example: Can see department average salary — cannot see John Smith's individual salary.
6. Memory and Address Protection Mechanisms
6.1 Fence Protection
- Hardware divides memory at address
n:0 → n= OS spacen+1 → High= User program space
- The fence = a hard boundary
6.2 Fence Registers
- A register holds the fence address (flexible — different OS versions can have different fence values)
- Allows flexible relocation of the OS/user boundary
6.3 Base and Bounds Registers ⭐
- Base Register = starting address of user's program space
- Bounds Register = ending address of user's program space
- Multiple users (A, B, C) each have their own base/bounds
🌾 Analogy: Like fencing off plots of land — each user owns their plot (base to bounds), nobody can step onto another's.
- Can also have separate base/bounds for program and data — code and data can be non-contiguous.
6.4 Tagged Architecture
- Every memory word has extra bits specifying access rights:
R(Read-only),RW(Read/Write),X(Execute-only) - Bits are set only by privileged (OS) instructions
- Tested every time an instruction accesses that memory location
6.5 Virtual Memory — Segmentation
- Program divided into logical segments (MAIN, DATA_SEG, SUB…)
- A Segment Translation Table maps segment names → physical addresses
- Benefits:
- Each address reference is checked (not too high or too low)
- Different data classes can have different protection levels
- Two users can share a segment with different access rights
- A user cannot generate an address for an unpermitted segment
6.6 Virtual Memory — Paging
- Program divided into fixed-size pages; memory into equal page frames
- A Page Translation Table maps logical page number → physical frame address
- Page size = power of 2: 2KB, 8KB, 16KB
- Gives efficient memory management (but improperly configured → page fault)
6.7 Combined Paging + Segmentation
- Each segment has its own Page Translation Table
- Address: Segment → Page Table → Physical Address
- Combines: logical structure (segmentation) + efficient memory use (paging)
- Security-wise: better — but performance tradeoff for small programs
🔐 Memory protection implements both separation AND sharing.
7. Memory Corruption Protection
Memory Corruption = interfered with / tampered / no longer genuine
7.1 Address Space Layout Randomization (ASLR)
- Mitigates exploits that rely on hardcoded stack, heap, code, libc addresses
How ASLR defeats Buffer Overflow:
- Without ASLR: attacker knows exactly where shellcode lands → overwrites return address → jumps there
- With ASLR: stack address changes every run → wrong guess = program crash
How ASLR defeats Return-to-libc:
- Attacker reuses existing functions like
system("/bin/sh")instead of injecting code - With ASLR: libc location randomized → attacker must first leak the base address (much harder)
7.2 Stack and Buffer Overflow
Normal stack layout:
| Return Address | ← Points to next instruction
| Saved Frame Pointer |
| Local Variables |
| [ char buffer[16] ] |
Stack after overflow (attacker payload):
| Overwritten Return Addr | ← Attacker redirects execution here!
| Corrupted Frame Ptr |
| buffer[16] + Exploit | ← Overflowed data writes into upper memory
Unsafe code:
void vulnerable() {
char buffer[16];
gets(buffer); // ⚠️ No bounds checking!
}Safe code:
void safe() {
char buffer[16];
fgets(buffer, sizeof(buffer), stdin); // ✅ Limits to 15 chars + null terminator
}💡 C = "You manage memory manually" 💀 — Swift = "System manages memory for you" 🍎
7.3 Stack Canary
A random value placed on the stack just before the return address.
| Local Variables |
| Canary Value (random) | ← Inserted by compiler
| Saved Return Address |
How it works:
- Function called → canary inserted on the stack
- Before function returns → system checks if canary was modified
- If canary is altered (by buffer overflow) → program aborts immediately before using the corrupted return address
🐤 Like a tamper seal — if the attacker overwrites the buffer to reach the return address, they inevitably overwrite the canary first → program detects tampering and stops.
8. OS Hardening
OS Hardening = configure securely + update + enforce policy + remove unnecessary components → minimize attack surface.
5 Basic Steps
① Install & patch the OS
② Harden & configure (remove unnecessary services/apps/protocols; configure users/groups/permissions)
③ Install additional security controls (AV, host firewall, IDS/IPS, application whitelisting)
④ Test system security (checklists, vulnerability scanners)
⑤ Repeat periodically
Step-by-Step Details
Step 1 — Remove Unnecessary Services, Apps, Protocols
- System planning identifies what's actually required
- Do NOT use supplied defaults — default config maximizes ease-of-use, not security
- Install additional packages later when needed
Step 2 — Configure Users, Groups, Authentication
- Elevated privileges → only those who need it, only when needed
- Default accounts not required → remove or disable
- Define categories of users, their privileges, accessible data, and authentication methods
Step 3 — Configure Resource Controls
- Set appropriate permissions on data and resources
- Follow security hardening guides for recommended changes
Step 4 — Install Additional Security Controls
- Anti-virus, Host-based firewall, IDS/IPS, Application whitelisting
Step 5 — Test System Security
- Ensure previous steps are correctly implemented
- Identify vulnerabilities
- Use checklists + vulnerability scanning tools
- Repeat after initial hardening and periodically
7 Steps for a Well-Maintained Computer
| Step | Action |
|---|---|
| 1 | Use a surge protector or UPS |
| 2 | Update the BIOS or UEFI |
| 3 | Update the OS |
| 4 | Update anti-virus and anti-malware |
| 5 | Update the firewall |
| 6 | Maintain the disks |
| 7 | Create an image of the system |
ASD Top 4 Prevention Strategies
- Whitelist approved applications
- Patch third-party applications and OS vulnerabilities
- Restrict administrative privileges
- Create a defense-in-depth system
9. Defense in Depth
Multiple layers of defense addressing technical, personnel, and operational issues.
Attack
↓
Hardware Broadband Router / Firewall
↓
OS / Software Firewall
↓
Antivirus / Antimalware
↓
Security Patches
↓
User Account Controls
↓
[Core Data]
Outer to inner: Policies/Procedures/Awareness → Physical → Perimeter → Internal Network → Host → Application → Data
🧅 Analogy: Like the layers of an onion — an attacker must break through each layer to reach the core data.
10. Linux/Unix Security
| Area | Key Points |
|---|---|
| Patch Management | Keep security patches up to date — critical control |
| App/Service Config | Config files in /etc; user overrides in dot files (.bashrc, .vimrc, .profile) |
| Users/Groups/Permissions | r/w/x for owner, group, others; change permissions on critical dirs/files |
| Remote Access | Host firewall programs; admin utility to select permitted services |
| Logging & Log Rotation | Don't assume defaults are appropriate; configure explicitly |
| chroot jail | Isolates application to a restricted directory subtree |
Local Exploit = vulnerability exploited by attacker with local access → gains elevated privileges Remote Exploit = vulnerability in a network server exploitable by a remote attacker
11. Windows Security
Key Windows Security Features
| Feature | Description |
|---|---|
| Windows Update / WSUS | Patch management — automatic update support |
| DAC | Discretionary Access Controls on resources |
| Mandatory Integrity Controls | Objects labeled Low/Medium/High/System integrity |
| UAC (User Account Control) | Admins run as standard user by default; elevate only when required |
| Registry | Centralized database of keys/values; editable via regedit |
| EFS | Encrypting File System — encrypts files and directories |
| BitLocker | Full-disk encryption with AES |
| Microsoft Baseline Security Analyzer | Free tool that checks compliance with Microsoft security recommendations |
Biba Integrity Model (Windows Mandatory Integrity Controls)
- Subjects are prevented from writing to objects at higher integrity levels
- Prevents low-integrity processes from corrupting high-integrity data
Windows Logon — Admin vs Standard User
| Account Type | Access Tokens | Explorer.exe runs as |
|---|---|---|
| Admin (Admin Approval Mode) | Full Admin Token + Standard User Token | Standard User (limited) |
| Standard User | Standard User Token only | Standard User (limited) |
12. OWASP Top 10 (2025) — Web Application Vulnerabilities
| # | Vulnerability |
|---|---|
| A01 | Broken Access Control |
| A02 | Security Misconfiguration |
| A03 | Software Supply Chain Failures |
| A04 | Cryptographic Failures |
| A05 | Injection |
| A06 | Insecure Design |
| A07 | Authentication Failures |
| A08 | Software or Data Integrity Failures |
| A09 | Security Logging and Alerting Failures |
| A10 | Mishandling of Exceptional Conditions |
13. Virtualization Security
Virtualization Types
| Type | Description |
|---|---|
| Application Virtualization | App written for one OS runs on another |
| Full Virtualization (Native/Bare-Metal) | Multiple full OS instances via Type 1 Hypervisor on hardware |
| Hosted Virtualization | VMs run via Type 2 Hypervisor on top of a host OS |
Native vs. Hosted Hypervisor
Native (Bare-Metal): Hosted:
Guest OS 1 | Guest OS 2 ... Apps | Guest OS 1 ...
Hypervisor (Type 1) Hypervisor (Type 2)
Physical Hardware Host OS Kernel
Physical Hardware
Type 1 = more secure (no host OS as attack surface beneath hypervisor)
Three Core Virtualization Security Issues
| Issue | Description |
|---|---|
| Guest OS isolation | Programs in guest OS may only access resources allocated to it |
| Hypervisor monitoring | Hypervisor has privileged access to all guest OS programs and data |
| Image and snapshot management | Attackers may attempt to view or modify VM images/snapshots |
Securing Virtualization — 4 Layers
1. Hypervisor Security
- Use Type 1 (Bare-metal) hypervisors (VMware ESXi, Hyper-V, Xen)
- Minimize attack surface: disable unused services/interfaces/device drivers
- Regular patch management
- Enable TPM + Secure Boot (hardware root-of-trust)
2. VM Hardening
- Start with hardened, minimal OS templates
- Isolate VMs (logical + network isolation)
- Install anti-malware, firewalls, HIDS within each VM
3. Network Security in Virtualization
- Virtual Firewalls between VMs or at vSwitch level
- Microsegmentation via SDN / VMware NSX (per-VM security policies)
- Secure vSwitches — prevent:
- Promiscuous mode
- MAC address spoofing
- Forged transmissions
4. Security Tools and Technologies
- Virtualization-aware AV: Trend Micro Deep Security, Symantec Endpoint Protection for VEs
- VM Introspection (VMI): Inspect VMs from hypervisor level without an agent (KVM + LibVMI, Bitdefender)
- SIEM: Integrate virtualization logs for correlation and alerting
14. TPM — Trusted Platform Module
A hardware security chip embedded in the motherboard (or virtualized as vTPM in cloud).
TPM Functions
| Function | Description |
|---|---|
| Secure key storage | Stores cryptographic keys safely |
| PRNG | Random number generation |
| Hashing + Signing | Secure cryptographic operations |
| Integrity measurements during boot | Stores PCR (Platform Configuration Register) values |
| Device identity attestation | Proves the device's identity |
TPM Chip
├── Secure Key Storage
├── PCR Registers (boot integrity measurements)
├── Cryptographic Unit
├── Random Number Generator
└── Trusted Boot
🍎 Apple equivalent = T2 Security Chip
15. Trusted Boot (Measured Boot)
Ensures each component loaded during startup is verified and measured against a known-good value.
How It Works
UEFI BIOS/Firmware starts
↓
Measures each component (takes SHA hash)
↓
Stores hashes in TPM's PCR registers
↓
If hash differs from known-good → tampered! (rootkit/malware detected)
↓
System refuses to boot / alerts / triggers remediation
🪪 Analogy: Like a tamper-evident seal on each stage of the boot chain — if anything was opened, you'll know.
16. TEE — Trusted Execution Environment
A secure area inside the processor where sensitive code and data are executed in isolation — protected even if OS, hypervisor, or apps are compromised.
CPU
├── Normal World (OS, Applications)
└── Secure World (TEE)
└── Isolated memory + execution (inaccessible from outside)
Protected Operations in TEE
- Cryptographic key operations
- Authentication, biometric verification
- Payment processing
- Secure AI inference
- Confidential computing
TEE Workflow — 6 Steps
Step 1: Enclave Deployment
Server loads program into enclave; gets eid (Enclave ID)
Step 2: Remote Attestation
- Enclave proves its identity via cryptographic quote
- = hash of enclave program (proves exact code loaded)
nonce= prevents replay attacks- Client verifies: returns
1if genuine → client trusts the enclave
🍽️ Analogy: Like a restaurant showing a health inspection certificate — client checks proof before sending sensitive data.
Step 3: Secure Channel (DH Key Exchange)
Enclave generates (sk_e, pk_e) → sends pk_e to client
Client generates (sk_c, pk_c) → sends pk_c to enclave
Enclave: K_sess = DH(sk_e, pk_c)
Client: K_sess = DH(sk_c, pk_e)
→ Both arrive at same shared session key ✅
Step 4: Key Provisioning — Two Cases
| Case | Method | Security |
|---|---|---|
| Case 1 | Client sends key encrypted with : | Key travels over wire (encrypted) |
| Case 2(stronger) | Enclave generates key internally: | Key never exists outside enclave in plaintext |
🏧 Case 2 = generating your ATM PIN inside the machine — even the bank doesn't know it.
Step 5: Client Sends Data
Enclave receives and decrypts internally.
Step 6: Encrypt Inside Enclave
\boxed{CT = \text{Enc_{AES}}(m,\ k)}
TEE Formal Algorithms
| Algorithm | Signature | Description |
|---|---|---|
| TEE.Init | Generates TEE signing key pair | |
| TEE.Install | Loads program into enclave; returns Enclave ID | |
| TEE.Resume | Runs function ; returns output + attestation | |
| TEE.VrfyQuote | Returns 1 iff attestation valid + program loaded | |
| TEE.Seal | Encrypts with hardware-derived key; only same enclave can unseal |
TEE.Seal = when you need to take a key out of the enclave → seal it first. To use it again → unseal it back inside.
Intel SGX — EPC (Enclave Page Cache)
| Type | Size |
|---|---|
| Physical EPC (older) | ~128 MB |
| Usable EPC | ~90–100 MB |
| Newer SGX | up to ~256 MB+ |
🅿️ Analogy: All apartments share a limited parking lot (EPC) — each tenant has their own locked unit, but parking is shared and limited.
17. TEE Technologies
| Technology | Used In |
|---|---|
| Intel SGX | Secure enclaves in Intel CPUs |
| ARM TrustZone | Smartphones, IoT devices |
| AMD SEV | Cloud VMs — encrypts entire VM memory |
| Apple Secure Enclave | Face ID, Touch ID, secure key storage |
If CPU does NOT support TEE features → No TEE available.
18. TPM vs. TEE Comparison
| Feature | TPM | TEE |
|---|---|---|
| Type | Hardware security chip (separate) | Secure CPU environment (inside CPU) |
| Purpose | Secure key storage + boot trust | Secure execution of sensitive code |
| Location | Separate hardware module on motherboard | Inside the processor |
| Typical Use | Secure boot, disk encryption (BitLocker) | Mobile payments, biometrics, confidential computing |
How TPM + TEE Work Together
① TPM verifies system integrity during boot (Trusted Boot)
② Secure Boot loads trusted OS
③ TEE runs sensitive operations securely
🏢 Analogy: TPM = security guard at building entrance (checks who enters at boot). TEE = locked executive office inside (where sensitive work actually happens).
When to Use Which?
| Use TEE when | Use TPM when |
|---|---|
| Keys used frequently during secure app execution | Keys tied to platform integrity or device identity |
| Mobile payment keys | Secure boot verification |
| Biometric authentication | Disk encryption keys (BitLocker) |
| DRM keys | Device identity / attestation keys |
| Confidential computing, IoT | Protection against bootkits, firmware attacks |
| Component | Best Role |
|---|---|
| TPM | Root keys, device identity, boot integrity keys |
| TEE | Application/session keys, runtime crypto operations |
⚡ Key Facts to Remember
| Fact | Detail |
|---|---|
| OS = primary attack target | Controls all system resources → most valuable to compromise |
| OS must protect | Users from each other + resources |
| Layered OS | Each layer vulnerable to attacks from below |
| ASLR | Randomizes memory addresses → defeats hardcoded-address exploits |
| Without ASLR | Attacker knows return address → can jump to shellcode |
gets() | Dangerous — no bounds checking → use fgets() |
| Stack canary | Random value before return address; if modified → program aborts |
| Buffer overflow | Overwrite return address → redirect execution to attacker's code |
| Return-to-libc | Reuses existing library code (no injection) → bypassed by ASLR |
| OS hardening rule | FEWER IS BETTER — remove all unnecessary services/apps |
| Default config | Maximizes ease-of-use, NOT security — never use defaults |
| Defense in depth | Multiple layers from hardware to data — attack must breach all |
| Type 1 Hypervisor | Bare-metal — more secure than Type 2 (hosted) |
| vSwitch security | Prevent: promiscuous mode, MAC spoofing, forged transmissions |
| VMI | VM introspection from hypervisor level — no agent needed |
| TPM | Hardware chip: key storage, boot integrity, device attestation |
| Trusted Boot | Hashes each boot component → stores in PCR → detects tampering |
| TEE | Isolated CPU area — even compromised OS can't access it |
| TEE.Seal | Key exported out of enclave must be sealed; unsealed to use |
| Remote Attestation | Cryptographic proof that enclave code is genuine + untampered |
| Case 2 key provision | Key generated inside enclave → never leaves in plaintext → stronger |
| Intel SGX EPC | ~128 MB — not suitable for large data, heavy ML models |
| Biba Model (Windows) | Subject integrity ≥ object integrity to write (prevents low-trust process corrupting high-trust data) |
| BitLocker | Full-disk encryption with AES |
| UAC | Admin runs as standard user by default; elevates only when required |
| chroot jail | Restricts Linux app to a directory subtree — isolation technique |
| AMD SEV | Encrypts entire VM memory in cloud |
| ARM TrustZone | TEE for smartphones and IoT |
| Apple Secure Enclave | Face ID / Touch ID / key storage TEE |