Network Security Fundamentals Security Training Course Dr. Charles - - PowerPoint PPT Presentation

network security fundamentals
SMART_READER_LITE
LIVE PREVIEW

Network Security Fundamentals Security Training Course Dr. Charles - - PowerPoint PPT Presentation

Network Security Fundamentals Security Training Course Dr. Charles J. Antonelli The University of Michigan 2013 Network Security Fundamentals Module 7 Intrusion Detection Topics Fundamentals Network IDS Snort Host-based IDS


slide-1
SLIDE 1

Network Security Fundamentals

Security Training Course

  • Dr. Charles J. Antonelli

The University of Michigan 2013

slide-2
SLIDE 2

Network Security Fundamentals

Module 7 Intrusion Detection

slide-3
SLIDE 3

Topics

  • Fundamentals
  • Network IDS
  • Snort
  • Host-based IDS
  • Tripwire

3 04/13 cja2013

slide-4
SLIDE 4

Fundamentals

slide-5
SLIDE 5

Intrusion Detection

  • Location
  • Network-based (NIDS)
  • Host-based (HIDS)
  • Action
  • Detection

 Only alerts

  • Prevention

 Performs some reactive action  IPS (NIDS + prevention)  HIPS (HIDS + prevention)

5 04/13 cja2013

slide-6
SLIDE 6

NIDS

  • Change the way you think about NIDS
  • By itself, no direct impact on C.I.A.

 you do!

  • IDS is a piece of network security monitoring
  • Intrusion is a misnomer
  • Detects network traffic that has some property of an

attack

  • IDS thinks in these units, so should you when thinking

about IDS

6 04/13 cja2013

slide-7
SLIDE 7

Traditional CIDF model

  • Event (E) box
  • Collect data

 sniff packets from the wire  OS shim (HIDS)

  • Analysis (A) box
  • analyze data from E box
  • Countermeasure (C) box
  • prevention, blocking
  • Data storage (D) box
  • alerting mechanism, log storage

7 04/13 cja2013

slide-8
SLIDE 8

Traditional CIDF model

from “Insertion, Evasion, and Denial of Service: Eluding Network Intrusion Detection” Ptacek & Newsham

8 04/13 cja2013

slide-9
SLIDE 9

Sniffing

  • E box
  • Passive
  • Sniffs network packets

 “smart” tcpdump (or Ethereal)  No cost to the network

  • Sniffing modes
  • Span port
  • Tap

9 04/13 cja2013

slide-10
SLIDE 10

Sniffing

  • Usually in conjunction with some operating

system or hardware tweaks

  • fast BPF

 no copies from kernel -> userland

  • In 2013 ~1+ GB/s continues to be the limit
  • Traffic mangling hacks
  • Aggregate
  • Separate 1GB+

 Hash network input to a bank of IDS

10 04/13 cja2013

slide-11
SLIDE 11

Sniffer Placement

  • In front of a firewall
  • More information

 Too much?

  • Do you care about the anklebiters?
  • Behind a firewall
  • Less information

 More useful?

  • Both?
  • You got that kind of time?
  • Rule of thumb:
  • Closest to asset you’re trying to protect

11 04/13 cja2013

slide-12
SLIDE 12

Analysis

  • The goal of the NIDS is to surmise what the end

host will process at each network layer and look for some indication of intrusion

  • A box
  • This is where the magic happens
  • Session tracking at each network layer passed

up the stack

  • MAC addresses

 usually ignored

  • IP defragmention
  • TCP session reassembly
  • Application layer deobfuscation

12 04/13 cja2013

slide-13
SLIDE 13

Layered detection

13

alert raw packets

IP normalization TCP session tracking URL de-obfuscation attack detection

04/13 cja2013

slide-14
SLIDE 14

Signature based rules

  • Statically analyze network traffic for

known intrusions

  • For instance (look familiar?)

GET /awstats?configdir=|cmd

14 04/13 cja2013

slide-15
SLIDE 15

Signature based rules

  • A (pseudocode) rule for this might be:

if (url contains “awstats?configdir=|”) alert()

  • Doesn’t matter where the awstats binary is

located on the web server

  • Don’t care what the command is, just that

the first character of the value is a pipe

  • Looking for the vulnerability, not the exploit

15 04/13 cja2013

slide-16
SLIDE 16

IP Fragmentation

Flags = Reserved | DF | MF

16 04/13 cja2013

slide-17
SLIDE 17

IP fragmentation

  • IP packet divided into chunks if some

