Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli,...

81
VigNAT: A Formally Verified NAT Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea

Transcript of Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli,...

Page 1: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

VigNAT:A Formally Verified NAT

Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea

Page 2: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

2

Formally verify a stateful NF

with competitive performance

and reasonable human effort

Page 3: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

3

Formally verify a stateful NF

with competitive performance

and reasonable human effort

Page 4: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Formally verify a stateful NF

with competitive performance

and reasonable human effort

4

Page 5: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Software Network Functions: Pros and Cons

● Everywhere○ OpenWRT/NetFilter, Click, RouteBricks

○ Vyatta, OpenVswitch, DPDK

● Flexibility, short time to market, but ...

5

Page 6: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Software Network Functions: Pros and Cons

● Everywhere○ OpenWRT/NetFilter, Click, RouteBricks

○ Vyatta, OpenVswitch, DPDK

● Flexibility, short time to market, but ...

● Bugs○ Packets of death, table exhaustion, denial of service

○ Cisco NAT, Juniper NAT, NetFilter, Windows ICS

○ Network outages already cost up to $700B/year 6

Page 7: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Testing: Easy but Incomplete

7

Page 8: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Testing: Easy but Incomplete

8

Page 9: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

9

Formal Verification: Complete but Expensive

Page 10: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

10

Formal Verification: Complete but Expensive——?——

Page 11: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Network Verification

S

D

11

Page 12: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Network Verification

S

D

CODE

12

MODEL

Page 13: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Network Verification ≠ NF Code Verification

S

D

CODE

13

Page 14: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

14

Bits Algebras

Human effort quick slow (infeasible)

Machine effort slow (infeasible) quick

How to Verify an NF (Before Vigor)?

Page 15: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

15

Bits Algebras

Human effort quick slow (infeasible)

Machine effort slow (infeasible) quick

How to Verify an NF (Before Vigor)?

Page 16: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

16

Bits Algebras

Human effort quick slow (infeasible)

Machine effort slow (infeasible) quick

How to Verify an NF (Before Vigor)?

Page 17: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

17

Bits Algebras

Human effort quick slow (infeasible)

Machine effort slow (infeasible) quick

How to Verify an NF (Before Vigor)?

Page 18: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Bits Algebras

Human effort quick high / infeasible

Machine effort slow (infeasible) low

Theorem Proving

18

Page 19: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Bits Algebras

Human effort quick high / infeasible

Machine effort slow (infeasible) low

Theorem Proving

Too complicated

19

[1] Klein, Gerwin, et al. "seL4: Formal verification of an OS kernel." Proceedings of the ACM SIGOPS 22nd symposium on Operating systems principles. ACM, 2009.

[2] Chen, Haogang, et al. "Using Crash Hoare logic for certifying the FSCQ file system." Proceedings of the 25th Symposium on Operating Systems Principles. ACM, 2015.

Page 20: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Bits Algebras

Human effort low high / infeasible

Machine effort high / infeasible low

Exhaustive Symbolic Execution (SymbEx)

20

Page 21: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Bits Algebras

Human effort low high / infeasible

Machine effort high / infeasible low

Exhaustive Symbolic Execution (SymbEx)

Credit to Jonas Wagner

Path Explosion

21

Page 22: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Bits Algebras

Human effort low high / infeasible

Machine effort high / infeasible low

Vigor

22

Page 23: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Bits Algebras

Human effort low high / infeasible

Machine effort high / infeasible low

Vigor

Plus runtime performance

23

Page 24: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Main Idea

24

● Split the code into two parts

● Verify each part separately

● Stitch the proofs — key challenge

Page 25: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Outline

● Problem Statement

● VigNAT Formal Proof

○ General Idea

○ Proof Stitching Example

● RFC Formalization

● Performance

25

Page 26: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Vigor: split code | verify parts | stitch proofs

26

CODE

Page 27: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Vigor: split code | verify parts | stitch proofs

27

Page 28: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Vigor: split code | verify parts | stitch proofs

28

Page 29: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Stateful code(data structures)

Stateless code(application logic)

29

Vigor: split code | verify parts | stitch proofs

Interface contracts

Page 30: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Interface contractsStateful code

(data structures)

