Security Fundamentals
Advanced Track: Lecture 11
mdcha (adapted w/ <3 from abizer)
Let’s Speedrun CS 161 and Then Some.
Why do we care?
Why do we care?
What is Security?
Security is keeping systems functioning as intended in the face of adversaries.
This can take multiple forms:
Confidentiality
Integrity/Authenticity
Availability
Basic Principles
Basic Principles
Basic Principles: Account for Human Factors
Basic Principles: Account for Human Factors
Threat modeling
(There are always more attackers than you think, and they’re always more clever than you think)
Security Basics
Building Blocks
Everything is interrelated and builds off of one another
Don’t #$%^& with primitives
Don’t #$%^& with primitives
Authentication
Problem: You have data and you only want to give access to the owner of the data. (e.g. banking info)
How do they identify themselves and prove they are the owner?
Passwords Suck.
Passwords suck.
What do we do as users?
What do we do as users?
What do we do as SysAdmins?
Better Authentication (Multi-Factor Authentication)
Better Authentication (Multi-Factor Authentication)
Be careful with biometrics
Encryption
* For a less glib treatment of this argument, see Daniel Solove’s essay 'I've Got Nothing to Hide' and Other Misunderstandings of Privacy
** This is security by obscurity
Encryption
Instead, let’s “hide” things by converting information into something unreadable, except by you - that way, even if it’s “found,” it’s useless, because it’s meaningless garbage
“secret” -> “fc683cd9ed1990ca2ea10b84e5e6fba048c24929”
There’s two parts, encrypting and decrypting
“Fc683cd9ed1990ca2ea10b84e5e6fba048c24929” -> ???
Symmetric Encryption
Asymmetric Encryption
Problem: How do we share keys over an insecure connection?
Asymmetric Encryption
Solution: Public Key Cryptography. There’s two parts:
Anything encrypted with the public key can only be decrypted with the private key. Nothing secret needs to be securely sent beforehand like symmetric cryptography.
Asymmetric Encryption: RSA
RSA is the classic example
Asymmetric Encryption, ECC
Elliptic Curve Cryptography (ECC)
Any Questions?
Hashing
Hashing! Turn any data (even that bloated as hell 20GB Windows 10 OS) into a small fixed string. This is
Hashing, cont.
There are lots of hashing / digest algorithms, you may have heard of some of them, e.g.
man sha{1,256,4512,224,384}sum and md5sum to see how to use these on the terminal
Hashing, cont.
All of them turn arbitrary data into fixed-size outputs with critical cryptographic properties met:
Practical Hashing: Verifying Integrity
Practical Hashing: Password Verification
Never store user passwords in plain (or encrypted) text.
Practical Hashing: Password Verification
Recall that hashing functions are deterministic and public.
I promise you there’s a lookup table matching the top 1000 passwords to their bcrypt values floating around somewhere.
How do we defeat this?
Practical Hashing: Password Verification
Salt your passwords:
Any Questions?
Signatures and Certificates
The public key cryptography system can also be used the verify identities.
Suppose I want to use your public key to verify your identity. I can encrypt something with it, and ask you to decrypt it and show me the correct value. If you can decrypt the value, you must own the private half of the key and can be authenticated.�
Signatures and Certificates
Suppose you want to prove that a message sent by you is actually sent by you. You can use your private key to “sign” the message by encrypting it, and your public key can be used to decrypt the signature to verify that you (identified by your published public key) did in fact send the message, since only you and not an adversary would have the corresponding private key.
Signatures and Certificates
How can we trust that the public key we get belongs to the user?
If I gave you a public key and told you that it belonged to your bank, how do you verify this?
This is a nontrivial problem. You have to consider things like revocation and mistakes in transmission.
Signatures and Certificates, cont.
Enter certificates:
Signatures and Certificates, cont.
https://packages.debian.org/stretch/ca-certificates
Any Questions?
File Security
File Permissions and Ownership
Background
See also: Role-based Access Control
UNIX Permissions Model
Everything is a file, every “file” owned by a user and a group
3 components in UNIX permission model: for file’s
3 types of permissions:
9 possibilities: user rwx, group rwx, other rwx
Explanation of Permissions
d r w x r - x r - -
9 permissions
flag indicating directory, or symlink, or various other things
user:
read
write
execute
group:
read
execute
other:
read
Permissions Masks
4: Read (100)
2: Write (010)
1: Execute (001)
= 7 (111)
What is:
Modifying Permissions
2 primary ways to modify permissions/file access:
Changing File Ownership
Changing File Permissions
Why is this important?
In a practical sense, bad file security is one of the easiest ways to leak information or give an attacker far too much privilege on your system.
Suppose you are using public-key crypto to encrypt your files on a multi-user system. What happens if you set this as the permissions on your private key?
�Anyone on your system can read your key and decrypt your files!
What happens if a program running as root gets exploited? Whole system is compromised!
File Security
File Security
Mandatory / Role-Based Access Control
set[ug]id
setuid and setgid are auxiliary bits that can be set in the permissions of a file that allow it to execute as the owning user/group respectively, regardless of which user calls it
e.g. allow anyone to execute a single script, which would run as (for example) the root user, or as the www-data group, to achieve some necessary end
Any Questions?
Network Security
Protecting a computer and applications over the network
Security implications of networked software
Background
Therefore, it is important to minimize your attack surface and reduce attack vectors as much as possible
Basics
Basics
Basics
Basics
Network Security is Hard.
Types of network attacks
There are lots of ways to attack networked systems:
Wiretapping, Man in the Middle, Denial of service, Application vulnerabilities such as buffer/heap overflow, SQL injection, directory traversal, CSRF, SSRF, XSS, Injection of viruses, worms, rootkits, spam, cryptomining, ransomware, phishing, dozens more...
So what do we do about… wiretapping?
So what do we do about… man-in-the-middle?
So what do we do about… denial of service?
So what do we do about… application vulnerabilities?
So what do we do about… application vulnerabilities?
So what do we do about… application vulnerabilities?
That being said....
Vote in the Spring 2020 ASUC Elections to fund us with STF!
Logging
The only way to respond to attacks is with good logs. Or else you’re just guessing.
Keep a centralized logging server using something rsyslog or syslogd: it’s less likely an attacker can escape a distributed logging system after breaking into a singular machine.
You can see if someone is aggressively scanning your servers.
Having intrusion detection systems (IDS) like bro/zeek is solid
Kerberos
BeyondCorp and Zero Trust
Resources
Discussion: TLS MiTM
Is this attack possible?
Does this attack work, why or why not? Does TLS have any defense against this type of attack? How would it protect against this type of attack?
How does it work together?
Example: secure web browsing via TLS
Don’t ignore certificate validation errors!
References