• No results found

Applications of formal verification for secure Cloud environments at CEA LIST

N/A
N/A
Protected

Academic year: 2021

Share "Applications of formal verification for secure Cloud environments at CEA LIST"

Copied!
37
0
0

Loading.... (view fulltext now)

Full text

(1)

Applications of formal verification for secure Cloud

environments at CEA LIST

Nikolai Kosmatov

joint work with A.Blanchard, F.Bobot, M.Lemerre,. . .

(2)

Outline

Frama-C, a platform for analysis of C code

Verification of a Cloud hypervisor

Anaxagoros hypervisor and Virtual Memory Formal Verification

Results and discussion

Verification of a sandbox

The ZeroVM sandbox solution Formal verification

Results

(3)

Frama-C, a platform for analysis of C code

Outline

Frama-C, a platform for analysis of C code

Verification of a Cloud hypervisor

Anaxagoros hypervisor and Virtual Memory Formal Verification

Results and discussion Verification of a sandbox

The ZeroVM sandbox solution Formal verification

Results Conclusion

(4)

Frama-C, a platform for analysis of C code

Frama-C, a brief history

I 90’s: CAVEAT, Hoare logic-based tool for C code at CEA

I 2000’s: CAVEAT used by Airbus during certification process of the A380 (DO-178 level A qualification)

I 2008: First public releaseof Frama-C (Hydrogen)

I 2012: New Hoare-logic based pluginWPdeveloped at CEA LIST

I Today: Frama-C Sodium(v.11)

I Multiple projectsaround the platform

I A growing community of users. . . I and of plugin developers

(5)

Frama-C, a platform for analysis of C code

Frama-C at a glance

I AFramework forModular Analysis of C code

I Developed at CEA LIST and INRIA Saclay

I Released underLGPL license

I Kernel based on CIL [Necula et al. (Berkeley), CC 2002]

I ACSL annotation language

I Extensible plugin oriented platform

I Collaboration of analysesover same code

I Inter plugin communicationthrough ACSL formulas

I Adding specialized pluginsis easy

(6)

Frama-C, a platform for analysis of C code

ACSL: ANSI/ISO C Specification Language

I Based on the notion of contract, like in Eiffel, JML

I Allows users to specify functional propertiesof programs

I Allowscommunication between various plugins

I Independent from a particular analysis

I Manual at http://frama-c.com/acsl Basic Components

I First-order logic

I Pure C expressions

I C types +Z(integer) andR (real)

(7)

Frama-C, a platform for analysis of C code

Example: a C program annotated in ACSL

/∗@ r e q u i r e s n>=0 && \v a l i d( t + ( 0 . . n−1 ) ) ; a s s i g n s \n o t h i n g; e n s u r e s \r e s u l t != 0 <==> (\f o r a l l i n t e g e r j ; 0 <= j < n ==> t [ j ] == 0 ) ; ∗/ i n t a l l z e r o s (i n t t [ ] , i n t n ) { i n t k ; /∗@ l o o p i n v a r i a n t 0 <= k <= n ; l o o p i n v a r i a n t \f o r a l l i n t e g e r j ; 0<=j<k ==> t [ j ]==0; l o o p a s s i g n s k ; l o o p v a r i a n t n−k ; ∗/ f o r( k = 0 ; k < n ; k++) i f ( t [ k ] != 0 ) r e t u r n 0 ; r e t u r n 1 ; } Can be proven in Frama-C/WP

(8)

Frama-C, a platform for analysis of C code

Main Frama-C plugins

Frama-C Plugins Dynamic Analysis E-ACSL PathCrawler LTEST STADY SANTE Concurrency Mthread Specification Generation Agen Aora¨ı Formal Methods Deductive Verification WP Jessie Abstract Interpretation VALUE Code Transformation

Semantic constant folding Slicing

Spare code

Browsing of unfamiliar code

Scope & Data-flow browsing Variable occurrences

Impact Analysis Metrics computation

(9)

Frama-C, a platform for analysis of C code

Plugin WP for deductive verification

I Based onWeakest Precondition calculus[Dijkstra, 1976]

I Proves that a given program respects its specification

I Relies on

