Unit 2 · Operating Systems
Imagine CPU is boss, devices are workers (printer, disk, keyboard). How does boss talk to workers? 3 ways:
Programmed I/O: Boss constantly asks worker "done? done? done?" polling busy waiting wastes CPU.
Interrupt-driven I/O: Boss says do work and goes to do other work, worker interrupts boss when done "Boss I'm done!" via ISR Interrupt Service Routine efficient.
DMA Direct Memory Access: Boss hires manager DMA controller transfers data directly between device and memory without CPU involvement CPU free to do other work DMA steals cycles cycle stealing fast for bulk transfer disk.
Protection = Inside security who can access what inside system? Access Matrix rows=Domains (process, user) columns=Objects (file, device) cells=Rights (read/write/execute). Domain=process/user who wants access Object=file/device what is accessed Rights=what can do. Implementation ACL Access Control List column-wise per object stored with object file→{process:r,w,x; user:r} easy to list who can access file, Capability List row-wise per domain stored with domain process→{file:r,w,x; device:r,x} like ticket/token held by domain. Revocation ACL→remove domain from object's list→easy Capability→must reclaim capability from domain→harder. Principle of least privilege give each domain only minimum rights it needs to function limits damage if compromised. Protection Rings Ring 0 kernel highest privilege OS runs here Ring 3 user lowest privilege user apps run here Goal enforce isolation control access safely.
Security = Outside protection from external threats CIA triad: Confidentiality keep data secret only authorized access, Integrity data remains accurate not altered or tampered, Availability system & data accessible when needed + Authentication verify identity of user/system + Non-repudiation sender cannot deny having sent it. Threats 4 types: Interruption→availability service disrupted stopped, Interception→confidentiality data eavesdropped/sniffed, Modification→integrity data altered/changed, Fabrication→authenticity fake data/message introduced.
Malware types must know: Virus attaches to a file requires host to run, Worm standalone self-replicates spreads across network, Trojan disguises as useful program but is malicious, Spyware spies on user collects activity/data secretly, Ransomware encrypts files demands ransom payment, Rootkit hides itself to evade detection & maintain control.
Attacks: DoS Denial of Service flood→overwhelm target cause outage, DDoS Distributed Denial of Service many devices/botnet flood target, Buffer Overflow exploit to overwrite memory execute code, Man-in-the-Middle intercept/relay communications between parties.
Security Mechanisms: Encryption symmetric same key DES AES fast uses same key both sides, asymmetric public private key RSA slow public encrypt private decrypt digital signature private encrypt public decrypt, Authentication passwords hashed salt one-time passwords biometrics multi-factor MFA, Firewalls packet filter stateful application gateway, Intrusion Detection IDS NIDS HIDS anomaly signature, Digital Signature and Certificates CA, Protection vs Security Protection controls access inside system Access Matrix Security protects from external threats CIA. Let's learn with handwritten diagrams.
I/O Subsystem Layer:
- User process → kernel I/O subsystem (scheduling, buffering, caching, spooling) → device driver (knows device specifics) → device controller (hardware interface) → device (printer, disk, keyboard).
- Kernel I/O subsystem provides services: scheduling of I/O requests, buffering temporary storage to cope with speed mismatch, caching faster access, spooling queue for shared devices like printer, device reservation.
3 Methods of I/O Handling:
- 1) Programmed I/O (Polling):
- CPU polls status register busy waiting constantly checks if device ready "done? done?".
- CPU executes loop: while(device not ready) check status; then transfer data.
- Wastes CPU inefficient CPU busy waiting cannot do other work waiting.
- Good for fast devices or when device ready quickly but inefficient for slow devices.
- No interrupt hardware needed simple.
- 2) Interrupt-driven I/O:
- CPU does other work after initiating I/O device interrupts CPU when ready.
- Steps: CPU starts I/O → goes to do other process → device finishes → raises interrupt → CPU saves current context → jumps to ISR Interrupt Service Routine → handles I/O transfer → restores context → resumes.
- Efficient CPU not wasting time polling can do other useful work during I/O.
- Needs interrupt controller and ISR handling overhead context switch per interrupt.
- Better than programmed for most devices.
- 3) DMA Direct Memory Access:
- DMA controller transfers data directly between device and memory without CPU involvement for each byte.
- Steps: CPU programs DMA controller with source, destination, count → CPU free to do other work → DMA controller transfers data device↔memory directly stealing memory cycles cycle stealing → when done DMA interrupts CPU "transfer complete".
- CPU involvement minimal only setup and completion interrupt.
- Fast for bulk transfer disk I/O large blocks high speed devices.
- DMA steals cycles cycle stealing uses memory bus while CPU may need it slight slowdown but overall efficient.
- Needs DMA controller hardware.
Comparison Table:
- Programmed I/O: CPU involvement High polling, Efficiency Low for slow devices, Hardware Simple no interrupt, Use Fast devices where waiting short.
- Interrupt-driven: CPU involvement Low interrupt, Efficiency Medium, Hardware Interrupt controller ISR, Use Most devices moderate speed.
- DMA: CPU involvement Minimal setup only, Efficiency High for bulk transfer, Hardware DMA controller, Use Bulk transfer disk high speed devices large data.
I/O Hardware Techniques:
- Polling, Interrupts, DMA controller, I/O channels.
- Blocking vs Non-blocking I/O: Blocking process waits until I/O complete suspended, Non-blocking process continues returns immediately.
Protection Overview: Protection controls access inside system who can access what internal mechanism.
Access Matrix Model:
- A model that defines protection rights for each (domain, object) pair.
- Rows = Domains, Columns = Objects, Cells = Rights (read/write/execute).
- Domain = process, user who wants access subject that initiates request.
- Object = file, device, memory segment, process what is accessed resource.
- Each cell = the rights the domain has on the object e.g., read, write, execute, rwx.
- Example table: Domains\Objects | file | device | process: file read,write,execute, device read,execute; user: file read, device read,write.
- Domain examples: process, user; Object examples: file, device; Each cell = the rights the domain has on the object.
- Access matrix is abstract model not actually stored as matrix sparse many empty cells implementation via ACL or Capability List.
Implementation Two Ways:
- 1) ACL Access Control List Column-wise:
- Column-wise list of domains & rights for each object.
- Stored with the object e.g., file's inode stores ACL.
- Example: file → { process: r,w,x ; user: r } means process can read write execute file user can only read.
- Easier to list who can access the file answer question "Who can access this file?" quickly.
- Used in Unix Linux Windows file systems.
- ACL entry format: domain: rights.
- 2) Capability List Row-wise:
- Row-wise list of objects & rights for each domain.
- Stored with the domain e.g., process's PCB stores capability list.
- Example: process → { file: r,w,x ; device: r,x } means process has rights rwx on file rx on device.
- Like a ticket/token held by the domain must present capability to access object.
- Easier to list what objects a domain can access answer "What can this process access?" quickly.
- Used in capability-based systems.
Revocation:
- ACL → remove the domain from the object's list → easy just delete entry from ACL of object.
- Capability → must reclaim capability from the domain → harder need to find capability in domain and remove must search all domains.
- ACL easier for revocation, Capability harder.
Principle of Least Privilege:
- Give each domain only the minimum rights it needs to function → Limits damage if process is compromised attacker gets only limited rights not all rights.
- Example: Web browser needs network read but not write to system files give only network read.
Protection Rings:
- Ring 0: kernel highest privilege OS/kernel runs here can execute all instructions privileged instructions access all memory.
- Ring 1,2: device drivers services intermediate.
- Ring 3: user lowest privilege user applications run here cannot execute privileged instructions must syscall to kernel.
- Goal: enforce isolation control access to resources safely hardware support for protection.
- Intel x86 has 4 rings 0-3, ARM has exception levels.
Security Goals CIA Triad + 2:
- Confidentiality: Keep data secret / only authorized access no unauthorized disclosure e.g., encryption.
- Integrity: Data remains accurate / not altered or tampered no unauthorized modification e.g., checksum hash.
- Availability: System & data accessible when needed no denial of service e.g., redundancy.
- + Authentication: Verify identity of user/system are you who you claim? passwords biometrics.
- + Non-repudiation: Sender cannot deny having sent it proof of origin digital signatures.
Threats 4 Types Mapping to Goals:
- Interruption → availability: Service disrupted or stopped e.g., DoS attack cuts network destroys file system.
- Interception → confidentiality: Data eavesdropped/sniffed unauthorized access e.g., wiretapping sniffing passwords.
- Modification → integrity: Data altered/changed unauthorized modification e.g., tampering with database changing values.
- Fabrication → authenticity: Fake data/message introduced e.g., fake transactions fake identity.
Malware Types:
- Virus: Attaches to a file requires host to run cannot run alone replicates when host executed e.g., attaches to .exe file.
- Worm: Standalone self-replicates spreads across network no host needed exploits vulnerabilities e.g., Morris worm.
- Trojan: Disguises as useful program but is malicious pretends to be game but installs backdoor e.g., fake antivirus.
- Spyware: Spies on user collects activity/data secretly keylogger screen capture browsing history.
- Ransomware: Encrypts files demands ransom payment to decrypt e.g., WannaCry CryptoLocker.
- Rootkit: Hides itself to evade detection & maintain control hides files processes maintains backdoor access.
- Difference: Virus needs host file worm standalone Trojan disguises.
Attacks:
- DoS Denial of Service flood → overwhelm target cause outage: Single machine floods target with requests e.g., SYN flood ping flood target cannot serve legitimate users.
- DDoS Distributed Denial of Service many devices/botnet flood target: Many compromised devices botnet flood target harder to block many sources e.g., Mirai botnet.
- Buffer Overflow: Exploit to overwrite memory beyond buffer boundary execute malicious code e.g., strcpy without bounds check overwrites return address jumps to shellcode.
- Man-in-the-Middle: Intercept/relay communications between parties eavesdrop and possibly modify attacker sits between client and server client thinks talking to server server thinks talking to client attacker intercepts.
- Other attacks: Phishing fake emails to steal credentials, SQL Injection inject SQL via input to manipulate database, Cross-Site Scripting XSS inject script into web page.
Encryption:
- Symmetric same key: DES Data Encryption Standard 56-bit old insecure, AES Advanced Encryption Standard 128/192/256-bit modern fast. Same key for encrypt and decrypt fast efficient for bulk data. Need secure channel to share key key distribution problem if attacker intercepts key can decrypt. Example: AES key K encrypt plaintext P → ciphertext C = Encrypt(K,P) decrypt P = Decrypt(K,C) same K.
- Asymmetric public private key: RSA Rivest Shamir Adleman public private key pair. Slow compared to symmetric but solves key distribution. Public key can be shared openly private key secret. Two uses:
- Public encrypt private decrypt: Sender encrypts with receiver's public key only receiver with private key can decrypt confidentiality. Example: Alice wants to send secret to Bob Alice encrypts with Bob's public key Bob decrypts with his private key.
- Private encrypt public decrypt = Digital signature: Sender encrypts with own private key anyone with sender's public key can decrypt verifies sender authenticity non-repudiation. Example: Alice signs message with her private key Bob verifies with Alice's public key proves message from Alice and not tampered integrity.
- Key distribution symmetric need secure channel to share key asymmetric public can be shared openly no secure channel needed for public key but need to verify public key belongs to correct person via certificates.
- Symmetric fast Asymmetric slow hybrid approach uses both Asymmetric to exchange symmetric session key securely then symmetric for bulk data fast e.g., TLS HTTPS uses hybrid RSA/AES.
- DES AES symmetric block ciphers, RSA asymmetric, Diffie-Hellman key exchange.
Authentication:
- Passwords: Not stored plain store hashed with salt hash(salt+password) salt random per user prevents rainbow table attack. On login hash entered password with stored salt compare with stored hash. Example: password "hello" salt "x5" store hash(x5+hello).
- One-time passwords OTP: Password valid only once or short time e.g., SMS OTP TOTP time-based.
- Biometrics: Fingerprint iris face recognition something you are.
- Multi-factor MFA: Combine factors something you know password + something you have phone OTP token + something you are biometrics at least 2 factors. More secure than single factor.
- MFA example: Password (know) + phone OTP (have) + fingerprint (are) = 3-factor.
Firewalls:
- Packet filter filters based on IP port protocol stateless simple fast.
- Stateful keeps connection state tracks TCP connections more secure.
- Application gateway proxy firewall filters at application layer e.g., HTTP proxy understands HTTP.
- Firewall sits between internal network and external internet filters traffic based on rules allow/deny.
Intrusion Detection IDS:
- NIDS Network IDS monitors network traffic detects intrusions network-wide.
- HIDS Host IDS monitors host system logs files processes detects intrusions on single host.
- Anomaly detection baseline normal behavior detects deviation from baseline may have false positives.
- Signature detection known attack patterns signatures detects known attacks low false positive but cannot detect new attacks.
- IDS detects IDS + IPS Intrusion Prevention System blocks as well as detects.
Digital Signature and Certificates:
- Digital Signature: Hash message then encrypt hash with sender's private key signature = Encrypt(private_key, hash(message)). Receiver decrypts signature with sender's public key and compares hash verifies integrity and authenticity non-repudiation.
- CA Certificate Authority trusted third party signs certificate binding public key to identity. Certificate = public key + identity + CA signature. Browser has CA public keys pre-installed verifies server certificate.
- PKI Public Key Infrastructure system for managing certificates.
Protection vs Security Difference:
- Protection controls access inside system Access Matrix ACL Capability internal access control who can access what inside OS.
- Security protects from external threats CIA triad outside attackers malware network attacks external.
- Protection is internal Security is external both needed.
Final Recap - Unit 5 Complete: CPU boss devices workers printer disk keyboard How boss talk to workers? 3 ways Programmed I/O Boss constantly asks worker done? done? done? polling busy waiting wastes CPU Interrupt-driven I/O Boss says do work and goes to do other work worker interrupts boss when done Boss I'm done! via ISR Interrupt Service Routine efficient DMA Direct Memory Access Boss hires manager DMA controller transfers data directly between device and memory without CPU involvement CPU free to do other work DMA steals cycles cycle stealing fast for bulk transfer disk. Protection Inside security who can access what inside system Access Matrix rows=Domains process user columns=Objects file device cells=Rights read/write/execute Domain=process/user who wants access Object=file/device what is accessed Rights=what can do Implementation ACL Access Control List column-wise per object stored with object file→{process:r,w,x; user:r} easy to list who can access file Capability List row-wise per domain stored with domain process→{file:r,w,x; device:r,x} like ticket/token held by domain Revocation ACL→remove domain from object's list→easy Capability→must reclaim capability from domain→harder Principle of least privilege give each domain only minimum rights it needs to function limits damage if compromised Protection Rings Ring 0 kernel highest privilege OS runs here Ring 3 user lowest privilege user apps run here Goal enforce isolation control access safely. Security Outside protection from external threats CIA triad Confidentiality keep data secret only authorized access Integrity data remains accurate not altered or tampered Availability system & data accessible when needed + Authentication verify identity + Non-repudiation sender cannot deny having sent it Threats 4 types Interruption→availability service disrupted stopped Interception→confidentiality data eavesdropped/sniffed Modification→integrity data altered/changed Fabrication→authenticity fake data/message introduced Malware types must know Virus attaches to a file requires host to run Worm standalone self-replicates spreads across network Trojan disguises as useful program but is malicious Spyware spies on user collects activity/data secretly Ransomware encrypts files demands ransom payment Rootkit hides itself to evade detection & maintain control Difference Virus needs host file worm standalone Trojan disguises Attacks DoS Denial of Service flood→overwhelm target cause outage DDoS Distributed Denial of Service many devices/botnet flood target Buffer Overflow exploit to overwrite memory execute code Man-in-the-Middle intercept/relay communications between parties Other Phishing fake emails SQL Injection inject SQL XSS inject script. Security Mechanisms Encryption symmetric same key DES AES fast same key encrypt decrypt vs asymmetric public private key RSA slow public encrypt private decrypt digital signature private encrypt public decrypt Key distribution symmetric need secure channel asymmetric public can be shared Symmetric fast Asymmetric slow hybrid uses both Asymmetric to exchange symmetric key then symmetric for data Authentication passwords hashed salt not plain store hash(salt+password) One-time passwords OTP Biometrics fingerprint iris face Multi-factor MFA something you know password + something you have phone OTP + something you are biometrics Firewalls packet filter stateful application gateway proxy firewall IDS Intrusion Detection NIDS Network IDS monitors network HIDS Host IDS monitors host anomaly detection baseline signature detection known patterns Digital Signature and Certificates CA Certificate Authority signs certificate public key+identity Protection vs Security Protection controls access inside system Access Matrix ACL Capability internal Security protects from external threats CIA triad outside attackers malware. If you remember I/O Subsystem User→kernel I/O→device driver→device controller→device Programmed polling busy waiting waste CPU inefficient Interrupt CPU does other work device interrupts ISR efficient DMA controller transfers directly memory without CPU cycle stealing fast bulk disk Comparison Programmed High Low Simple Fast devices Interrupt Low Medium Interrupt controller Most devices DMA Minimal High DMA controller Bulk disk large data and Access Matrix Rows Domains process user Columns Objects file device Cells Rights rwx Domain process user Object file device Each cell rights Abstract model sparse ACL or Capability ACL Column-wise Stored with object Example file→{process:r,w,x; user:r} Easier who can access file Used Unix Linux Windows Capability Row-wise Stored with domain Example process→{file:r,w,x; device:r,x} Like ticket/token held by domain Easier what domain can access Capability-based Revocation ACL→remove domain from object's list→easy Capability→must reclaim from domain→harder Least Privilege Give each domain only minimum rights limits damage if compromised Protection Rings Ring 0 kernel highest privilege OS runs here Ring 3 user lowest privilege user apps run here Goal enforce isolation control access safely and CIA Triad Confidentiality keep secret only authorized Integrity accurate not altered Availability accessible when needed Authentication verify identity Non-repudiation sender cannot deny Threats Interruption→availability disrupted stopped Interception→confidentiality eavesdropped sniffed Modification→integrity altered changed Fabrication→authenticity fake data introduced Malware Virus attaches file requires host Worm standalone self-replicates spreads network Trojan disguises useful but malicious Spyware spies collects secretly Ransomware encrypts demands ransom Rootkit hides evade detection maintain control Difference Virus needs host worm standalone Trojan disguises Attacks DoS flood overwhelm outage DDoS many devices botnet flood Buffer Overflow overwrite memory execute code Man-in-the-Middle intercept relay between parties Phishing fake emails SQL Injection inject SQL XSS inject script Encryption Symmetric same key DES 56-bit old AES 128/192/256 modern fast same key encrypt decrypt Need secure channel C=Encrypt(K,P) P=Decrypt(K,C) same K Asymmetric public private key RSA slow public encrypt private decrypt digital signature private encrypt public decrypt Two uses Public encrypt private decrypt confidentiality Alice encrypts with Bob's public Bob decrypts private Private encrypt public decrypt = Digital signature authenticity non-repudiation Alice signs private Bob verifies public Key distribution symmetric need secure channel asymmetric public can be shared openly but need verify via certificates Symmetric fast Asymmetric slow hybrid Asymmetric to exchange symmetric key then symmetric for data fast TLS HTTPS hybrid RSA/AES Authentication passwords hashed salt hash(salt+password) salt random prevents rainbow table login hash entered with stored salt compare OTP One-time valid once short time SMS TOTP Biometrics fingerprint iris face something you are MFA something you know password + something you have phone OTP + something you are biometrics at least 2 factors more secure Firewalls packet filter IP port stateless simple fast stateful keeps connection state tracks TCP more secure application gateway proxy application layer HTTP proxy Filters between internal external allow/deny IDS NIDS Network monitors network HIDS Host monitors host anomaly baseline deviation may false positives signature known patterns low false positive cannot detect new IDS detects IPS blocks Digital Signature Hash then encrypt hash with private key signature=Encrypt(private_key,hash(message)) Receiver decrypts with public compares hash verifies integrity authenticity non-repudiation CA Certificate Authority trusted third party signs certificate binding public key to identity Certificate=public key+identity+CA signature Browser has CA public keys pre-installed verifies server PKI Public Key Infrastructure Protection vs Security Protection internal Access Matrix ACL Capability internal who can access what inside OS Security external CIA outside attackers malware external both needed DSSSB 6 marks fixed! Unit 5 Complete!
I/O Systems
Protection
| Concept | Definition | Example |
|---|---|---|
| Access Matrix | Model defines protection rights for each (domain, object) pair Rows=Domains Columns=Objects Cells=Rights rwx Domain=process user Object=file device Each cell=rights domain has on object Abstract sparse ACL or Capability implementation | Domains\Objects file device process rwx rx user r rw Domain process user Object file device Each cell rights |
| ACL | Access Control List Column-wise list of domains & rights for each object Stored with object Easier who can access file Who can access this file? quickly Used Unix Linux Windows ACL entry domain:rights | file→{process:r,w,x; user:r} means process can rwx file user only r |
| Capability List | Row-wise list of objects & rights for each domain Stored with domain Like ticket/token held by domain must present capability Easier what domain can access What can this process access? quickly Capability-based systems | process→{file:r,w,x; device:r,x} means process has rights rwx on file rx on device |
| Revocation | ACL→remove domain from object's list→easy just delete entry Capability→must reclaim capability from domain→harder need to find and remove search all domains ACL easier Capability harder | ACL easy Capability hard |
| Least Privilege | Give each domain only minimum rights it needs to function Limits damage if compromised attacker gets only limited rights not all | Web browser needs network read but not write to system files give only network read |
| Protection Rings | Ring 0 kernel highest privilege OS/kernel runs here can execute all privileged instructions access all memory Ring 1,2 device drivers services intermediate Ring 3 user lowest privilege user applications run here cannot execute privileged instructions must syscall to kernel Goal enforce isolation control access safely hardware support | Intel x86 4 rings 0-3 ARM exception levels |
Security
| CIA | Meaning | Protection |
|---|---|---|
| Confidentiality | Keep data secret only authorized access no unauthorized disclosure | Encryption |
| Integrity | Data remains accurate not altered or tampered no unauthorized modification | Checksum hash |
| Availability | System & data accessible when needed no denial of service | Redundancy |
| Authentication | Verify identity are you who you claim? | Passwords biometrics |
| Non-repudiation | Sender cannot deny having sent it proof of origin | Digital signatures |
| Threat | → Goal | Example |
|---|---|---|
| Interruption | availability service disrupted or stopped | DoS cuts network destroys file system |
| Interception | confidentiality data eavesdropped/sniffed unauthorized access | Wiretapping sniffing passwords |
| Modification | integrity data altered/changed unauthorized modification | Tampering database changing values |
| Fabrication | authenticity fake data/message introduced | Fake transactions fake identity |
| Malware | How | Needs Host? |
|---|---|---|
| Virus | Attaches to a file requires host to run cannot run alone replicates when host executed attaches to .exe | Yes needs host file |
| Worm | Standalone self-replicates spreads across network no host needed exploits vulnerabilities Morris worm | No standalone |
| Trojan | Disguises as useful program but is malicious pretends game but installs backdoor fake antivirus | Disguises |
| Spyware | Spies on user collects activity/data secretly keylogger screen capture browsing history | Secret |
| Ransomware | Encrypts files demands ransom payment to decrypt WannaCry CryptoLocker | Encrypts |
| Rootkit | Hides itself to evade detection & maintain control hides files processes maintains backdoor | Hides |
| Attack | How | Effect |
|---|---|---|
| DoS | Denial of Service flood→overwhelm target Single machine floods with requests SYN flood ping flood | Overwhelm target cause outage target cannot serve legitimate users |
| DDoS | Distributed Denial of Service many devices/botnet flood target Many compromised devices botnet flood | Harder to block many sources Mirai botnet |
| Buffer Overflow | Exploit to overwrite memory beyond buffer boundary strcpy without bounds check overwrites return address jumps to shellcode | Overwrite memory execute code |
| Man-in-the-Middle | Intercept/relay communications between parties eavesdrop and possibly modify attacker sits between client and server client thinks talking to server server thinks talking to client attacker intercepts | Eavesdrop modify |
| Other | Phishing fake emails to steal credentials SQL Injection inject SQL via input to manipulate database XSS Cross-Site Scripting inject script into web page | Steal credentials manipulate database inject script |
Security Mechanisms
| Mechanism | How | Example |
|---|---|---|
| Symmetric Encryption | Same key DES 56-bit old insecure AES 128/192/256-bit modern fast same key encrypt decrypt fast efficient bulk data need secure channel to share key key distribution problem if attacker intercepts key can decrypt C=Encrypt(K,P) P=Decrypt(K,C) same K | DES AES symmetric block ciphers AES 128/192/256 |
| Asymmetric Encryption | Public private key RSA slow public private key pair slow but solves key distribution public key shared openly private key secret Two uses Public encrypt private decrypt confidentiality Sender encrypts with receiver's public only receiver private can decrypt Alice to Bob Alice encrypts with Bob's public Bob decrypts private Private encrypt public decrypt = Digital signature authenticity non-repudiation Sender encrypts own private anyone with sender's public can decrypt verifies sender authenticity non-repudiation Alice signs with private Bob verifies with Alice's public proves from Alice not tampered | RSA Diffie-Hellman key exchange |
| Key Distribution | Symmetric need secure channel to share key Asymmetric public can be shared openly no secure channel needed for public key but need to verify public key belongs to correct person via certificates | Symmetric need secure Asymmetric public can be shared |
| Speed | Symmetric fast Asymmetric slow hybrid uses both Asymmetric to exchange symmetric session key securely then symmetric for bulk data fast TLS HTTPS hybrid RSA/AES | Hybrid TLS HTTPS RSA/AES |
| Passwords | Not stored plain store hashed with salt hash(salt+password) salt random per user prevents rainbow table attack On login hash entered password with stored salt compare with stored hash Example password hello salt x5 store hash(x5+hello) | hash(salt+password) salt random prevents rainbow table |
| OTP | One-time passwords valid only once or short time SMS OTP TOTP time-based | SMS OTP TOTP |
| Biometrics | Fingerprint iris face recognition something you are | Fingerprint iris face |
| MFA | Multi-factor Combine something you know password + something you have phone OTP token + something you are biometrics at least 2 factors more secure than single factor Example Password know + phone OTP have + fingerprint are = 3-factor | Password know + phone OTP have + fingerprint are = 3-factor |
| Firewalls | Packet filter filters IP port protocol stateless simple fast Stateful keeps connection state tracks TCP connections more secure Application gateway proxy firewall application layer e.g., HTTP proxy understands HTTP Firewall sits between internal and external filters traffic based on rules allow/deny | Packet filter IP port stateless Stateful tracks TCP Application gateway proxy HTTP proxy |
| IDS | NIDS Network IDS monitors network traffic detects intrusions network-wide HIDS Host IDS monitors host system logs files processes detects intrusions on single host Anomaly detection baseline normal behavior detects deviation may false positives Signature detection known attack patterns signatures detects known attacks low false positive cannot detect new attacks IDS detects IPS Intrusion Prevention System blocks as well as detects | NIDS Network HIDS Host Anomaly baseline deviation may false positives Signature known patterns low false positive cannot detect new IDS detects IPS blocks |
| Digital Signature | Hash message then encrypt hash with sender's private key signature=Encrypt(private_key,hash(message)) Receiver decrypts signature with sender's public key and compares hash verifies integrity and authenticity non-repudiation | signature=Encrypt(private_key,hash(message)) Receiver decrypts with public compares hash |
| CA | Certificate Authority trusted third party signs certificate binding public key to identity Certificate=public key+identity+CA signature Browser has CA public keys pre-installed verifies server certificate PKI Public Key Infrastructure system for managing certificates | Certificate=public key+identity+CA signature Browser has CA public keys pre-installed PKI |
| Protection vs Security | Protection controls access inside system Access Matrix ACL Capability internal access control who can access what inside OS Security protects from external threats CIA triad outside attackers malware network attacks external both needed | Protection internal Access Matrix ACL Capability Security external CIA outside attackers malware |
PYQ Traps Unit 5 Final:
• I/O Subsystem User→kernel I/O→device driver→device controller→device Kernel scheduling buffering caching spooling reservation
• Programmed I/O polling CPU polls status register busy waiting waste CPU inefficient for slow CPU High polling Efficiency Low Hardware Simple Fast devices where waiting short
• Interrupt-driven I/O CPU does other work device interrupts when ready ISR CPU saves context jumps to ISR handles returns efficient CPU not wasting Needs interrupt controller overhead context switch per interrupt CPU Low Efficiency Medium Hardware Interrupt controller ISR Most devices moderate speed
• DMA Direct Memory Access controller transfers directly memory without CPU CPU programs DMA source destination count CPU free DMA device↔memory directly cycle stealing when done interrupts transfer complete CPU Minimal Efficiency High Hardware DMA controller Needs DMA controller Bulk disk large data fast Cycle stealing uses memory bus while CPU may need slight slowdown but efficient
• Blocking waits until I/O complete suspended Non-blocking continues returns immediately
• Access Matrix Model defines protection rights for each (domain, object) pair Rows=Domains Columns=Objects Cells=Rights rwx Domain=process user Object=file device Each cell=rights domain has on object Abstract model not stored as matrix sparse implementation via ACL or Capability
• ACL Access Control List Column-wise list of domains & rights for each object Stored with object Example file→{process:r,w,x; user:r} means process can rwx file user only r Easier to list who can access file Who can access this file? quickly Used Unix Linux Windows ACL entry domain:rights
• Capability List Row-wise list of objects & rights for each domain Stored with domain Example process→{file:r,w,x; device:r,x} means process has rights rwx on file rx on device Like ticket/token held by domain must present capability to access Easier to list what objects domain can access What can this process access? quickly Capability-based systems
• ACL vs Capability ACL Column-wise Stored with object Example file→{process:r,w,x; user:r} Easier who can access file Used Unix Linux Windows vs Capability Row-wise Stored with domain Example process→{file:r,w,x; device:r,x} Like ticket/token held by domain Easier what domain can access Capability-based
• Revocation ACL→remove domain from object's list→easy just delete entry from ACL of object Capability→must reclaim capability from domain→harder need to find capability in domain and remove search all domains ACL easier for revocation Capability harder
• Principle of Least Privilege Give each domain only minimum rights it needs to function Limits damage if process compromised attacker gets only limited rights not all Example Web browser needs network read but not write to system files give only network read
• Protection Rings Ring 0 kernel highest privilege OS/kernel runs here can execute all privileged instructions access all memory Ring 1,2 device drivers services intermediate Ring 3 user lowest privilege user applications run here cannot execute privileged instructions must syscall to kernel Goal enforce isolation control access to resources safely hardware support Intel x86 4 rings 0-3 ARM exception levels
• Security Protects from external threats CIA triad outside attackers malware network attacks external
• CIA Triad Confidentiality keep data secret only authorized access no unauthorized disclosure encryption Integrity data remains accurate not altered or tampered no unauthorized modification checksum hash Availability system & data accessible when needed no denial of service redundancy + Authentication verify identity are you who you claim? passwords biometrics + Non-repudiation sender cannot deny having sent it proof of origin digital signatures
• Threats 4 types Interruption→availability service disrupted or stopped e.g., DoS cuts network destroys file system Interception→confidentiality data eavesdropped/sniffed unauthorized access e.g., wiretapping sniffing passwords Modification→integrity data altered/changed unauthorized modification e.g., tampering database changing values Fabrication→authenticity fake data/message introduced e.g., fake transactions fake identity
• Malware Virus attaches to a file requires host to run cannot run alone replicates when host executed attaches to .exe Worm standalone self-replicates spreads across network no host needed exploits vulnerabilities Morris worm Trojan disguises as useful program but is malicious pretends game but installs backdoor fake antivirus Spyware spies on user collects activity/data secretly keylogger screen capture browsing history Ransomware encrypts files demands ransom payment to decrypt WannaCry CryptoLocker Rootkit hides itself to evade detection & maintain control hides files processes maintains backdoor Difference Virus needs host file worm standalone Trojan disguises
• DoS Denial of Service flood→overwhelm target cause outage Single machine floods target with requests SYN flood ping flood target cannot serve legitimate users
• DDoS Distributed Denial of Service many devices/botnet flood target Many compromised devices botnet flood target harder to block many sources Mirai botnet
• Buffer Overflow Exploit to overwrite memory beyond buffer boundary execute malicious code strcpy without bounds check overwrites return address jumps to shellcode
• Man-in-the-Middle Intercept/relay communications between parties eavesdrop and possibly modify attacker sits between client and server client thinks talking to server server thinks talking to client attacker intercepts
• Other attacks Phishing fake emails to steal credentials SQL Injection inject SQL via input to manipulate database XSS Cross-Site Scripting inject script into web page
• Encryption Symmetric same key DES 56-bit old insecure AES 128/192/256-bit modern fast same key encrypt decrypt fast efficient bulk data need secure channel to share key key distribution problem if attacker intercepts key can decrypt C=Encrypt(K,P) P=Decrypt(K,C) same K
• Asymmetric Public private key RSA slow public private key pair slow but solves key distribution public key shared openly private key secret Two uses Public encrypt private decrypt confidentiality Sender encrypts with receiver's public only receiver private can decrypt Alice to Bob Alice encrypts with Bob's public Bob decrypts private Private encrypt public decrypt = Digital signature authenticity non-repudiation Sender encrypts own private anyone with sender's public can decrypt verifies sender authenticity non-repudiation Alice signs with private Bob verifies with Alice's public proves from Alice not tampered
• Key distribution Symmetric need secure channel to share key Asymmetric public can be shared openly no secure channel needed for public key but need to verify public key belongs to correct person via certificates
• Symmetric vs Asymmetric speed Symmetric fast Asymmetric slow hybrid uses both Asymmetric to exchange symmetric session key securely then symmetric for bulk data fast TLS HTTPS hybrid RSA/AES DES AES symmetric block ciphers RSA asymmetric Diffie-Hellman key exchange
• Authentication passwords hashed salt not plain store hashed with salt hash(salt+password) salt random per user prevents rainbow table attack On login hash entered password with stored salt compare with stored hash Example password hello salt x5 store hash(x5+hello)
• OTP One-time passwords valid only once or short time SMS OTP TOTP time-based
• Biometrics Fingerprint iris face recognition something you are
• MFA Multi-factor Combine something you know password + something you have phone OTP token + something you are biometrics at least 2 factors more secure than single factor Example Password know + phone OTP have + fingerprint are = 3-factor
• Firewalls Packet filter filters IP port protocol stateless simple fast Stateful keeps connection state tracks TCP connections more secure Application gateway proxy firewall application layer e.g., HTTP proxy understands HTTP Firewall sits between internal and external filters traffic based on rules allow/deny
• IDS NIDS Network IDS monitors network traffic detects intrusions network-wide HIDS Host IDS monitors host system logs files processes detects intrusions on single host Anomaly detection baseline normal behavior detects deviation may false positives Signature detection known attack patterns signatures detects known attacks low false positive cannot detect new attacks IDS detects IPS Intrusion Prevention System blocks as well as detects
• Digital Signature Hash message then encrypt hash with sender's private key signature=Encrypt(private_key,hash(message)) Receiver decrypts signature with sender's public key and compares hash verifies integrity and authenticity non-repudiation
• CA Certificate Authority trusted third party signs certificate binding public key to identity Certificate=public key+identity+CA signature Browser has CA public keys pre-installed verifies server certificate PKI Public Key Infrastructure system for managing certificates
• PKI Public Key Infrastructure system for managing certificates
• Protection vs Security Protection controls access inside system Access Matrix ACL Capability internal access control who can access what inside OS Security protects from external threats CIA triad outside attackers malware network attacks external both needed
• Difference Virus Worm Trojan Virus needs host file attaches requires host to run Worm standalone self-replicates spreads across network no host needed exploits vulnerabilities Trojan disguises as useful program but is malicious pretends useful but installs backdoor