Verified translation validation of static analyses Sandrine Blazy - - PowerPoint PPT Presentation

verified translation validation of static analyses
SMART_READER_LITE
LIVE PREVIEW

Verified translation validation of static analyses Sandrine Blazy - - PowerPoint PPT Presentation

Verified translation validation of static analyses Sandrine Blazy Univ. Rennes, CNRS IRISA, Inria joint work with Gilles Barthe, Vincent Laporte, David Pichardie and Alix Trieu IFIP WG 2.11 2018 6 8 1 How to check


slide-1
SLIDE 1

Verified translation validation of static analyses

Sandrine Blazy

  • Univ. Rennes, CNRS IRISA, Inria

1

joint work with Gilles Barthe, Vincent Laporte, David Pichardie and Alix Trieu IFIP WG 2.11 京都大学 2018年6月8日

slide-2
SLIDE 2

How to check security properties of implementations ?

Cryptographic constant-time property :

  • branching do not depend on secrets
  • memory accesses do not depend on secrets

2 program.c program.asm

CompCert compiler security analysis

at program point XX: 0 ≤ x ≤ 3 ∧ p ⟼ t[2*i+1] …

Verasco static analyzer

No alarm !

slide-3
SLIDE 3

This talk

3

General and lightweight methodology for carrying the results of a source analyzer down to lower-level representations

CompCert compiler Verasco static analyzer

program.asm program.c

0 ≤ r6 ≤ 3 ∧ r1 ⟼ r2

lightweight proof effort at program point XX: 0 ≤ x ≤ 3 ∧ p ⟼ t[2*i+1] …

slide-4
SLIDE 4

This talk

4

CompCert compiler Verasco static analyzer

program.asm program.c

simple constant-time analysis

Low-level data-flow analysis :

  • requires to manually rewrite programs
  • lack of precision
  • does not scale

High-level abstract interpreter :

  • precise (e.g. precise points-to analysis)

lightweight proof effort

slide-5
SLIDE 5

Alternative solution (work in progress)

5

CompCert compiler

program.asm program.c

direct proof

improved Verasco static analyzer

program.c is constant-time and so is program.asm Brittle approach : it requires to

  • instrument all the semantics of CompCert
  • adapt and redo all the proofs
  • define new proof principles
slide-6
SLIDE 6

Background : the formally verified tools CompCert and Verasco

6

slide-7
SLIDE 7

CompCert methodology

We program the compiler inside Coq. Definition compiler (S: program) := ... We state its correctness w.r.t. a formal specification of the language semantics. Theorem compiler_is_correct : ∀ S C, compiler S = OK (C) safe (S) 
 «C behaves like S». We interactively and mechanically prove this theorem

  • Proof. ...(* a few months later *) ...

Qed. We extract an OCaml implementation of the compiler. Extraction compiler.

Logical Framework

(here Coq)

Compiler Language Semantics

parser.ml pprinter.ml compiler.ml

Soundness Proof

7

slide-8
SLIDE 8

Verification patterns (for each compilation pass)

8

Verified transformation transformation transformation validator Verified translation validation = formally verified = not verified Proved once for all One proof per program to compile

slide-9
SLIDE 9

Verasco

We program the static analyzer inside Coq. Definition analyzer (p: program) := ... We state its correctness w.r.t. a formal specification of the language semantics. Theorem analyzer_is_sound : ∀ P, analyzer P = Yes 
 safe(P). We interactively and mechanically prove this theorem

  • Proof. ... (* a few months later *) ...

Qed. We extract an OCaml implementation of the analyzer. Extraction analyzer.

Logical Framework

(here Coq)

Compiler Language Semantics

parser.ml pprinter.ml

Soundness Proof

9

Static Analyzer

analyzer.ml

slide-10
SLIDE 10

numbers

General architecture of Verasco

states Memory & value domain control flow Abstract interpreter Alarms Z → int

Integer congruences

Integer & F .P . intervals

Nonrel→ Rel Nonrel→ Rel Symbolic equalities Convex polyhedra

CompCert compiler C#minor Clight CompCert C ...

slide-11
SLIDE 11

A lightweight methodology to correctly translate the results of static analysis

11

CompCert compiler Verasco static analyzer

program.asm program.c

low-level annotations

lightweight proof 
 effort

slide-12
SLIDE 12

Key ideas

  • Inlining enforceable properties
  • properties that can be enforced using runtime monitors 


