10

Updated 4 Oct 2026

🖥️ 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

FunctionDescription
Access ControlControls who can access what
Identity & Credential ManagementAuthenticate users and processes
Information FlowControl how data moves between processes/users
Audit & Integrity ProtectionLogging + memory protection

2. OS History → Why Protection Is Needed

EraSituationProtection needed?
Single userOne user at a time❌ No
MultiprogrammingMultiple programs in memory simultaneously✅ Yes — programs interfere
Multitasking / Multi-userMultiple 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

TypeHowExample
PhysicalDifferent processes → different physical hardwareSeparate machines
TemporalDifferent security processes run at different timesBatch jobs at off-hours
LogicalOS makes each process feel like it's aloneVMs, containers
CryptographicEncrypt data/processes to conceal from othersFull Disk Encryption, FileVault

Each type has different security strength, implementation complexity, and resource utilization.


5. Levels of Protection (0 → 5)

LevelNameDescription
0No protectionUser protects themselves via temporal separation
1IsolationProcesses run concurrently but are hidden from each other; each has own space
2Full or no sharingOwner declares resource as shared or private
3Access ControlAccess rights (policy) determine per-user, per-object access
4Sharing by capabilitiesDynamic access rights; depends on user + context + object (like ABAC)
5Limit use of objectCan 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 space
    • n+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 ⭐

Valid address=Base≤address≤Bounds\boxed{\text{Valid address} = \text{Base} \leq \text{address} \leq \text{Bounds}}

  • 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)

ASLR: Base address of segment = random value on every execution\boxed{\text{ASLR: Base address of segment = random value on every execution}}

  • 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:

  1. Function called → canary inserted on the stack
  2. Before function returns → system checks if canary was modified
  3. 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

FEWER IS BETTER — reduce attack surface\boxed{\text{FEWER IS BETTER — reduce attack surface}}

  • 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

StepAction
1Use a surge protector or UPS
2Update the BIOS or UEFI
3Update the OS
4Update anti-virus and anti-malware
5Update the firewall
6Maintain the disks
7Create an image of the system

ASD Top 4 Prevention Strategies

  1. Whitelist approved applications
  2. Patch third-party applications and OS vulnerabilities
  3. Restrict administrative privileges
  4. 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

AreaKey Points
Patch ManagementKeep security patches up to date — critical control
App/Service ConfigConfig files in /etc; user overrides in dot files (.bashrc, .vimrc, .profile)
Users/Groups/Permissionsr/w/x for owner, group, others; change permissions on critical dirs/files
Remote AccessHost firewall programs; admin utility to select permitted services
Logging & Log RotationDon't assume defaults are appropriate; configure explicitly
chroot jailIsolates 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

FeatureDescription
Windows Update / WSUSPatch management — automatic update support
DACDiscretionary Access Controls on resources
Mandatory Integrity ControlsObjects labeled Low/Medium/High/System integrity
UAC (User Account Control)Admins run as standard user by default; elevate only when required
RegistryCentralized database of keys/values; editable via regedit
EFSEncrypting File System — encrypts files and directories
BitLockerFull-disk encryption with AES
Microsoft Baseline Security AnalyzerFree tool that checks compliance with Microsoft security recommendations

Biba Integrity Model (Windows Mandatory Integrity Controls)

Subject can write to object only if integritysubject≥integrityobject\boxed{\text{Subject can write to object only if } \text{integrity}_{subject} \geq \text{integrity}_{object}}

  • 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 TypeAccess TokensExplorer.exe runs as
Admin (Admin Approval Mode)Full Admin Token + Standard User TokenStandard User (limited)
Standard UserStandard User Token onlyStandard User (limited)

12. OWASP Top 10 (2025) — Web Application Vulnerabilities

#Vulnerability
A01Broken Access Control
A02Security Misconfiguration
A03Software Supply Chain Failures
A04Cryptographic Failures
A05Injection
A06Insecure Design
A07Authentication Failures
A08Software or Data Integrity Failures
A09Security Logging and Alerting Failures
A10Mishandling of Exceptional Conditions

13. Virtualization Security

Virtualization Types

TypeDescription
Application VirtualizationApp written for one OS runs on another
Full Virtualization (Native/Bare-Metal)Multiple full OS instances via Type 1 Hypervisor on hardware
Hosted VirtualizationVMs 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

IssueDescription
Guest OS isolationPrograms in guest OS may only access resources allocated to it
Hypervisor monitoringHypervisor has privileged access to all guest OS programs and data
Image and snapshot managementAttackers 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

FunctionDescription
Secure key storageStores cryptographic keys safely
PRNGRandom number generation
Hashing + SigningSecure cryptographic operations
Integrity measurements during bootStores PCR (Platform Configuration Register) values
Device identity attestationProves 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

eid←TEE.Install(pEnc)\boxed{eid \leftarrow \text{TEE.Install}(p_{Enc})} Server loads program into enclave; gets eid (Enclave ID)

Step 2: Remote Attestation