30

Vigor: split code | verify parts | stitch proofs

Theorem Proving

Page 31: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Stateful code(data structures)

Stateless code(application logic)

31

Vigor: split code | verify parts | stitch proofs

Interface contracts

Page 32: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Stateful code(data structures)

Stateless code(application logic)

32

Vigor: split code | verify parts | stitch proofs

Interface contracts

ExhaustiveSymbolic Execution

Page 33: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Stateless code(application logic)

33

Vigor: split code | verify parts | stitch proofs

Symbolic models

ExhaustiveSymbolic Execution

Approximation (not trusted)

Page 34: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Symbolic models Stateless code

(application logic)

34

Vigor: split code | verify parts | stitch proofs

traces

Approximation (not trusted)

ExhaustiveSymbolic Execution

Page 35: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

35

Vigor: split code | verify parts | stitch proofs

traces

Interface contracts

Page 36: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Interface contracts

Vigor: split code | verify parts | stitch proofs

Vigor Validator

36

traces

Page 37: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Interface contractsStateful code

(data structures)Stateless code

(application logic)

Vigor: split code | verify parts | stitch proofs

Vigor Validator

37

traces

ExhaustiveSymbolic ExecutionTheorem Proving

Page 38: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Outline

● Problem Statement

● VigNAT Formal Proof

○ General Idea

○ Proof Stitching Example

● RFC Formalization

● Performance

38

Page 39: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Proof Stitching: SymbEx + Theorem Proving

● Stateful code: theorem proving● Stateless code: exhaustive symbolic execution

1. Use symbolic models — rough interpretations of contracts

● Symbolic models are written in C

2. Replay call traces in a proof checker to check contracts39

Page 40: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Example NF Codeif (!ring_full(r) && receive(&p) && p.port != 9)

ring_push_back(r, &p);

if (!ring_empty(r) && can_send()) {

ring_pop_front(r, &p);

send(&p);

}

40

Page 41: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Example NF Codeif (!ring_full(r) && receive(&p) && p.port != 9)

ring_push_back(r, &p);

if (!ring_empty(r) && can_send()) {

ring_pop_front(r, &p);

send(&p);

}

41

Page 42: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

if (!ring_full(r) && receive(&p) && p.port != 9)

ring_push_back(r, &p);

if (!ring_empty(r) && can_send()) {

ring_pop_front(r, &p);

send(&p);

}

42

Example NF Code

Page 43: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

For Each API Function ...

43

Symbolicmodel

Formal contract

Page 44: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Example: Formal Contractvoid ring_pop_front(struct ring* r, struct packet* p);r is not empty andp points to valid memory ———————————— r contains one packet less andp points to a packet and p->port ≠ 9

44

Formal contract

Page 45: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Example: Symbolic Modelvoid ring_pop_front(struct ring* r, struct packet* p) { FILL_SYMBOLIC(p, sizeof(struct packet), "popped_packet"); ASSUME(p->port != 9);}

45

Symbolicmodel

Page 46: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Example NF Codeif (!ring_full(r) && receive(&p) && p.port != 9)

ring_push_back(r, &p);

if (!ring_empty(r) && can_send()) {

ring_pop_front(r, &p);

send(&p);

}

46

Page 47: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Use Symbolic Modelsif (!ring_full(r) && receive(&p) && p.port != 9)

ring_push_back(r, &p);

if (!ring_empty(r) && can_send()) {

ring_pop_front(r, &p);

send(&p);

}

47

Symbolicmodel

Symbolicmodel

Symbolicmodel

Symbolicmodel

Page 48: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Execution Traceif (!ring_full(r) && receive(&p) && p.port != 9)

ring_push_back(r, &p);

if (!ring_empty(r) && can_send()) {

ring_pop_front(r, &p);

send(&p);

}

48

