Title: Exploits and Defenses Up and Down the Stack
1Exploits and Defenses Up and Down the Stack
- Jeanna Neefe Matthews
- jnm_at_clarkson.edu
- Electrical and Computer Engineering Seminar
Series2/6/2004
2Internet protocol stack
users
Application
HTTP, SMTP, FTP, TELNET, DNS,
Transport
TCP, UDP.
Network
IP
Link
Ethernet, Wireless, Point-to-point links
3Where in the stack is security?
- Attacks can be targeted at any layer of the
protocol stack! - Defenses must be implemented at multiple levels
of the protocol stack too
4Network Layer
- Route datagram from any machine in the network to
any other based on address - Internet Protocol (IP) main protocol
- Supporting protocols including dynamic routing
protocols
5Network Layer Vulberabilities
- Sometimes IP address used for authorization
- Example only machines with Clarkson IP addresses
can access - No authentication that a packet came from a
machine with the IP address listed in the source
field - Establish routing dynamically
- Routers exchange messages containing known route
information to reach consensus on the best routes
through the system - Any validation of these messages?
6IP Spoofing
- can generate raw IP packets directly from
application, putting any value into IP source
address field - receiver cant tell if source is spoofed
- e.g. C pretends to be B
- Any defense or trust based on IP address is shaky
C
A
B
7Defenses against IP spoofing
- Good for routers not to forward datagrams with
IP addresses not in their network - If you wouldnt route down then dont send up
- Not all configured that way though
- Doesnt help attacks from local networks!
- Really need authentication based on more than IP
address !
8False Dynamic Routing Updates
- Bad routing tables make a routing black hole
where legitimate traffic does not reach - Attacker sends a routing update stating she has a
path to a particular unused host or network - All subsequent packets will be routed to her.
- Once traffic is misdirected attacker can,,,
- Answer as if they are the victim (IP spoofing)
- Delete all traffic (denial of service)
- Could instead listen/forward or modify incoming
packets (man in the middle attack)
9IPSEC
- Secure IP
- Network-layer authentication
- destination host can authenticate source IP
address - Network-layer secrecy
- sending host encrypts the data in IP datagram
- TCP and UDP segments ICMP and SNMP messages.
10Authentication Header (AH) Protocol
- AH header includes
- connection identifier
- authentication data signed message digest,
calculated over original IP datagram, providing
source authentication, data integrity. - Next header field specifies type of data (TCP,
UDP, ICMP, etc.) in plain text
- Provides source host authentication, data
integrity, but not secrecy. - AH header inserted between IP header and IP data
field. - Protocol field 51.
- Intermediate routers process datagrams as usual.
11ESP Protocol
- Provides host authentication PLUS secrecy and
data integrity - Data, ESP trailer encrypted.
- Next header field is in ESP header.
- ESP authentication field is similar to AH
authentication field. - Protocol 50.
12Using IPSec
- Only accept routing updates from machines that
authenticate themselves (secrecy?) - Require authentication especially from trusted
servers on your local network
13Transport Layer
- provide logical communication between app
processes running on different hosts - transport protocols run in end systems
- transport vs network layer services
- network layer data transfer between end systems
- transport layer data transfer between processes
- relies on, enhances, network layer services
14SYN Flooding DoS
- Pick a machine, any machine.
- Spoof packets to it (so you dont get caught)
- Each packet is a the first hand of the 3-way
handshake of TCP send a SYN packet. - Send lots of SYN packets.
- Each SYN packet received causes a buffer to be
allocated, and the limits of the listen()call to
be reached. - Worse yet compromise many machines and then have
them all attack the victim
15Transport Layer
- Most common transport layer protocols is
Transmission Control Protocol (TCP) - TCP provides reliable, in-order delivery over an
unreliable network - How?
- Think of a sending a document over a flaky fax
machine - Let them know it is coming, number the pages, ask
for feedback on what they received, resend if
necessary, etc.
16TCP seq. s and ACKs
- Seq. s
- Byte stream number of first byte in segments
data - ACKs
- seq of next byte expected from other side
- If get data that has already been acked or is too
early, ignore it
Host B
Host A
User types C
Seq42, ACK79, data C
host ACKs receipt of C, echoes back C
Seq79, ACK43, data C
host ACKs receipt of echoed C
Seq43, ACK80
simple telnet scenario
17Transport Layer Network Security
- TCP will accept a segment with an acceptable IP
address, port number and sequence number - Forging the IP address part isnt hard
- Port Number and Sequence number you can
definitely get if you are using a packet sniffer - Port number and sequence number are also pretty
predictable - All this means an attacker has a good chance of
inserting data into a TCP stream
18What might an attacker insert into an ongoing TCP
stream?
- RST or FIN would kill the connection (denial of
service) - Worse if you know how the stream is interpreted
on the other side you could add in data - Telnet is an example of this because it is just
echoing key strokes - If hijack a telnet session could insert any
command you want (rm ?!)
19Defenses
- Switched networks and physical security of the
back bone links - Good idea to do yes but to easy for someone to
plug into network somewhere - Run applications that encrypt the data stream
- Hijacking ssh session vs telnet
- Can still interupt stream but harder to take it
over to do something active - Secure Socket layer
20Secure sockets layer (SSL)
- Server authentication
- SSL-enabled browser includes public keys for
trusted CAs. - Browser requests server certificate, issued by
trusted CA. - Browser uses CAs public key to extract servers
public key from certificate. - Visit your browsers security menu to see its
trusted CAs.
- SSL works at transport layer. Provides security
to any TCP-based app using SSL services. - Often used between WWW browsers, servers for
ecommerce (https). - SSL security services
- server authentication
- data encryption
- client authentication (optional)
21HTTPS
- Encrypted SSL session
- Browser generates symmetric session key, encrypts
it with servers public key (from CA), sends
encrypted key to server. - Using its private key, server decrypts session
key. - Browser, server agree that future msgs will be
encrypted. - All data sent into TCP socket (by client or
server) is encrypted with session key.
- SSL basis of IETF Transport Layer Security
(TLS). - SSL can be used for non-Web applications, e.g.,
IMAP. - Client authentication can be done with client
certificates. - encrypt in the public key given by server and
send - Server can decrypt using private key
22Application Layer
- Application Layer Protocols define set of
messages or language used between two processes
in the network - Often client/server
- Many application layer protocols read like
English text - Example HTTP GET request, SMTP MAIL FROM/RCPT TO
23Application Layer Vulnerabilities
- Many applications are designed with HUGE
security problems - On purpose?
- No! many common applications (FTP, SMTP, telnet)
designed when the goal was just to get it to work
(security complicates that) - But some applications are bad enough that it
makes you wonder
24Clear Text Passwords
- Many application level protocols send your
password and data in the clear - FTP, TELNET, POP, News
- Attack packet sniffing can capture passwords and
confidential information - Defenses
- Replace these applications with ones that do not
send the password in the clear (ssh, scp,..) - Switched Networks and Physical Security of
Backbone networks
25(No Transcript)
26Other application layer problems
- E-Mail viruses?
- They run with your full privileges
- Similarly with web downloads
- Forged mail? Spam mail?
- PGP
- Buffer Overflow attacks?
27Buffer Overflows
- Program buffer overflows are the most common form
of security vulnerability in fact they dominate. - Two have a buffer overflow, you need two things
- Arrange for root-grabbing code to be available in
the programs address space - Get the program to jump to that code.
28Buffer Overrun Seg fault
- In memory, if you read data into a buffer, you
might write over other variables necessary for
program execution. - Normally this results in a seg fault.
- input256
- buffer16
- strcpy(buffer, input)
29Careful Buffer Overrun Attack
- When you read in too many characters into a
buffer, you can modify the rest of the stack,
altering the flow of the program. - Normally, writing over array bounds causes a seg
fault as youll actually overwrite into other
variables in the program. - If you are careful about what you overwrite, then
you can alter what the program does next without
stepping far enough to cause a seg fault.
30Processes in Memory
- We need consider only four regions in memory
- static data pre-allocation memory ( int
array9) - text instructions and read-only data
- heap re-sizeable portion containing data
malloc()d and free()d by the user. - Stack a push and pop data structure.Used to
allocate local variables used in functions, pass
variables, and return values from function calls.
31Calling a function
- The stack consists of a logical stack of frames.
- Frames are the parameters given to a function,
local variables, and data used to pop back up to
the previous frame (like which instruction to go
back to). - Each frame in the stack looks like this
return addr
Saved framepointer
b
Local vars
32Smashing the Stack
return addr
Saved framepointer
b
Buffer30
Execve(/bin/sh/) return 0xd1
- If buffer gets its input from the command line,
and the input is longer than the allocated
memory, the program will write into the return
address - If you do it perfectly, you can write into the RA
the memory location of your input. - When your function completes, it will execute
next the first command in your input.
33Defenses
- How do you avoid this exploit?
- Use a language with garbage collection and input
will never be able to smash the stack. (i.e.,
java, lisp, etc) - Use input functions carefully.
- Dont use strcpy(), strcat(), sprintf(), gets().
- Use instead strncpy(3), strncat(3), snprintf(3),
and fgets(3) . - There are other problematic constructsfscanf(3),
scanf(3), vsprintf(3), realpath(3), getopt(3),
getpass(3), streadd(3), strecpy(3), and
strtrns(3).
34Security Beyond the Stack
- We just thought about exploits and defenses up
and down the protocol stack - Important to remember that lots of exploits have
nothing to do with the network technologies - If you really want to defend something, defenses
must do well beyond the protocol stack
35Beyond the Stack Physical Security
- Are you sure someone can just walk into your
building and - Steal floppies or CD-ROMs that are lying around?
- Bring in a laptop and plug into your dhcp-enable
ethernet jacks? - Reboot your computer into single user mode?
(using a bios password?) - Reboot your computer with a live CD-ROM and mount
the drives? - Sit down at an unlocked screen?
36Beyond the Stack Social Engineering
- Using tricks and lies that take advantage of
peoples trust to gain access to an otherwise
guarded system. - Social Engineering by Phone Hi this is your
visa credit card company. We have a charge for
3500 that we would like to verify. But, to be
sure its you, please tell me your social
security number, pin, mothers maiden name, etc - Dumpster Diving collecting company info by
searching through trash. - Online hi this is Alice from my other email
account on yahoo. I believe someone broke into my
account, can you please change the password to
foo? - Persuasion Showing up in a FedEx or police
uniform, etc. - Bribery/Threats
37Security Putting It In Perspective
- How do we manage the security of a valued
resource? - Risk assessment the value of a resource should
determine how much effort (or money) is spent
protecting it. - E.g., If you have nothing in your house of value
do you need to lock your doors other than to
protect the house itself? - If you have an 16,000,000 artwork, you might
consider a security guard. (can you trust the
guard?) - Policy define who should have access to each
resource and to what degree.
38Security Putting it In Perspective
- Prevention taking measures that prevent
unauthorized access or damage. - E.g., passwords, physical security, firewalls or
one-time passwords - Detection measures that allow detection of
unauthorized access (when an asset has been
damaged, altered, or copied). - E.g., intrusion detection, trip wire, network
forensic - Recovery restoring systems that were
compromised patch holes. - Response/Punishment measures that deter
unathorized access not through prevention but
through threat of consequences in detected
39Jeannas Top 10
- Dont use telnet/ftp use ssh/scp
- Use a good virus scanner for your e-mail ( cant
trust mail even from friends) - Read mail on a non-Windows machine
- Dont set your mail reader to POP your mail every
5 minutes do it manually - For on-line shopping use a credit card that
guarantees zero liability for fraudulent
purchases - Be wary of downloads from disreputable web sites
- Close down any unnecessary network services on
your machine (netstat a -n) - Use a firewall if your machine is constantly
connected (Linksys) - Get used to normal traffic on your home network
and periodically check (snort) - Back up your data regularly
40FixItDay, Sunday March 7
- Test your metal! Help the Community! Have some
fun! - http//www.clarkson.edu/fixitday/documents/advert
isment_1.pdf - http//www.clarkson.edu/fixitday/documents/advert
isment_2.pdf - http//www.clarkson.edu/fixitday
- Interest Meeting Thursday Feb 26 7 PM
41Outtakes
42Secure as the real world
- The more you think about security the more you
realize how many holes there are - A good rule of thumb is to work to make things as
secure as the real world
43TODO
- Diffie Hellman
- Suseptible to man in the middle
- Kerberos
- Central authorities have long term associations
with all communicating parties
44The Security Process
Detection
- Security is an on-going process between these
three steps. - Moreover, most security research can be
categorized within these three topics.
Prevention
Response
- Prevention firewalls and filtering, secure
shell, anonymous protocols - Detection intrusion detection, IP traceback
- Response dynamic firewall rule sets, employee
education (post-its are bad)
45More 3-faceted views of Security
- Security of an organization consists of
- Computer and Network Security
- Everything that we will learn about in this class
- Firewalls, IDS, virus protection, ssh, passwords,
etc. - Process security
- Protected by good policy!
- No one should be able to get an account by phone
a form should be filled out, an email/phone call
sent to a manager, and then the password picked
up in person. Dont send notifications after
accounts are set up! - http//www.nstissc.gov/html/library.html
- Physical security
- Protected by alarm systems, cameras, and mean
dogs. - Are you sure someone cant just steal the hard
drive?
46Outtakes
47Where in the stack is security?
- Attacks can be targeted at any layer of the
protocol stack - Application layer Password and data sniffing,
Forged transactions, Security holes, Buffer
Overflows? - Transport Layer TCP Session Stealing,
- Network Layer IP Spoofing, False Dynamic Routing
Updates, ICMP attacks - Link Layer ARP attacks
- Denial of Service, Intrusion
- Defenses can be implemented at multiple levels of
the protocol stack too - Application Layer PGP
- Transport Layer SSL
- Network Layer Ipsec
- Link Layer Static ARP tables, Physical security
48Viruses
- Often distributed in email because many email
readers will automatically execute programs
contained in the email - Remember your email program runs as you with your
full privileges (run any program, delete any or
all! files, send email to everyone in your
address book) - Defenses
- Dont allow your mail reader to execute things
(but we like attachments to open up
automatically) - Read your mail on a non-Windows platform, most
viruses target the dominant software platform,
use heterogeneity to help you
49TODO
- Add Diffie-Hellman key exchange
50Ssh
- Users run ssh_keygen on client to generate two
keys - private key /.ssh/identity
- public key /.ssh/identity.pub
- Users append the identity.pub to their
/.ssh/authorized_keys on server - Machines running sshd maintain similar files
/etc/ssh_host_key and /etc/ssh_host_key.pub
51Challenge
- From client ssh machine will send a message to
the server with the username and the client name - Server looks up in authorized_keys, finds the
matching public_key, uses it to encrypt a random
number, and send that back to the client - User uses the private key in /.ssh/identity to
decrypt the message and send it back to the server
52One final attempt
- If authentication methods fail, server may
request passwd from the user - Client machine can still encrypt in the public
key given by server and send - Server can decrypt using private key
- Password did not go in clear but must trust
server with the passwd