ρ←TEE.Quote(H(pEnc), nonce)\boxed{\rho \leftarrow \text{TEE.Quote}(H(p_{Enc}),\ nonce)} TEE.VrfyQuote(pkTEE, pEnc, ρ)=1\boxed{\text{TEE.VrfyQuote}(pk_{TEE},\ p_{Enc},\ \rho) = 1}

  • Enclave proves its identity via cryptographic quote
  • H(pEnc)H(p_{Enc}) = hash of enclave program (proves exact code loaded)
  • nonce = prevents replay attacks
  • Client verifies: returns 1 if 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)

Ksess←KEX(Client, Enclave)\boxed{K_{sess} \leftarrow \text{KEX}(\text{Client},\ \text{Enclave})}

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

CaseMethodSecurity
Case 1Client sends key encrypted with KsessK_{sess}: EncKsess(k)\text{Enc}_{K_{sess}}(k)Key travels over wire (encrypted)
Case 2(stronger)Enclave generates key internally: k←KeyGen(1λ)k \leftarrow \text{KeyGen}(1^\lambda)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

EncKsess(m)\boxed{\text{Enc}_{K_{sess}}(m)} Enclave receives and decrypts internally.

Step 6: Encrypt Inside Enclave

\boxed{CT = \text{Enc_{AES}}(m,\ k)}

TEE Formal Algorithms

AlgorithmSignatureDescription
TEE.Init→(pkTEE,skTEE)\rightarrow (pk_{TEE}, sk_{TEE})Generates TEE signing key pair
TEE.Install(p)→eid(p) \rightarrow eidLoads program into enclave; returns Enclave ID
TEE.Resume(eid,f,in)→(out,ρ)(eid, f, in) \rightarrow (out, \rho)Runs function ff; returns output + attestation
TEE.VrfyQuote(pkTEE,p,out,ρ)→0,1(pk_{TEE}, p, out, \rho) \rightarrow {0,1}Returns 1 iff attestation valid + program loaded
TEE.Seal(data)→sealeddata(data) \rightarrow sealed_dataEncrypts 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)

TypeSize
Physical EPC (older)~128 MB
Usable EPC~90–100 MB
Newer SGXup 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

TechnologyUsed In
Intel SGXSecure enclaves in Intel CPUs
ARM TrustZoneSmartphones, IoT devices
AMD SEVCloud VMs — encrypts entire VM memory
Apple Secure EnclaveFace ID, Touch ID, secure key storage

If CPU does NOT support TEE features → No TEE available.


18. TPM vs. TEE Comparison

FeatureTPMTEE
TypeHardware security chip (separate)Secure CPU environment (inside CPU)
PurposeSecure key storage + boot trustSecure execution of sensitive code
LocationSeparate hardware module on motherboardInside the processor
Typical UseSecure 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 whenUse TPM when
Keys used frequently during secure app executionKeys tied to platform integrity or device identity
Mobile payment keysSecure boot verification
Biometric authenticationDisk encryption keys (BitLocker)
DRM keysDevice identity / attestation keys
Confidential computing, IoTProtection against bootkits, firmware attacks
ComponentBest Role
TPMRoot keys, device identity, boot integrity keys
TEEApplication/session keys, runtime crypto operations

⚡ Key Facts to Remember

FactDetail
OS = primary attack targetControls all system resources → most valuable to compromise
OS must protectUsers from each other + resources
Layered OSEach layer vulnerable to attacks from below
ASLRRandomizes memory addresses → defeats hardcoded-address exploits
Without ASLRAttacker knows return address → can jump to shellcode
gets()Dangerous — no bounds checking → use fgets()
Stack canaryRandom value before return address; if modified → program aborts
Buffer overflowOverwrite return address → redirect execution to attacker's code
Return-to-libcReuses existing library code (no injection) → bypassed by ASLR
OS hardening ruleFEWER IS BETTER — remove all unnecessary services/apps
Default configMaximizes ease-of-use, NOT security — never use defaults
Defense in depthMultiple layers from hardware to data — attack must breach all
Type 1 HypervisorBare-metal — more secure than Type 2 (hosted)
vSwitch securityPrevent: promiscuous mode, MAC spoofing, forged transmissions
VMIVM introspection from hypervisor level — no agent needed
TPMHardware chip: key storage, boot integrity, device attestation
Trusted BootHashes each boot component → stores in PCR → detects tampering
TEEIsolated CPU area — even compromised OS can't access it
TEE.SealKey exported out of enclave must be sealed; unsealed to use
Remote AttestationCryptographic proof that enclave code is genuine + untampered
Case 2 key provisionKey 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)
BitLockerFull-disk encryption with AES
UACAdmin runs as standard user by default; elevates only when required
chroot jailRestricts Linux app to a directory subtree — isolation technique
AMD SEVEncrypts entire VM memory in cloud
ARM TrustZoneTEE for smartphones and IoT
Apple Secure EnclaveFace ID / Touch ID / key storage TEE