Software Verification - Computer Science Department at … · 2020. 10. 19. · Software...

39
Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

Transcript of Software Verification - Computer Science Department at … · 2020. 10. 19. · Software...

Page 1: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

Software Verification(preview of COS 510 “Programming Languages”)

Andrew W. Appel

PrincetonUniversity

Page 2: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

Formal reasoningabout programs and programming languages

2

FunctionalProgramming

Proving your(functional)

programs correct

Page 3: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

ProvingHoare Logic

sound

Formal reasoningabout programs and programming languages

3

intro to

FormalLogic

FunctionalProgramming

Proving your(functional)

programs correct

Provingyour type

system sound

HoareLogic

Proving your(imperative)

programs correct

ImperativeProgramming

Typesystems

Specificationof programming

languages

Page 4: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

ProvingHoare Logic

sound

Which of these things do we doBy machine? With pencil+paper?

4

intro to

FormalLogic

FunctionalProgramming

Specificationof programming

languages

Proving your(functional)

programs correct

Provingyour type

system sound

HoareLogic

Proving your(imperative)

programs correct

ImperativeProgramming

Typesystems

Page 5: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

ProvingHoare Logic

sound

We can do all of theseBy machine! pencil+paper? Really?

5

intro to

FormalLogic

FunctionalProgramming

Specificationof programming

languages

Proving your(functional)

programs correct

Provingyour type

system sound

HoareLogic

Proving your(imperative)

programs correct

ImperativeProgramming

Typesystems

Page 6: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

ProvingHoare Logic

sound

COS 510: Machine-checked, formal reasoningabout programs and programming languages

6

intro to

FormalLogic

FunctionalProgramming

Specificationof programming

languages

Proving your(functional)

programs correct

Provingyour type

system sound

HoareLogic

Proving your(imperative)

programs correct

ImperativeProgramming

Typesystems

Page 7: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

EXAMPLE: LENGTH, APP

7

Page 8: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

8

Page 9: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

9

Page 10: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

10

Page 11: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

11

Page 12: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

12

Page 13: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

13

Page 14: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

14

Page 15: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

15

Page 16: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

16

Page 17: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

17

Page 18: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

18

Page 19: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

19

Page 20: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

20

Page 21: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

21

Page 22: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

22

Page 23: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

23

Page 24: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

24

Page 25: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

25

Page 26: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

26

Page 27: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

27

Page 28: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

28

Page 29: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

29

Page 30: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

Applications of Formal Methods

30

Page 31: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

31

Attacking a web server

Web ServerClient PC

for(i=0;p[i];i++)

search[i]=p[i];

URLs

Input in web forms

Crypto keys for SSL

etc.

this is a really long search term that overflows a buffer

Page 32: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

32

Attacking a web browser

Web Server

@ badguy.comClient PC

for(i=0;p[i];i++)

gif[i]=p[i];

HTML keywords

Images

Image names

URLs

etc.

www.badguy.com

Earn $$$ Thousands

working at home!

Page 33: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

33

Attacking everything in sight

The Internet

@ badguy.comClient device

E-mail client

PDF viewer

Web browser

Operating-system kernel

TCP/IP stack

Any application that ever sees input directly from the outside

Page 34: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

34

Solution: implement the outward-facing parts of

software without any bugs!

The Internet

@ badguy.comClient device

E-mail client

PDF viewer

Web browser

Operating-system kernel

TCP/IP stack

Any application that ever sees input directly from the outside

Page 35: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

In recent years, great progress in . . .

• Proved-correct optimizing C compiler (France)

• Proved-correct ML compiler (Sweden, Princeton)

• Proved-correct O.S. kernels (Australia, New Haven)

• Proved-correct crypto (Princeton NJ, Cambridge MA)

• Proved-correct distributed systems (Seattle, Israel)

• Proved-correct web server (Philadelphia)

• Proved-correct malloc/free library (Princeton, Hoboken)

35

Page 36: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

Automated verification in industry

Amazon

Microsoft

Intel

Facebook

Google

Galois, HRL, Rockwell, Bedrock, …

36

Page 37: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

Recent Princeton JIW / Sr. Thesis

• Katherine Ye ’16 verified crypto security

• Naphat Sanguansin ’16 verified crypto impl’n

• Brian McSwiggen ’18 verified B-trees

• Katja Vassilev ’19 verified dead-var elimination

• John Li ’19 verified uncurrying

• Jake Waksbaum ’20 verified Burrows-Wheeler

• Anvay Grover ’20 verified CPS-conversion

37

Page 38: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

38

ACM Conference on Computer and Communications Security 2017

’16 ’16

’81

Page 39: Software Verification - Computer Science Department at … · 2020. 10. 19. · Software Verification (preview of COS 510 “Programming Languages”) Andrew W. Appel Princeton University

Prerequisites for COS 510 if you’re an undergrad

1. COS 326 Functional Programming

2. Enjoy the proofs in COS 326

3. Get the form signed by Colleen Kenny-McGinley,

room 210 (one-stop shopping, all three signatures):

39