Inlining a monitor yields a defensive form (i.e. a program instrumented with runtime checks)
 Enforcing a program to follow a property amounts to checking that it is safe.

12

int *x; int t[3]; /* … */ y = *x; int *x; int t[3]; /* … */ assert (x==t || x==t+1 || x==t+2); y = *x; z = x/y; assert { y != 0 }; z = x/y;

  • Relative safety: P1 is safe under the knowledge that P2 is safe
  • An instance of relational verification
slide-13
SLIDE 13

Methodology

13

p Φ

pΦ [p]hΦi hΦi

DefS DefT

h·i

CosafeT

[pΦ] [p]

[p] | =T hΦi

safeT ([p]) safeS(p)

safeT ([p]hΦi) safeT ([pΦ])

safeS(pΦ)

Verasco Verasco CompCert CompCert

v : [l,h] i; ⇾ assert (l≤v && v≤h); i;

slide-14
SLIDE 14

Use case: cryptographic constant-time

14

slide-15
SLIDE 15

Secure cryptography ?

Lots of secure crypto algorithms were produced in the past decades:
 AES, RSA, SHA1/2/3, ECDSA (used in Bitcoin). Attacks against these algorithms were also published:

  • Tromer, Osvik, Shamir, 2006: Attack against AES, recover the secret key

from Linux's encrypted partitions in 65ms.

  • Yarom, Falkner, 2014: Attack against RSA in GnuPG 1.4.13. « On average,

the attack is able to recover 96.7% of the bits of the secret key by observing a single signature or decryption round. »

  • Benger, van de Pol, Smart, Yarom, 2014: Attack on ECDSA using the

secp256k1 curve « We demonstrate our analysis via experiments using the curve secp256k1 used in the Bitcoin protocol. In particular we show that with as little as 200 signatures we are able to achieve a reasonable level of success in recovering the secret key for a 256-bit curve. »

slide-16
SLIDE 16

Timing attacks

Secret data can have influence on running time of the program Attacker measures timing Attacker infers what is required to recover secret Examples

if (secret) foo(); else bar();

function modular_pow(base, exponent, modulus) if modulus = 1 then return 0 Assert :: (modulus - 1) * (modulus - 1) does not OVF base result := 1 base := base mod modulus while exponent > 0 if (exponent mod 2 == 1): result := (result * base) mod modulus exponent := exponent >> 1 base := (base * base) mod modulus return result

Computes ab mod n, where b is a secret key in RSA
 pseudo-code from Wikipedia

leaks how many bits

  • f exponent are 1
slide-17
SLIDE 17

Use case: cryptographic constant-time

Constant-time policy: the control flow and sequence of memory accesses of a program do not depend on some of its inputs (tagged as secret). Use of the points-to information from Verasco to keep track of security levels, and exploit this information in an information-flow type system

  • Leakage model: conditional branchings and memory accesses can leak

information 
 Ex.: Leakage (<σ, if e then p1 else p2>) = σ (e) We were able to automatically prove that programs verify the constant-time policy.
 Benchmarks: mainly PolarSSL and NaCl cryptographic libraries

17

slide-18
SLIDE 18

Conclusion

Approach to formally verify translation of static analysis results in a formally verified compiler lightweight proof-effort reduces security to safety improves a previous security analysis at pre-assembly level Improve Verasco to perform a very precise taint analysis

  • relies on a tainted semantics
  • encouraging results on a representative benchmark
  • main theorem: any safe program w.r.t. the tainted semantics is constant

time (paper proof)

18

slide-19
SLIDE 19

Questions ?

19

slide-20
SLIDE 20

References

  • G. Barthe, S. Blazy, V. Laporte, D. Pichardie, A. Trieu. Verified translation

validation of static analyses. Computer Security Foundations Symposium (CSF), 2017.

  • S. Blazy, V. Laporte, D. Pichardie. An abstract memory functor for verified

C static analyzers. ICFP 2016.

  • J.H. Jourdan, V. Laporte, S. Blazy, X. Leroy, D. Pichardie. A formally-verified

static analyzer. POPL 2015.

  • G. Barthe, G.Bertate, J.D.Campo, C.Luna, D. Pichardie. System-level non-

interference for constant-time cryptography. Conference on Computer and Communications Security (CCS), 2014.

  • F

. Schneider. Enforceable security policies. ACM Transactions on Information and System Security. 2000.

  • M. Dam, B. Jacobs, A. Lundblad, F

. Piessens. Provably correct inline monitoring for multithreaded Java-like programs. Journal of Computer Security, 2010.

20