Lightweight Verification of Array Indexing

Slides:



Advertisements
Similar presentations
Why Have The OSGi Specifications Been Based On Java Technology ? By Peter Kriens, CEO aQute OSGi Technology Officer
Advertisements

Static Analysis for Security
De necessariis pre condiciones consequentia sine machina P. Consobrinus, R. Consobrinus M. Aquilifer, F. Oratio.
Modular and Verified Automatic Program Repair Francesco Logozzo, Thomas Ball RiSE - Microsoft Research Redmond.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Identity and Equality Based on material by Michael Ernst, University of Washington.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
A Randomized Dynamic Program Analysis for Detecting Real Deadlocks Koushik Sen CS 265.
1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki PSWLAB Generalized Symbolic Execution for Model Checking and Testing.
Preventing bugs with pluggable type checking Michael D. Ernst University of Washington Object x)
Recap from last time Saw several examples of optimizations –Constant folding –Constant Prop –Copy Prop –Common Sub-expression Elim –Partial Redundancy.
1 8. Safe Query Languages Safe program – its semantics can be at least partially computed on any valid database input. Safety is tied to program verification,
Houdini: An Annotation Assistant for ESC/Java Cormac Flanagan and K. Rustan M. Leino Compaq Systems Research Center.
1 A Modular Checker for Multithreaded Programs Cormac Flanagan HP Systems Research Center Joint work with Shaz Qadeer Sanjit A. Seshia.
CS527: (Advanced) Topics in Software Engineering Overview of Software Quality Assurance Tao Xie ©D. Marinov, T. Xie.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
Extended Static Checking for Java  ESC/Java finds common errors in Java programs: null dereferences, array index bounds errors, type cast errors, race.
Towards Automatic Verification of Safety Architectures Carsten Schürmann Carnegie Mellon University April 2000.
Applications of extended static checking K. Rustan M. Leino Compaq SRC K. Rustan M. Leino Compaq SRC Systems Research Center Invited talk, SAS’01, Paris,
User-defined type checkers for error detection and prevention in Java Michael D. Ernst MIT Computer Science & AI Lab
EE 422C Day 2 Java, Eclipse. Copyright Pearson Education, 2010 Based on slides bu Marty Stepp and Stuart Reges from
Demo of Scalable Pluggable Types Michael Ernst MIT Dagstuhl Seminar “Scalable Program Analysis” April 17, 2008.
Extended Static Checking for Java Cormac Flanagan Joint work with: Rustan Leino, Mark Lillibridge, Greg Nelson, Jim Saxe, and Raymie Stata.
How analysis can hinder source code manipulaton And what to do about it Michael Ernst University of Washington.
Extended Static Checking for Java Cormac Flanagan Joint work with: Rustan Leino, Mark Lillibridge, Greg Nelson, Jim Saxe, and Raymie Stata Compaq Systems.
Static Resolution of Implicit Control Flow for Reflection and Message-Passing Paulo Barros, René Just, Suzanne Millstein, Paul Vines, Werner Dietl, Marcelo.
Secure Programming with Static Analysis Brian Chess, Ph.D.
Preventing bugs with pluggable type-checking Michael Ernst MIT
Jeremy Nimmer, page 1 Automatic Generation of Program Specifications Jeremy Nimmer MIT Lab for Computer Science Joint work with.
Data Structures I (CPCS-204) Week # 2: Algorithm Analysis tools Dr. Omar Batarfi Dr. Yahya Dahab Dr. Imtiaz Khan.
Language-Based Security: Overview of Types Deepak Garg Foundations of Security and Privacy October 27, 2009.
Topic 21 arrays - part 1 Copyright Pearson Education, 2010 Based on slides by Marty Stepp and Stuart Reges from "Should.
Chapter 4 (Part 3): Mathematical Reasoning, Induction & Recursion
Types for Programs and Proofs
Arrays (review) CSE 2011 Winter May 2018.
COP 3503 FALL 2012 Shayan Javed Lecture 15
GC 211:Data Structures Week 2: Algorithm Analysis Tools
More important details More fun Part 3
Input Space Partition Testing CS 4501 / 6501 Software Testing
Arrays 2/4 By Pius Nyaanga.
GC 211:Data Structures Algorithm Analysis Tools
CS 326 Programming Languages, Concepts and Implementation
CSE 116/504 – Intro. To Computer Science for Majors II
Bell Work 9/15/17 Solve the Inequalities for x and give two possible solutions. (what are some numbers that would work for x?) 1. 2
Solving Linear Arithmetic with SAT-based MC
CBCD: Cloned Buggy Code Detector
Lecture 22 Complexity and Reductions
A Test Case + Mock Class Generator for Coding Against Interfaces
Trust, but Verify Two-Phase Typing for Dynamic Languages
Jared Davis CyberTrust Meeting March 1, 2006
High Coverage Detection of Input-Related Security Faults
Testing Recap Testing can find problems, but cannot prove your program works Since exhaustive testing is impossible, select test cases with maximum likelihood.
CodePeer Update Arnaud Charlet CodePeer Update Arnaud Charlet
Logical architecture refinement
Aspect Validation: Connecting Aspects and Formal Methods
CSE341: Programming Languages Section 1
CodePeer Update Arnaud Charlet CodePeer Update Arnaud Charlet
GC 211:Data Structures Algorithm Analysis Tools
Arrays We often want to organize objects or primitive data in a way that makes them easy to access and change. An array is simple but powerful way to.
Searching: linear & binary
Coding Concepts (Data- Types)
Language-based Security
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
CS210- Lecture 3 Jun 6, 2005 Announcements
Estimating Algorithm Performance
1.6 Absolute Value Equations and Inequalities
Presentation transcript:

