Finding Security Vulnerabilities in a Network Protocol Using Formal Verification Methods

51
Finding Security Vulnerabilities in a Network Protocol Using Formal Verification Methods Orna Grumberg Technion, Israel Joint work with Adi Sosnovich and Gabi Nakibly Tel-Aviv University, December 5, 2013 1

description

Finding Security Vulnerabilities in a Network Protocol Using Formal Verification Methods. Orna Grumberg Technion, Israel J oint work with Adi Sosnovich and Gabi Nakibly Tel-Aviv University, December 5, 2013. Motivation. - PowerPoint PPT Presentation

Transcript of Finding Security Vulnerabilities in a Network Protocol Using Formal Verification Methods

Page 1: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Finding Security Vulnerabilities in a Network Protocol Using Formal

Verification Methods

Orna GrumbergTechnion, Israel

Joint work with Adi Sosnovich and Gabi Nakibly

Tel-Aviv University, December 5, 2013 1

Page 2: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Motivation• Attacks on network protocols, taking

advantage of built-in vulnerabilities, are not easy to identify

– Rely on legitimate functionality of the protocol

– May involve only a small number of messages

– Identifying attacks is done mostly manually, by experts, in an ad hoc manner

Page 3: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Goals• Develop automatic methods for

identifying attacks in network protocols

• Using methods and tools for formal verification of software and hardware– Model checking

Page 4: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

4

Model Checking [CE81,QS82]

An efficient procedure that receives: A finite-state model describing a system A temporal logic formula describing a

property

It returns yes, if the system has the propertyno + Counterexample, otherwise

Page 5: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

5

Mutual Exclusion Example• Two process mutual exclusion with shared semaphore

• Each process has three states• Non-critical (N)• Trying (T)• Critical (C)

• Semaphore can be available (sem=1) or taken (sem=0) • Initially both processes are in the Non-critical state and

the semaphore is available --- N1 N2 S0

• S0 denotes sem=0• S1 denotes sem=1

Page 6: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Mutual Exclusion ExampleP = P1 || P2

Pi :: while (true) { if (vi == N) vi = T; else if (vi == T && sem=1)

{vi = C; sem=0;} else if (vi == C) {vi = N; sem=1;}

}

Initial state: (v1 == N, v2 == N, sem=0)6

Page 7: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

7

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M ╞ AG (C1 C2 )

The two processes are never in their critical states at the same time

The state with (C1 C2 ) is not reachable

Page 8: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

8

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M ╞ AG (C1 C2 )

S0

Page 9: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

9

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M ╞ AG (C1 C2 )

S1

Page 10: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

10

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M ╞ AG (C1 C2 )

S2

Page 11: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

11

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M ╞ AG (C1 C2 ) S3

Page 12: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

12

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M ╞ AG (C1 C2 )

S4 S0 … S3

Page 13: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

13

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M ╞ AG (T1 T2 )

The two processes are never in their trying states at the same time

Page 14: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

14

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M ╞ AG (T1 T2 )

Page 15: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

15

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M ╞ AG (T1 T2 )

Page 16: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

16

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M | AG (T1 T2 )

A violating state has been found

Page 17: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

17

Mutual Exclusion Example

N1N2S0

C1N2S1T1T2S0

N1T2S0T1N2S0

N1C2S1

T1C2S1C1T2S1

M | AG (T1 T2 )

Model checking returns a counterexample

Page 18: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Our goalsTo search for attacks using model checking

For this purpose, we define:• Model

– Represents the protocol’s behaviors– Includes an attacker with predefined

capabilities• Specification

– Specifies “suspect” states

Page 19: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Challenges• Building a model which is

– Sufficiently detailed: to enable identifying attacks based on the protocol's functionality

– Sufficiently reduced: feasible for model checking tools

• Write general specification to identify different kinds of attacks with different techniques

Page 20: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Advantages of our approach

• We do not need to define an attack, but only its possible outcome.

– Specifying suspect states requires less knowledge and efforts than defining an attack

– May enable finding new attacks, unknown by now

Page 21: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Routing in the Internet• How do packets get from A to B in

the Internet?

A BInternet

Page 22: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Routing in the Internet• Each router makes a local decision on

how to forward a packet towards B

A B

R1 R4

R2

R3

R6

R7

R5

R8

Page 23: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Research Focus - OSPF• We focused on the routing protocol

Open Shortest Path First (OSPF)

• OSPF is widely used for routing in the Internet– Finding attacks on OSPF is significant

• OSPF is a complex protocol– We may be able to derive insights from its

modeling to modeling of other network protocols

Page 24: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

OSPF• Each router compiles a database of the most

recent OSPF messages received from all routers in the network

A B

R1 R4

R2

R3

R6

R7

R5

R8

Originator List of neighbors

Links costs

r1 r4,r6,r2,r3

r2 r3,r1,r8 …… … …

database

network

Using this database a router obtains a complete view of the network topology

Page 25: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

OSPF• OSPF messages are flooded through the network

Originator

List of neighbors

Links costs

r6 r4,r1,r8 …

OSPF message M

A B

R1 R4

R2

R3

R6

R7

R5

R8

network

M

MM

M

M

M

M

M

Page 26: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

OSPF Attacks• The goal of an OSPF attacker is to advertise