MTU over the traversed route is too small

  • End host reassembles packets
  • NIDS must also reassemble packet
  • IP protocol allows overlapping fragments
  • Different OSs reassemble fragments

differently

  • How will the NIDS know whether to favor

new or old data?

17 04/13 cja2013

slide-18
SLIDE 18

2 overlapping IP fragments

18

GET awstats?configdir=|

?blah=blahblcmd

  • ffset 20
  • ffset 44
  • ffset 32
  • ffset 57

Does the NIDS use “?configdir=|” or “?blah=blahbl”? (offset is 20 because of the prepended TCP header)

04/13 cja2013

slide-19
SLIDE 19

Overlapping IP fragments

  • A few options
  • Alert on tiny fragments

 Attacker can use bigger fragments

  • Reassemble both ways

 Slow, can lead to DoS condition

  • Passively fingerprint the end-host

 Can make an educated guess which way it will reassemble

  • Alert on overlapping fragments

19 04/13 cja2013

slide-20
SLIDE 20

Other network games

  • Out-of-order packets
  • NIDS has to cache packets until reassembled

 How long?

  • Old packets
  • Overlap TCP segments
  • Same concept as IP fragmentation
  • Low TTL games
  • See Ptacek & Newsham paper
  • Dugsong’s fragroute for an implementation

20 04/13 cja2013

slide-21
SLIDE 21

Other network games

  • Most network ambiguities are solved
  • Reasonably permissive TCP/IP stack

 aggressive timeouts to avoid DoS

  • Do not accept data until ACKed
  • Alert on any obvious anomalies
  • UDP remains a problem

 connection-less

21 04/13 cja2013

slide-22
SLIDE 22

Application layer

  • Quoth the RFCs: be liberal in what you accept and strict

with what you send

  • Sometimes too liberal, especially in a hostile

environment

  • URL obfuscation
  • Telnet escape codes (in FTP too)
  • (MS)RPC fragmentation
  • DNS compression
  • etc etc etc
  • Ever read an RFC?
  • Vendors haven’t

$ wc –l rfc* 6267750

22 04/13 cja2013

slide-23
SLIDE 23

Detection

  • Majority of vendors
  • Heuristics register interest in sessions (TCP)
  • r types of packets (UDP, IP, et al) or

application protocols (http, rpc, dns, et al)

  • Dispatcher iterates over ruleset or executes

pseudocode  Application level parsing if applicable

  • Alert if evaluation for intrusion passes

23 04/13 cja2013

slide-24
SLIDE 24

Detection

  • IDS typically alerts on
  • Attacks

 well-formed intrusion attempts  DoS

  • Probes

 portscans, hostscans

  • Anomalies

 packet floods  bizarre protocol behavior (more later)

  • Policy violations

 RFC 1918 addresses  p2p traffic

24 04/13 cja2013

slide-25
SLIDE 25

Detection

  • Common methodologies
  • I saw XYZ
  • I saw A XYZs in B seconds
  • I didn’t see XYZ where I expected to

25 04/13 cja2013

slide-26
SLIDE 26

Signature vs anomaly

  • Signature
  • Does this network traffic match a known,

well-formed pattern of a particular attack?  GET /awstats?configdir=|cmd  Indicative of a particular attack method or the actual vulnerability?

  • Writing good signature rules is an art

26 04/13 cja2013

slide-27
SLIDE 27

Signature vs anomaly

  • Anomaly detection
  • Does this seem “wrong”?

 Suspect number of SYNs  Really long URL

GET /blah.ida? AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA[Ax240]=x HTTP/1.1

 “Protocol lint”

27 04/13 cja2013

slide-28
SLIDE 28

Alerts

  • Alerts stored
  • Correlated
  • Throttled
  • Analyst mines alert data
  • Response
  • Easiest way to render a NIDS useless is

to flood the alerting mechanism (D box)

  • Admin misses the real attack in the

avalanche of alerts

28 04/13 cja2013

slide-29
SLIDE 29

Alerts

  • CVE – Common Vulnerabilities Exposure
  • http://cve.mitre.org
  • Dictionary, not a database
  • Common names for vulnerabilities

 Alerts linked with CVE entries  Solves the AV naming problem

CVE-2005-0116 CVE-2005-0116 Description AWStats 6.1, and other versions before 6.3, allows remote attackers to execute arbitrary commands via shell metacharacters in the configdir parameter.

29 04/13 cja2013

slide-30
SLIDE 30

Countermeasures

slide-31
SLIDE 31