Lightweight Verification of Array Indexing Martin Kellogg*, Vlastimil Dort**, Suzanne Millstein*, Michael D. Ernst* * University of Washington, Seattle ** Charles University, Prague

The problem: unsafe array indexing In unsafe languages (C): buffer overflow! In managed languages (Java, C#, etc.): exception, program crashes

The state of the art Strength of guarantees Practical for developers

The state of the art Coq KeY Clousot Strength of guarantees Practical for developers

The state of the art Coq KeY Clousot Strength of guarantees Coverity FindBugs Practical for developers

The Index Checker (this talk) The state of the art Coq KeY Clousot The Index Checker (this talk) Strength of guarantees Coverity FindBugs Practical for developers

Problems with complex analyses false positives annotation burden complex analyses are hard to predict

Problems with complex analyses false positives bounds checking is hard → complex analysis complex analysis → harder to implement harder to implement → more false positives annotation burden complex analyses are hard to predict

Problems with complex analyses false positives bounds checking is hard → complex analysis complex analysis → harder to implement harder to implement → more false positives annotation burden complex analysis → complex annotations complex analyses are hard to predict

Problems with complex analyses false positives bounds checking is hard → complex analysis complex analysis → harder to implement harder to implement → more false positives annotation burden complex analysis → complex annotations complex analyses are hard to predict

Fundamental problem is complex analyses! Insight: Fundamental problem is complex analyses!

Cooperating simple analyses Solve all three problems:

Cooperating simple analyses Solve all three problems: simpler implementation → fewer false positives

Cooperating simple analyses Solve all three problems: simpler implementation → fewer false positives simpler abstractions → easier to write annotations

Cooperating simple analyses Solve all three problems: simpler implementation → fewer false positives simpler abstractions → easier to write annotations simpler analysis → simpler to predict

Proving an array access safe T[] a = …; int i = …; ... a[i] ... We need to show that: i is an index for a

Proving an array access safe T[] a = …; int i = …; ... a[i] ... We need to show that: i is an index for a i ≥ 0 i < a.length Point out that splitting this up is one of the key insights into actually doing reasonable type inference. Reasoning about both causes state explosion.

Proving an array access safe T[] a = …; int i = …; ... a[i] ... We need to show that: i is an index for a i ≥ 0 A lower bound on i i < a.length An upper bound on i Point out that splitting this up is one of the key insights into actually doing reasonable type inference. Reasoning about both causes state explosion.

A type system for lower bounds @LowerBoundUnknown int i ↑ ↑ i ≥ -1 @GTENegativeOne int i ↑ ↑ i ≥ 0 @NonNegative int i ↑ ↑ i ≥ 1 @Positive int i

A type system for lower bounds @LowerBoundUnknown int i ↑ ↑ i ≥ -1 @GTENegativeOne int i ↑ ↑ i ≥ 0 @NonNegative int i ↑ ↑ i ≥ 1 @Positive int i Note that this is a benefit of the approach – the

A type system for upper bounds if (i >= 0 && i < a.length) { a[i] = ... }

A type system for upper bounds if (i >= 0 && i < a.length) { a[i] = ... } i < a.length @LTLengthOf(“a”) int i

Type systems Linear inequalities i < j Minimum lengths a.length > 10 Negative indices | i | < a.length Lower bounds i ≥ 0 Equal lengths a.length = b.length Upper bounds i < a.length

Type systems Linear inequalities i < j Minimum lengths a.length > 10 Negative indices | i | < a.length Lower bounds i ≥ 0 Equal lengths a.length = b.length Upper bounds i < a.length

A type system for minimum array lengths if (a.length >= 3) { a[2] = ...; }

A type system for minimum array lengths if (a.length >= 3) { a[2] = ...; } a.length ≥ i T @MinLen(i) [] a

Evaluation Three case studies: Google Guava (two packages) JFreeChart plume-lib Comparison to existing tools: FindBugs, KeY, Clousot Note that plume-lib is quite well-tested (1/6th of LoC are tests)

Case Studies Guava JFreeChart plume-lib Total Lines of code 10,694 94,233 14,586 119,503 Bugs found 5 64 20 89 Annotations 510 2,938 241 3,689 False positives 138 386 43 567 Java casts 222 2,740 219 3,181 A couple of things to point out on this slide: false positive rate is WAY lower than Java’s existing type system; annotation burden is reasonable (~1 anno / 32 loc); about 1/7 of warnings are true positives (low, but not outrageous in production code).

Comparison to other tools: confirmed bugs Approach Types Bug finder Verif. w/ solver Abs. interpret. Tool Index Checker FindBugs KeY Clousot True Positives False Negatives Time (100k LoC) Not sure how to present this info….

Comparison to other tools: confirmed bugs Approach Types Bug finder Verif. w/ solver Abs. interpret. Tool Index Checker FindBugs KeY Clousot True Positives False Negatives Time (100k LoC) ~10 minutes ~1 minute cannot scale ~200 minutes Not sure how to present this info….

Comparison to other tools: confirmed bugs Approach Types Bug finder Verif. w/ solver Abs. interpret. Tool Index Checker FindBugs KeY Clousot True Positives 18/18 0/18 9/18 16/18 False Negatives 1/18 2/18 Time (100k LoC) ~10 minutes ~1 minute cannot scale ~200 minutes Not sure how to present this info….

Using the Index Checker Distributed with Checker Framework www.checkerframework.org

Contributions A methodology: simple, cooperative type systems An analysis: abstractions for array indexing An implementation and evaluation for Java Verifying the absence of array bounds errors in real codebases (and finding bugs in the process!)