I automatic provers (Alt-Ergo, CVC4, Z3, . . . ) I when necessary, interactive proof assistants (Coq)

(10)

Verification of a Cloud hypervisor

Outline

Frama-C, a platform for analysis of C code

Verification of a Cloud hypervisor

Anaxagoros hypervisor and Virtual Memory Formal Verification

Results and discussion Verification of a sandbox

The ZeroVM sandbox solution Formal verification

Results Conclusion

(11)

Verification of a Cloud hypervisor Anaxagoros hypervisor and Virtual Memory

Anaxagoros Microkernel

I Clouds mutualize physical resources between users

I Safety and security are crucial

I Anaxagoros

I Secure microkernel hypervisor I Developped at CEA LIST by

Matthieu Lemerre

I Designed for resource isolation and protection

I Virtual memory system is a key module to ensure isolation

(12)

Verification of a Cloud hypervisor Anaxagoros hypervisor and Virtual Memory

Anaxagoros Microkernel

I Clouds mutualize physical resources between users

I Safety and security are crucial

I Anaxagoros

I Secure microkernel hypervisor I Developped at CEA LIST by

Matthieu Lemerre

I Designed for resource isolation and protection

I Virtual memory system is a key module to ensure isolation

(13)

Verification of a Cloud hypervisor Anaxagoros hypervisor and Virtual Memory

Anaxagoros Microkernel

I Clouds mutualize physical resources between users

I Safety and security are crucial

I Anaxagoros

I Secure microkernel hypervisor I Developped at CEA LIST by

Matthieu Lemerre

I Designed for resource isolation and protection

I Virtual memory system is a key module to ensure isolation

(14)

Verification of a Cloud hypervisor Anaxagoros hypervisor and Virtual Memory

Virtual Memory Subsystem

I Organizes program address spaces I Creates a hierarchy of pages I Allows sharing when needed

I Controls accesses and modifications to the pages

I Only owners can access their pages

I Types of the pages limit possible actions

I Counts mappings, references, to each page

(15)

Verification of a Cloud hypervisor Formal Verification

Memory invariant for sequential version

I Maintain the counters of mappings to pages:

I The countermappings[e] must be equal to the real number of mappings to the pagee

I LetOcce be the number of mappings, i.e. occurrences ofe in all pagetables

I We want ot prove:

(16)

Verification of a Cloud hypervisor Formal Verification

Memory invariant for concurrent version

Concurrency issues

I Pages might be modified by different processes simultaneously

I That creates a gap between the actual number of mappings and the counter

New invariant :

∀e,validpage(e)⇒Occe≤mappings[e]≤MAX and more precisely,

∀e,validpage(e)⇒ ∃k.k ≥0∧Occe+k =mappings[e]≤MAX Here k is the number of threads that have introduced a difference in the counter, difference of at most 1.

(17)

Verification of a Cloud hypervisor Formal Verification

Simulation of the concurrency

I To model the execution context, we introduce for each thread : I global arrays representing the value of each local variable I a global array representing its position in the execution

I We simulate every atomic step with a function that performs this step for one thread

I We create an infinite loop that randomly chooses a thread and makes it perform a step of execution according to its current position

(18)

Verification of a Cloud hypervisor Results and discussion

Verification results

I Partial verification of a critical module of Anaxagoros hypervisor

I For low-level functions, we conducted a “classic” verification I Specification with ACSL

I Automatic proof with Frama-C/WP and SMT Solvers (CVC4, Z3)

I For the concurrent function used to change pagetables : I First specification and proof for sequential version I Weakening of the invariant for concurrency I Specification and proof of the simulated version

I Only a few properties could not be proved automatically I their proof is done in Coq by extracting them from WP

(19)

Verification of a Cloud hypervisor Results and discussion

Lessons Learned, Limitations and Benefits

I Ability to treat concurrent programs

I With a tool that originally does not handle parallelism I Proof done mostly automatically

I Verification of properties in isolation

I Scalability

I By-hand simulation is tedious and error prone I Could perfectly be automized

(20)

Verification of a sandbox

Outline

Frama-C, a platform for analysis of C code Verification of a Cloud hypervisor

Anaxagoros hypervisor and Virtual Memory Formal Verification

Results and discussion