Countermeasures

  • Manual
  • Block with firewall/router filter rules
  • Automated
  • TCP RSTs / UDP port unreachable

 Race condition

  • Inline blocking

 More on this later

  • All of these are temporary!
  • Buy time to do proper investigation

31 04/13 cja2013

slide-32
SLIDE 32

Snort

  • Free
  • Wait 30 days for the free rules
  • Excellent way to cut your teeth
  • Rule based rather than a language
  • One line per rule
  • Syntax supported by most vendors
  • Official rules at http://www.snort.org/vrt/
  • User contributed rules

 http://www.emergingthreats.net/

  • Excellent documentation at http://www.snort.org/docs/

32 04/13 cja2013

slide-33
SLIDE 33

Snort

  • Preprocessors
  • Handles things rules can’t

 TCP state machine

» portscan and hostscan

 URL deobfuscation  Interfaces with rules

  • Alerts
  • Output in a variety of formats
  • ASCII, syslog, database, OPSEC, etc
  • Lots of open source add-ons
  • SGUIL console

33 04/13 cja2013

slide-34
SLIDE 34

Snort components

  • http://www.snort.org/snort-downloads
  • Sources, Binaries
  • http://s3.amazonaws.com/snort-org/www/assets/166/

snort_manual.pdf

  • How to write Snort rules and run Snort
  • http://www.snort.org/snort-rules
  • VRT Certified Rules

 Official Snort Ruleset

  • Subscription required for immediate access
  • Registration required for 30-day delayed access

34 04/13 cja2013

slide-35
SLIDE 35

Lab: Get and install Snort

  • http://www.snort.org/login
  • Register
  • http://www.snort.org/snort-rules
  • Get VRT rules for registered users

35 04/13 cja2013

slide-36
SLIDE 36

Lab: Install Snort

  • 1. Snort is pre-installed in the lab environment
  • 2. Set Snort’s network interface
  • sudo vi /etc/sysconfig/snort
  • Set INTERFACE to your correct network interface

04/13

cja 2013

36

slide-37
SLIDE 37

Lab: Run Snort

  • Popular arguments
  • v
  • utput headers to console
  • d
  • utput packet data too
  • e
  • utput layer 2 header too
  • l d

log packets to directory d

  • h a

home network is a

  • b

tcpdump log to single file

  • c c

config file c (nids mode)

  • r f

read packets from file f

  • i i

read packets from interface i

04/13 37 cja2013

slide-38
SLIDE 38

Lab: Run Snort

  • As a sniffer

snort –I lo –v [–d –e]

  • As a logger

snort –i lo –v [-d –e] [–b|-h] –l ./log

  • As a NIDS

snort –i lo –v [-d –e] –c /etc/snort/snort.conf –A console –k none

  • As a service

sudo service snortd start 38 04/13 cja2013

slide-39
SLIDE 39

Lab: Run Snort

  • Try a scan
  • sudo nmap –sV –O localhost
  • Try a trigger: browse to
  • http://www.umich.edu/~cja/HNS10/awstats.pl?

39 04/13 cja2013

slide-40
SLIDE 40

Lab: Run Snort

  • Notes
  • ^C may not stop snort until it sees a packet

 Ping the local interface in another window  Or ^Z then kill -9 %

  • –k none ignores packet checksum errors

40 04/13 cja2013

slide-41
SLIDE 41

Snort rules 101

  • header (options)
  • Header
  • alert tcp any any -> any any

 action  protocol  source address/port  “->”  destination address/port

41 04/13 cja2013

slide-42
SLIDE 42

Snort rules 101

  • Options
  • Where the actual processing is performed
  • msg: “this is an alert”; sid:1000; rev:1; flow:

to_server,established;  msg – alert string  sid – Snort ID, unique per alert  rev – revision of the rule  flow - only matches data sent from the initiator of the established TCP session

42 04/13 cja2013

slide-43
SLIDE 43

Snort rules 101

  • Payload options
  • content – matches a string in the packet

 content: “USER root”;  “|” delimits binary data

» content: “|00 00 00|”;

 nocase; modifier

  • uricontent – just like content, but is deobfuscated

 uricontent: “evil”;  matches “GET /%65vil”

43 04/13 cja2013

slide-44
SLIDE 44

Snort rules 101

  • Payload options
  • pcre – match Perl regular expression

 pcre: “/joe[^\r\n]\*cool/Ui”; » Pattern modifiers: ~ U: ungreedy match ~ i: ignore case

  • Multiple payload options in one rule

 Implicit logical “and”

44 04/13 cja2013

slide-45
SLIDE 45

