09 Security
09 Security
Operating Systems
Brad Campbell – [email protected]
https://www.cs.virginia.edu/~bjc8c/class/cs6456-f19/
1
2
Protection vs. Security
• Protection: mechanisms for controlling access of programs,
processes, or users to resources
• Page table mechanism
• Round-robin schedule
• Data encryption
• Data integrity
• Ensure that data is not changed from source to
destination or after being written on a storage device
• Confidentiality
• Ensures that data is read only by authorized users
• Non-repudiation
• Sender/client can’t later claim didn’t send/write data
• Receiver/server can’t claim didn’t receive/write data
4
Why are Data Breaches so Frequent?
Really Large TCB Really Large TCB
SSL
SSL
h h
SSL
Full OS TCB
Encrypt with
Internet Decrypt with
secret key secret key
Ciphertext
7
Block Ciphers with Symmetric Keys
• Block cipher algorithms encrypt blocks of data
• Works with a block size (e.g., 64 bits)
• Can encrypt blocks separately:
• Same plaintextsame ciphertext
• Much better:
• Add in counter and/or link ciphertext of previous block
9
Authentication in Distributed Systems
• What if identity must be established across network?
Network
PASS: gina
• Need way to prevent exposure of information while still
proving identity to remote system
• Many of the original UNIX tools sent passwords over the
wire “in clear text”
• E.g.: telnet, ftp, yp (yellow pages, for distributed login)
• Result: Snooping programs widespread
• What do we need? Cannot rely on physical security!
• Encryption: Privacy, restrict receivers 11
• Authentication: Remote Authenticity, restrict senders
Authentication via Secret Key
• Main idea: entity proves identity by decrypting a secret
encrypted with its own key
• K – secret key shared only by A and B
• A can asks B to authenticate itself by decrypting a nonce,
i.e., random value, x
• Avoid replay attacks (attacker impersonating client or server)
• Vulnerable to man-in-the middle attack
A B
E(x, K
)
Notation: E(m,k) –
x
encrypt message
m with key k
12
Secure Hash Function
DFCD3454BBEA788A
Hash
Fox 751A696C24D97009
Function
CA992D17
• Approach:
• Sender computes a secure digest of message m using H(x)
• H(x) is a publicly known hash function
• Digest d = HMAC (K, m) = H (K | H (K | m))
• HMAC(K, m) is a hash-based message authentication function
• Send digest d and message m to receiver
• Upon receiving m and d, receiver uses shared secret key, K, to
recompute HMAC(K, m) and see whether result agrees with d
14
Using Hashing for Integrity
corrupted msg m
plaintext (m)
NO
=
digest’
Digest Internet Digest
HMAC(K,m) HMAC(K,m)
Encrypted Digest
Unencrypted Message
• SHA-2 (2001)
• Family of SHA-224, SHA-256, SHA-384, SHA-512 functions
17
Third Party: Authentication Server (Kerberos)
• Notation:
• Kxy is key for talking c k et Key
q Ti
between x and y Re Server
• (…) means encrypt e t
Tick
K
20
Public Key Encryption Details
• Idea: Kpublic can be made public, keep Kprivate private
Insecure Channel
Bpublic Bprivate
Aprivate Apublic
23
Non-Repudiation: RSA Crypto & Signatures
26
Digital Certificates
• How do you know KE is Alice’s public key?
27
Putting It All Together - HTTPS
29
HTTPS Connection (SSL/TLS) (cont’d)
Browser Amazon
• Browser (client) connects via
TCP to Amazon’s HTTPS server Hel
lo
(TL . I su
S p
• Client sends over list of crypto 2) o +RSA+ port
r AES
(SS 128
protocols it supports or
L+R
SA+ +SH
A
… 3DE
• Server picks protocols to use S+M
D5)
for this session
• Server sends over its e t ’s use S12 8+SH
L E
S +R SA+A
certificate TL
’s my
A 2 H e r e
• (all of this is in the clear) c er t B o f
~1 K
d ata
30
Inside the Server’s Certificate
• Name associated with cert (e.g., Amazon)
• Amazon’s RSA public key
• A bunch of auxiliary info (physical address, type of
cert, expiration time)
• Name of certificate’s signatory (who signed it)
• A public-key signature of a hash (SHA-256) of all this
• Constructed using the signatory’s private RSA key, i.e.,
• Cert = E(HSHA256(KApublic, www.amazon.com, …), KSprivate))
• KApublic: Amazon’s public key
• KSprivate: signatory (certificate authority) private key
•…
31
Validating Amazon’s Identity
• How does the browser authenticate certificate signatory?
• Certificates of several certificate authorities (e.g., Verisign) are
hardwired into the browser (or OS)
• If can’t find cert, warn user that site has not been verified
• And may ask whether to continue
• Note, can still proceed, just without authentication
• Browser uses public key in signatory’s cert to decrypt signature
• Compares with its own SHA-256 hash of Amazon’s cert
• Assuming signature matches, now have high confidence it’s
indeed Amazon … assuming signatory is trustworthy
• DigiNotar CA breach (July-Sept 2011): Google, Yahoo!, Mozilla, Tor
project, Wordpress, … (531 total certificates)
32
HTTPS Connection (SSL/TLS) cont’d
Browser Amazon
s my
• Browser constructs a random session Here’
c er t d ata
key K used for data communication o f
~1 KB
• Private key for bulk crypto K E(K, K
Apu
• Browser encrypts K using Amazon’s blic )
public key
• Browser sends E(K, KApublic) d K
Agree
to server
• Browser displays E(pa
s swor
d …,
• All subsequent comm. encrypted w/ K)
symmetric cipher …,
(e.g., AES128) using key K e s p o n se
E (r
• E.g., client can authenticate using a K)
password
34
Hardware Security
• Definition: implement security protection
mechanisms in hardware
• E.g., design trusted hardware, as opposed to (in addition
to) trusted software
• Software security: software protect software!
• Vulnerable to attacks
• Is the antivirus/hardware untouched?
• Easy infiltration
• Fast spread
• Hardware security: hardware protect software
• Attacks need physical access
• Software infiltration much more difficult
35
Trusted Platform Module (TPM)
36
Goals
• TPMs allow a system to:
• Gather and attest system state
• Store and generate cryptographic data
• Prove platform identity
37
TPM Components
• Root key
• PKI private keys could be stored in the chip
• PK signatures calculated in the chip itself, never
visible outside
• Random number generators
• SHA-1 encryption
• Monotonic counters
• Process isolation (encrypted I/O, prevents keystroke
loggers, screen scrapers)
38
Limitations
• Potential applications:
• DRM
• Fighting pirate software
40
BitLocker™ Drive Encryption Architecture
Static Root of Trust Measurement of boot components
TPM Init
BIOS
MBR
BootSector
BootBlock
BootManager
Start
OS Loader
OS
42
Disk Layout And Key Storage
OS Volume Contains Where’s the Encryption Key?
• Encrypted OS 1. SRK (Storage Root Key)
contained in TPM
• Encrypted Page File
2. SRK encrypts FVEK (Full Volume
• Encrypted Temp Files
Encryption Key) protected by TPM/PIN/USB
• Encrypted Data Storage Device
• Encrypted Hibernation File 3. FVEK stored (encrypted by SRK) on hard
drive in the OS Volume
3
OS Volume
2 FVEK 1 SRK
System
Client side:
• Hide anti-virus (AV) signatures:
• AV signatures are only opened inside an enclave
• not exposed to adversary in the clear
• Hide proprietary ML models:
• Speech detection on smart home devices
• Models secret and hidden from competitors
46
Intel SGX: how does it work?
create enclave
(isolated memory)
Process memory
47
Intel SGX: how does it work?
Process memory
48
Intel SGX: how does it work?
Process memory
49
How does it work?
• Part of process memory holds the enclave:
Process memory
53
SGX insecurity: side channels
60
Speculative execution
CPUs can guess likely program path and do speculative execution
Example:
if (uncached_value == 1) // load from memory
a = compute(b)
63
What about with speculative execution?
Conditional branch (Variant 1) attack
Memory & Cache Status
if (x < array1_size)
array1_size = 00000008
y = array2[array1[x]*4096];
Memory at array1 base:
8 bytes of data (value doesn’t matter)
Memory at array1 base+1000:
09 F1 98 CC 90...(something secret)
Before attack:
array2[ 0*4096]
• Train branch predictor to expect if() is true array2[ 1*4096]
array2[ 2*4096]
(e.g. call with x < array1_size) array2[ 3*4096]
array2[ 4*4096]
• Evict array1_size and array2[ 5*4096]
array2[ 6*4096] Contents don’t matter
array2[] from cache array2[ 7*4096] only care about cache status
array2[ 8*4096]
Uncached Cached
array2[ 9*4096]
array2[10*4096]
array2[11*4096]
64
Conditional branch (Variant 1) attack
Memory & Cache Status
if (x < array1_size)
array1_size = 00000008
y = array2[array1[x]*4096];
Memory at array1 base:
8 bytes of data (value doesn’t matter)
Memory at array1 base+1000:
Attacker calls victim with x=1000 09 F1 98 CC 90...(something secret)