Verification of a sandbox

The ZeroVM sandbox solution Formal verification

Results Conclusion

(21)

Verification of a sandbox The ZeroVM sandbox solution

ZeroVM: History

I Developed by Google as a sandboxing technique for Chrome (2009)

I Native Client (NaCl) plugins use Chrome API

(22)

Verification of a sandbox The ZeroVM sandbox solution

ZeroVM: Big picture

OS

trusted un

I Prevents privacy issues, privilege escalation, unauthorized device access...

I Performs binary code validation before execution

I Checks API calls (used for syscall invocations)

(23)

Verification of a sandbox The ZeroVM sandbox solution

ZeroVM: Big picture

OS

trusted un

I Prevents privacy issues, privilege escalation, unauthorized device access...

I Performs binary code validation before execution

I Checks API calls (used for syscall invocations)

(24)

Verification of a sandbox The ZeroVM sandbox solution

ZeroVM: Big picture

OS

trusted un

I Prevents privacy issues, privilege escalation, unauthorized device access...

I Performs binary code validation before execution

I Checks API calls (used for syscall invocations)

(25)

Verification of a sandbox The ZeroVM sandbox solution

ZeroVM: Big picture

OS

trusted un

API

I Prevents privacy issues, privilege escalation, unauthorized device access...

I Performs binary code validation before execution

I Checks API calls (used for syscall invocations)

(26)

Verification of a sandbox The ZeroVM sandbox solution

ZeroVM: Big picture

OS

trusted un

ks

hecc API

I Prevents privacy issues, privilege escalation, unauthorized device access...

I Performs binary code validation before execution

I Checks API calls (used for syscall invocations)

(27)

Verification of a sandbox Formal verification

Verification of ZeroVM

Specificaton in ACSL and deductive verification with Frama-C/WP of API checks before syscall invocation:

/* @ r e q u i r e s v a l i d _ n a p ( nap ); e n s u r e s v a l i d _ n a p ( nap ); @ */ i n t 3 2 _ t T r a p H a n d l e r (s t r u c t N a C l A p p * nap , u i n t 3 2 _ t * a r g s ){ ... }

(28)

Verification of a sandbox Formal verification

API handler for validation of Read operations

s t a t i c i n t 3 2 _ t Z V M R e a d H a n d l e ( s t r u c t N a C l A p p * nap , int ch , c h a r * buffer , i n t 3 2 _ t size , i n t 6 4 _ t o f f s e t ){ ... }

Checks performed by ZVMReadHandle:

I ch channel exists

I bufferis writable onsize length

I [offset;offset+size]⊂[0;channel->size]

(29)

Verification of a sandbox Formal verification

API handler for validation of memory accesses

/* @ r e q u i r e s v a l i d _ n a p ( nap ); r e q u i r e s nap - > m e m _ s t a r t <= s t a r t ; a s s i g n s \ n o t h i n g; e n s u r e s \ r e s u l t == 0 == > p r o t == P R O T _ R E A D == > v a l i d _ r e a d _ s e g m e n t ( start , s t a r t + s i z e ); e n s u r e s \ r e s u l t == 0 == > p r o t == P R O T _ W R I T E == > v a l i d _ s e g m e n t ( start , s t a r t + s i z e ); e n s u r e s \ r e s u l t == 0 || \ r e s u l t == -1; @ */ s t a t i c int C h e c k R A M A c c e s s (s t r u c t N a C l A p p * nap , N a C l S y s P t r start , u i n t 3 2 _ t size , int p r o t )

(30)

Verification of a sandbox Formal verification

Issues detected by formal verification (1/3)

before correction:

i n t 6 4 _ t s i z e ; u i n t p t r _ t start , nap - > m e m _ m a p [ i ]. end ; s i z e -= ( nap - > m e m _ m a p [ i ]. end - s t a r t );

if( s i z e <= 0) r e t u r n 0;

after correction:

if( s i z e <= ( nap - > m e m _ m a p [ i ]. end - s t a r t )) r e t u r n 0; s i z e -= nap - > m e m _ m a p [ i ]. end - s t a r t ;

(31)

Verification of a sandbox Formal verification

Issues detected by formal verification (1/3)