Snort rules 101

  • Let’s look at a few rules

45 04/13 cja2013

slide-46
SLIDE 46

Lab: Snort rules

  • Write a rule to detect the awstats exploit
  • Attack is a string of the form

http://localhost/cgi-bin/awstats.pl?configdir=|blah

  • Put your rule in rules/local.rules
  • Look at other rules for examples

46 04/13 cja2013

slide-47
SLIDE 47

Official Snort rule

  • <>

47 04/13 cja2013

slide-48
SLIDE 48

Some problems with Snort

  • Without a preprocessor
  • No way to say “I didn’t see XYZ”
  • No way to correlate non-adjacent events
  • Rule syntax is not Turing complete
  • You could argue this, but it still doesn’t

“feel” like a language

  • 0day rules aren’t free anymore

48 04/13 cja2013

slide-49
SLIDE 49

IDS Issues

slide-50
SLIDE 50

IDS sucks

"Here's my Everything's Okay Alarm. This will sound every 3 seconds unless something isn't okay. It can't be turned off, but it does break easily." 50 04/13 cja2013

slide-51
SLIDE 51

Accepts arbitrary input

  • Like any other complex system that

accepts input, NIDS are subject to attack

  • Classic programming errors

 BlackIce – March 2004

» Witty worm not so funny

 Snort has had numerous remotely exploitable attacks

51 04/13 cja2013

slide-52
SLIDE 52

Attacking the CIDF model

from “Insertion, Evasion, and Denial of Service: Eluding Network Intrusion Detection” Ptacek & Newsham

52 04/13 cja2013

slide-53
SLIDE 53

False alarms

  • False positives
  • Fallacy rate

 Test is 99.9% accurate  10,000 evaluations means 10 false positives

  • False negatives
  • Just plain misses stuff

53 04/13 cja2013

slide-54
SLIDE 54

Tuning

  • We are constantly being attacked
  • An untuned IDS is not worth running
  • An untuned IDS is not worth running
  • Only you know your environment
  • Background noise

 Old worms  Wide-scale probes

  • Try running some old SNORT rules to see

what I mean

54 04/13 cja2013

slide-55
SLIDE 55

Dealing with false positives

  • Turn on your IDS for the first time, and you’ll be

inundated with alerts

  • Find attacks you just don’t care about
  • Old attacks, you’re patched
  • Scans
  • Turn them off
  • Turn everything off
  • Turn on things you’re interested in
  • Like a firewall

55 04/13 cja2013

slide-56
SLIDE 56

Encryption

  • After key exchange, IDS misses
  • SSH
  • IPSEC
  • SSL

 https://victim/awstats/?configdir=|cmd  SSL accelerators  Give your IDS the keys (!)

56 04/13 cja2013

slide-57
SLIDE 57

Packet loss

  • Drops packets
  • Misses part of an attack
  • Session desynchronized for a period
  • Quoth Paxson: 30% of Internet

connections are asymmetric

  • Not too much of a problem on leaf networks

57 04/13 cja2013

slide-58
SLIDE 58

Signature development

  • How soon after a vulnerability goes public

does the vendor (or community) release rules?

  • They don’t have special information you

don’t

  • Reverse engineering patches

 in the case of “specially crafted” or “malformed”

  • Timeframe is usually measured in hours

 too late?

58 04/13 cja2013

slide-59
SLIDE 59

IDS rocks

  • Is IDS dead?
  • No, market research companies are dead

 Just kidding

  • Is it hopeless?
  • No, as long as you understand the limits
  • Policy
  • Inverse firewall rules
  • Better than tcpdump

59 04/13 cja2013

slide-60
SLIDE 60

Evaluating an IDS

  • Very, very competitive market
  • Read reviews
  • Pounds of salt
  • How fast can your NIDS ignore packets?
  • Test them yourself
  • Run exploits in your own production environment
  • Tcpreplay
  • Vulnerability scans?
  • Number of alerts is meaningless
  • Anomaly detection doesn’t map well
  • Neither does CVE
  • Use what you understand and like!

60 04/13 cja2013

slide-61
SLIDE 61

IPS

  • Intrusion prevention
  • Inline NIDS

 “Bump on the wire”

  • Alerts cause traffic to be blocked

 Drop this packet only  Drop packets from this host for some time

  • Has a direct effect on availability

61 04/13 cja2013

slide-62
SLIDE 62

IPS

  • You must carefully consider the

implications of IPS

  • Attacker spoofs malicious UDP packets from

*.root-servers.net

 Game over

62 04/13 cja2013