Page 49: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Execution Traceif (!ring_full(r); assume(r1 → true

ring_push_back(r, &p);

if (!ring_empty(r); assume(r1 → false

ring_pop_front(r, &p): after(p.port ≠ 9)

49

if (!ring_full(r) && receive(&p) && p.port != 9)

ring_push_back(r, &p);

if (!ring_empty(r) && can_send()) {

ring_pop_front(r, &p);

send(&p);

}

Page 50: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Over-Approximation Proofr1 = ring_full(r); assume(r1 == true);

ring_push_back(r, &p);

r2 = ring_empty(r); assume(r2 == false);

ring_pop_front(r, &p);

assert(p.port ≠ 9);

50

Page 51: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Over-Approximation Proofr1 = ring_full(r); assume(r1 == true);

ring_push_back(r, &p);

r2 = ring_empty(r); assume(r2 == false);

ring_pop_front(r, &p);

assert(p.port ≠ 9);

51

Formal contract

Page 52: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Over-Approximation Proofr1 = ring_full(r); assume(r1 == true);

ring_push_back(r, &p);

r2 = ring_empty(r); assume(r2 == false);

ring_pop_front(r, &p);

assert(p.port ≠ 9);

52

⊂(covers)

Formal contract

Symbolicmodel

Page 53: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Outline

● Problem Statement

● VigNAT Formal Proof

○ General Idea

○ Proof Stitching Example

● RFC Formalization

● Performance

53

Page 54: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Formalization of the NAT RFC

● Everything happens at packet arrival

● Abstract flow table summarizes history of previous interactions

● Packet arrival timestamps — the only source of time

54

Page 55: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

flowtable

Formalization of the NAT RFC

NATpacketpacket

flowtable

55

time

Page 56: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

flowtable

Formalization of the NAT RFC

NATpacketpacket

NAT

NAT

packet

packet

packet

packet

56

time

time

time

flowtable

flowtable

Page 57: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Formalization of the NAT RFC

{flowtablebefore, time, packetin} ➡ {flowtableafter, packetout}

NAT packet

57

packet

timeflowtable

flowtable

Page 58: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

packet

Formalization of the NAT RFC

58

time

update/create flow

expire_flows

forward/drop

flowtable

flowtable

Page 59: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Outline

● Problem Statement

● VigNAT Formal Proof

○ General Idea

○ Proof Stitching Example

● RFC Formalization

● Performance

59

Page 60: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

PerformanceNo-op(DPDK)

Unverified NAT(DPDK)

VigNAT(DPDK)

60

Linux NAT(NetFilter)

Page 61: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Performance

61

Latency ~20 μsec

No-op(DPDK)

Unverified NAT(DPDK)

VigNAT(DPDK)

Linux NAT(NetFilter)

5.13 μsec

5.03 μsec

4.63 μsec

Page 62: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

~20 μsec

Performance

Throughput 2.0Mpps

1.8Mpps 62

0.6Mpps

No-op(DPDK)

Unverified NAT(DPDK)

VigNAT(DPDK)

Linux NAT(NetFilter)

Latency 5.13 μsec

5.03 μsec

4.63 μsec

3.2Mpps

Page 63: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Human Effort (in Lines of Code)

Stateless code Stateful code(data structures)

Symbolic models Proofs of data structure library

800 1 000 400 + 325 (unvalidated DPDK)

23 000

63

Expect to reuse across many NFs

VigNAT Code Proof

Page 64: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Verification Friendliness of NF Code

● Low complexity○ No long/unbounded loops (except main loop)

● Well defined data structures

● Often implements widely adopted standards

64

Page 65: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Summary

● Vigor = symbolic execution + theorem proving

○ Stitching them is our primary contribution

● VigNAT is formally verified to comply with RFC 3022

○ Competitive performance

○ Tractable verification effort

65

Page 66: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

It is feasible now to build a stateful NF that have both

competitive performance andformally verified semantic properties

with reasonable effort 66

Interface contractsStateful code

(verified data structures)Stateless code

(application logic)

Vigor Validator

traces

ExhaustiveSymbolic ExecutionTheorem Proving

Page 67: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Additional material

67

Page 68: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Index

68

● Experimental setup● DPDK performance report● Future work● NAT RFC formalization● Related work● Plots● Stitching details● Proof Structure

Page 69: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Performance Experiment

● RFC 2544● Intel Xeon E5-2667 v2 @ 3.30 GHz● 32 GB of DRAM● 82599ES 10 Gbps

Tester

DUT

69index

Page 70: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Performance is comparable

<DPDK perf report>

70index

Page 71: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Future Work

● Certify more NFs○ bridge with mac-learning,○ DMZ

● Improve automation (to reduce the effort and TCB)○ Invariant induction○ Symbolic model selection/generation

● Support Concurrency● Full system verification (Vigor + CompCert + seL4 + …)

71index

Page 72: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

RFC 3022 Formalization

72index

Page 73: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Related work

73

● System software verificationseL4, CompCert, IronFleet, FSCQ, Beringer et al.

● Interoperability testing / protocol specificationMusuvathi et al., Bishop et al., Kuzniar et al., PIC

● Network configuration verification / testingSymNet {+NF testing}, BUZZ, Batfish, HSA, VeriFlow, NoD, Anteater, Panda et al., Cocoon, Xie et al.

● NF software verification : Dobrescu et al.index

Page 74: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Challenges

● Code

○ complexity from SymbEx viewpoint

○ unbounded number of events

○ arbitrary external interactions

● Formalize the RFC in machine readable language

● Integrate symbolic execution and theorem proving

74index

Page 75: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Latency

75index

Page 76: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Throughput

76index

Page 77: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Example: NF Code #define CAP 512int main() { struct packet p; struct ring *r = ring_create(CAP); if (!r) return 1; while(VIGOR_LOOP(1)) { loop_iteration_begin(&r); if (!ring_full(r)) if (receive(&p) && p.port != 9) ring_push_back(r, &p); if (!ring_empty(r) && can_send()) { ring_pop_front(r, &p); send(&p); } loop_iteration_end(&r); } return 0;} 77index

Page 78: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

loop_iteration_begin(&X) => []ring_full(&X) => truering_empty(&X) => falsecan_send() => truering_pop_front(&X, &{.port == y} -> &{.port == z}) => []——z != 9

#define CAP 512int main() { struct packet p; struct ring *r = ring_create(CAP); if (!r) return 1; while(VIGOR_LOOP(1)) { loop_iteration_begin(&r); if (!ring_full(r)) if (receive(&p) && p.port != 9) ring_push_back(r, &p); if (!ring_empty(r) && can_send()) { ring_pop_front(r, &p); send(&p); } loop_iteration_end(&r); } return 0;}

SymbEx→ Theorem Proving:Trace

78index

Page 79: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

loop_iteration_begin(&X) => []ring_full(&X) => truering_empty(&X) => falsecan_send() => truering_pop_front(&X, &{.port == y} -> &{.port == z}) => []——z != 9

SymbEx→ Theorem Proving:Replay

struct ring* arg1;struct packet arg2;

loop_invariant_produce(&(arg1));//@ open loop_invariant(_);bool ret1 = ring_full(arg1);//@ assume(ret1 == true);bool ret2 = ring_empty(arg1);//@ assume(ret2 == false);bool ret3 = can_send();//@ assume(ret3 == true);/*@ close packetp(&(arg2), packet((&(arg2))->port));@*/ring_pop_front(arg1, &(arg2));//@ open packetp(&(arg2), _);

//@ assert(arg2.port != 9);79index

Page 80: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

struct ring* arg1;struct packet arg2;

loop_invariant_produce(&(arg1));//@ open loop_invariant(_);bool ret1 = ring_full(arg1);//@ assume(ret1 == true);bool ret2 = ring_empty(arg1);//@ assume(ret2 == false);bool ret3 = can_send();//@ assume(ret3 == true);/*@ close packetp(&(arg2), packet((&(arg2))->port));@*/ring_pop_front(arg1, &(arg2));//@ open packetp(&(arg2), _);

//@ assert(arg2.port != 9);

SymbEx→ Theorem Proving:Replay

void ring_pop_front(struct ring* ...);Contract: ... andpacket satisfies packet_constraints_fp.

80index

Page 81: Katerina Argyraki, George Candea Arseniy Zaostrovnykh ... · Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, George Candea. 2 Formally verify a stateful NF with

Proof Structure VigNAT satisfies semantic properties

VigNAT satisfieslow-level properties

VigNAT stateless coderespects the

interface contracts

symbolic models are faithful to the

interface contracts

Stateful implementations behaves according to the

interface contracts

81index