before correction:

i n t 6 4 _ t s i z e ; u i n t p t r _ t start , nap - > m e m _ m a p [ i ]. end ; s i z e -= ( nap - > m e m _ m a p [ i ]. end - s t a r t );

if( s i z e <= 0) r e t u r n 0;

after correction:

if( s i z e <= ( nap - > m e m _ m a p [ i ]. end - s t a r t )) r e t u r n 0; s i z e -= nap - > m e m _ m a p [ i ]. end - s t a r t ;

(32)

Verification of a sandbox Formal verification

Issues detected by formal verification (2/3)

before correction:

i n t 3 2 _ t size , i n t 6 4 _ t o f f s e t ; i n t 6 4 _ t channel - > s i z e ;

/* p r e v e n t r e a d i n g b e y o n d the end of the c h a n n e l */

s i z e = MIN ( channel - > s i z e - offset , s i z e );

/* c h e c k a r g u m e n t s s a n i t y */

if( s i z e == 0)

r e t u r n 0; /* s u c c e s s . u s e r has r e a d 0 b y t e s */

if( s i z e < 0) r e t u r n - E F A U L T ; if( o f f s e t < 0) r e t u r n - E I N V A L ;

(33)

Verification of a sandbox Formal verification

Issues detected by formal verification (2/3)

after correction:

/* c h e c k o f f s e t s a n i t y */

if( o f f s e t < 0 || o f f s e t >= channel - > s i z e ) r e t u r n - E I N V A L ;

/* p r e v e n t r e a d i n g b e y o n d the end of the c h a n n e l */

s i z e = MIN ( channel - > s i z e - offset , s i z e );

/* c h e c k a r g u m e n t s s a n i t y */

if( s i z e == 0)

r e t u r n 0; /* s u c c e s s . u s e r has r e a d 0 b y t e s */

(34)

Verification of a sandbox Formal verification

Issues detected by formal verification (3/3)

before correction:

if( o f f s e t >= channel - > s i z e + t a i l ) r e t u r n - E I N V A L ;

after correction:

if( o f f s e t >= channel - > s i z e &&

(35)

Verification of a sandbox Formal verification

Issues detected by formal verification (3/3)

before correction:

if( o f f s e t >= channel - > s i z e + t a i l ) r e t u r n - E I N V A L ;

after correction:

if( o f f s e t >= channel - > s i z e &&

(36)

Verification of a sandbox Results

Verification results

I Frama-C/WP automatically proves specified properties I 64 proof obligations for functional properties

I 69 proof obligations to prevent runtime errors

I several issues and potential security flaws detected and reported to the development team

(37)

Conclusion

Conclusion

We performeddeductive verification in Frama-C for

I a submodule of a Cloud hypervisor

I a sandbox for secure execution of user applications Results:

I a concurrent version verified via simulation

I a few potential errors and security flaws detected and reported

I Frama-C provides a rich and extensible frameworkfor formal verification of C code

Future work:

References

Related documents

The scientific objectives of the NOMAD instrument can be categorized in three inter-related domains. These are compliant with and follow closely the science objectives of the

that factor. It turns out that if the ether is dragged by just that amount, then no first order experiment can reveal the ether wind. By the middle of the 19th century, the problem

The raw data set for this study consists of daily data from January 1, 1987 to March 26, 2013 for end-of-day settlement prices for all futures and American options on WTI crude oil

The objectives of this study were (1) to compare the concentrations of prebiotic carbohydrates in different lentil genotypes and growing locations and (2) to determine

samskapingen og kundens tilfredshet med virksomheten. En samskapings-opplevelse som gir positive følelser som attribueres på gruppe-nivå vil altså i følge teorien føre til at

Helen Nulty, Transfusion Laboratory Manager, Great Ormond Street Hospital Brian Robertson, Transfusion Practitioner, Guy's &amp; St Thomas' NHS Trust Sylvia Hennem,

Second, the local eye-movement data from the word that contained the correct answer present in the text of the literal condition paragraphs (correct answer word, e.g., cat; Appendix

Johnson (1985) uses a spatial production dif- ferentiation model to analyze two models of copying differing in characteristics related to marginal cost and fixed cost, he concludes