fake messages on behalf of some other router(s) in the network.

Originator List of neighbors

Links costs

r5 r3,r8 …

fake OSPF message M

A B

R1 R4

R2

R3

R6

R7

R5

R8

network

M

Page 27: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

OSPF Attacks

A B

R1 R4

R2

R6

R7

R5

R8

A B

R1 R4

R2

R3

R6

R7

R5

R8

M

Routing path beforefrom A to B

R3Routing path afterfrom A to B

Page 28: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

OSPF Fight Back Mechanism

A B

R1 R4

R2

R6

R7

R5

R8

M

M

M

M

M

M

When a router receives a message in its own name that it didn't originate, it sends a fight back message to all its neighbors

The fight back message is supposed to revert the effect of the attack eventually

MR3

MMOriginat

orList of

neighbors

Links costs

r5 r3,r8 …

fake OSPF message - M

Page 29: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

OSPF Attacks• An attack is a run of the protocol that

creates a fake topology view for some routers in the network

• An attack is called persistent if the fake topology view remains in some routers' databases

• We are interested in finding persistent attacks

Page 30: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

OSPF Concrete Model• A fixed network topology• Router Model

– Models a legitimate router• Attacker Model

– Models a malicious router• can send any random message to any

random destination router• can ignore incoming messages.

Page 31: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

In our model:• Messages originated by the attacker are

marked with a special flag isFake

• This flag is not part of the OSPF standard, and legitimate routers do not make use of it

• This flag allows us to easily define the specifications for the model

Page 32: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

OSPF Concrete Model• Our formal model for OSPF is a finite

state machine with global states and transitions

• The model is a simplified version of OSPF, which includes the fight back mechanism

Page 33: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Specification• A global state is considered attacked if:

– Some router has a fake message in its database

– No message resides in any router's queue

• An attacked state defines the outcome of a successful persistent attack regardless of a specific attack technique

Page 34: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Model Checking• We implemented the model of OSPF in C ,

and used the Bounded Model Checking tool CBMC to find persistent attacks on OSPF

• A counterexample returned by CBMC is an attack

Page 35: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Example of Attacks on OSPFAttack #1

– The attacker (r3) originates a fake message:dest = r2, orig = r4

r0

r2

r1

r4

r3

Page 36: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Example of Attacks on OSPFAttack #2

• The attacker (r3) sends two fake messages:

• m1 = (dest = r4, orig = r1, sequence_number = 1)

m2 = (dest = r4, orig = r1, sequence_number = 2)

r0

r2

r1

r4

r31 2

1

1

2

22

2

Page 37: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Another demonstration of attack #2 on a different topology

r0

r2

r1

r4

r3

22

2

r5

2

r8

r7

r6

2

2

2

Page 38: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Concrete Model - Problems• state explosion problem

– Models that can be handled are very small in size and hence restricted in their topologies and functionality

– We would like to extend our search for attacks to larger and more complex topologies

Page 39: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Abstract Model• We are interested in general attacks

– insensitive to most of the topology's details

– can be applied in a family of topologies

• We define an abstract model which:– represents a family of concrete models– under-approximates each member in the

family.

Page 40: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Abstract Model• The abstract model consists of an abstract

topology and an abstract protocol

• We defined several levels of abstract components

• An abstract topology may also contain some un-abstracted routers

• The attacker is always an un-abstracted router

Page 41: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Main Property of the Abstract Model

• If an attack is found on an abstract network, then there is a corresponding attack on each one of the concrete networks represented by it.

Page 42: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Example of an Abstract Attack on OSPF in the Abstract Model

– The attacker sends a fake message with:dest=2, orig=4

a0

r2

r1

r4

r3

a1a2

Page 43: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Example of an attack in a concrete instantiation of the abstract model

a0

r2

r1

r4

r3

a1a2

Page 44: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Example of a similar attack on another possible instantiation of the abstract model

a0

r2

r1

r4

r3

a1a2

Page 45: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Examples of attacks on OSPF in the abstract model

• Attack # 2

– The attacker (designated router) originates a fake message on behalf of sr1:m = (dest = sr5; orig = sr1; seq = 1; isFake = T)

DR

Page 46: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Correctness of Our Method• Lemma

– For each abstract transition on the abstract topology, there is a corresponding concrete finite run on each matching concrete topology

Abstract run

Matching concrete run

Page 47: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Correctness of Our Method

• Theorem– An abstract attack found on an abstract

topology TA, has a corresponding attack on each matching concrete topology TC.

Page 48: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

• Exposed OSPF vulnerabilities:• a message is opened only by its destination• the flooding procedure does not flood a

message back to its source– As a result, a fake message in the name

of router r might be sent through r

– If the attacker plays the role of a designated router, then by ignoring messages it can stop message flooding, including fight back messages

Page 49: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Conclusion• We automatically found attacks on small

concrete models

• We automatically found general attacks on small abstract models

• The general attacks are applicable to huge networks, with possibly thousands of routers– No model checker can be applied directly to

such networks

Page 50: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Conclusion• We developed a novel technique for

parameterized networks suitable for finding a counterexample (in our case an attack) on each member of the family

Page 51: Finding Security Vulnerabilities in a Network Protocol Using  Formal Verification Methods

Thank You

51