slide-63
SLIDE 63

Future of IDS

  • Smarter correlation
  • Attack properties -> actual attack
  • Storing earlier packets
  • “Packet TIVO”
  • Flow-based
  • Networks are getting too fast
  • Better at anomaly detection
  • Arbor Networks, etc
  • IPv6

63 04/13 cja2013

slide-64
SLIDE 64

Host-based IDS

slide-65
SLIDE 65

Host Based IDS (HIDS)

  • Network layer
  • Not vulnerable to obfuscation games
  • HIDS sees exactly what the application layer

sees

  • Library proxy
  • Entercept/Cisco CSA/etc
  • Did you really get every one?

 Multiple kernel entry points in Windows  Hundreds of ways to execute a program

65 04/13 cja2013

slide-66
SLIDE 66

Windows NT Architecture

04/13 66 cja2013

slide-67
SLIDE 67

HIDS

  • Behavioral
  • Behavior is learned
  • Has this program ever executed cmd.exe before?
  • Has it ever generated network traffic to this host?
  • Explicitly specified policies
  • Provos’ “syscall shim”

 systrace

  • Mandatory access control policy implementation

 SELinux

67 04/13 cja2013

slide-68
SLIDE 68

HIDS

  • Binary checksums
  • Tripwire
  • Log aggregators can take HIDS & NIDS

input

  • Correlate your own events
  • HIDS are “push”, NIDS are “pull”
  • Have to manually deploy HIDS
  • NIDS see everything

68 04/13 cja2013

slide-69
SLIDE 69

Tripwire

  • HIDS tool
  • Initially creates hashes of all stored files in a database
  • Subsequently compares stored hashes to files and

reports any changes

  • Configuration
  • twcfg.txt - general configuration
  • twpol.txt - policy: what files to monitor, what file attributes to

monitor for change, what to do if changes are detected  As shipped, monitors a large set of standard files  You will want to modify this file for your site

  • Security
  • Site passphrase - encrypts and signs Tripwire files
  • Local passphrase - needed to run Tripwire

69 04/13 cja2013

slide-70
SLIDE 70

Tripwire lab

  • Install
  • cd /usr/local/lab/tripwire
  • sudo ./INSTALL.sh
  • File /tmp/victim created for Tripwire to trip over later
  • Configure
  • sudo tripwire-setup-keyfiles

 Create passphrases when prompted

  • Signs and encrypts the Tripwire configuration and policy files

 Enter passphrases when prompted

  • Initialize database
  • sudo tripwire --init

 Enter passphrase when prompted

  • Creates the encrypted database

70 04/13 cja2013

slide-71
SLIDE 71

Tripwire lab

  • Check integrity -- should show no changes
  • sudo tripwire --check

 Report sent to standard output and saved as *.twr in report directory

  • Change something and re-check integrity -- should show change
  • Change something about /tmp/victim
  • sudo tripwire --check

 Shows changes

  • sudo ./Report

 Shows all generated reports

» File name reflects date and time file was generated

  • sudo ./Report report.twr

 Shows report report.twr

71 04/13 cja2013

slide-72
SLIDE 72

References

  • Stefano Zanero, “Benchmarking IDS,” BlackHat 2006.

http://www.blackhat.com/presentations/bh-federal-06/BH-Fed-06-Zanero.pdf (accessed April 2010)

  • NSS IDS/IPS reviews http://www.nss.co.uk/
  • Thomas Ptacek and Timothy Newsham, “Insertion, Evasion, and Denial of Service: Eluding Network Intrusion

Detection,” Secure Networks, 1998. http://insecure.org/stf/secnet_ids/secnet_ids.pdf (Accessed April 2010)

  • fragroute http://www.monkey.org/~dugsong/fragroute/ (accessed April 2010)
  • Snort http://www.snort.org/ (accessed April 2010)
  • Martin Roesch, “Snort - Lightweight Intrusion Detection for Networks,” 13th LISA Conference, pp. 229-238,

1999. http://www.usenix.org/event/lisa99/full_papers/roesch/roesch_html/ (accessed April 2010)

  • NFR http://www.nfr.net/
  • ISS http://www.iss.net/
  • Niels Provos, “Systrace - Interactive Policy Generation for System Calls.”

http://www.citi.umich.edu/u/provos/systrace/ (accessed April 2010)

  • Loscocco, P. and S. Smalley, “Integrating Flexible Support for Security Policies into the Linux Operating

System,” Proceedings of the FREENIX Track, Usenix Technical Conference, June 2001.

72 04/13 cja2013