1/40
A Principled Intermediate Language for JavaScript Verification
Daiva Naudˇ zi¯ unien˙ e
Imperial College London
A Principled Intermediate Language for JavaScript Verification - - PowerPoint PPT Presentation
A Principled Intermediate Language for JavaScript Verification Daiva Naud zi unien e Imperial College London Resource Reasoning Meeting 1/40 The Team Thomas Philippa Gareth Smith Wood Gardner Petar Jos e Fragoso Maksimovi
1/40
Imperial College London
2/40
3/40
4/40
Person.prototype.sayHi = function() { return “Hi! I am ” + this.name; } var alice = new Person(”Alice”); alice.sayHi();
and assign to “Person.prototype.sayHi”
Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop
xproto
5/40
var Person = function (x) { this.name = x; }
var alice = new Person(”Alice”); alice.sayHi();
Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop sayHi:
xproto
6/40
var Person = function (x) { this.name = x; } Person.prototype.sayHi = function() { return “Hi! I am ” + this.name; } var alice =new Person(”Alice”); alice.sayHi();
and assign to “Person.prototype.sayHi”
Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop sayHi:
xproto
@proto:
xthis
7/40
var Person = function (x) { this.name = x; } Person.prototype.sayHi = function() { return “Hi! I am ” + this.name; } var alice =new Person(”Alice”); alice.sayHi();
and assign to “Person.prototype.sayHi”
Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop sayHi:
xproto
@proto: name: “Alice”
xthis
8/40
var Person = function (x) { this.name = x; } Person.prototype.sayHi = function() { return “Hi! I am ” + this.name; }
alice.sayHi();
and assign to “Person.prototype.sayHi”
alice: Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop sayHi:
xproto
@proto: name: “Alice”
xthis
9/40
var Person = function (x) { this.name = x; } Person.prototype.sayHi = function() { return “Hi! I am ” + this.name; } var alice = new Person(”Alice”);
and assign to “Person.prototype.sayHi”
alice: Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop sayHi:
xproto
@proto: name: “Alice”
xthis
10/40
11/40
var Person = function (x) {
} Person.prototype.sayHi = function() { return “Hi! I am ” + this.name; } var alice =Person(”Alice”); alice.sayHi();
and assign to “Person.prototype.sayHi”
Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop sayHi:
xproto
@proto: name: “Alice”
xthis
12/40
13/40
JS Logic JSIL Logic JSVerify ES5 Strict JSIL
14/40
◮ small language; ◮ simple semantics; ◮ similar memory model to JavaScript’s
ES5 Strict JSIL Principled Translation
15/40
16/40
17/40
18/40
19/40
0: C0 1: C1
m: Cm
20/40
21/40
22/40
23/40
◮ The translation generates a top level procedure for each
◮ The translation generates a special procedure main for the
◮ No nesting of procedures. JavaScript Code JSIL Code var Person = function (x) { ... } proc PProc(xsc, xthis, x){...} Whole Program proc main(){...}
24/40
var Person =function (x) {
var alice = new Person(”Alice”);
this being an object created in Step 3
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop
xproto
25/40
var alice = new Person(”Alice”);
this being an object created in Step 3
Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop
xproto
26/40
var Person = function (x) { this.name = x; } var alice =new Person(”Alice”);
this being an object created in Step 3
Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop
xproto
@proto:
xthis
27/40
var Person = function (x) { this.name = x; } var alice =new Person(”Alice”);
Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop
xproto
@proto: name: “Alice”
xthis
28/40
var Person = function (x) { this.name = x; }
this being an object created in Step 3
alice: Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop
xproto
@proto: name: “Alice”
xthis
29/40
30/40
var Person = function (x) {
} var alice =Person(”Alice”);
Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
sayHi:
xproto
@proto: name: “Alice”
xthis
31/40
ES5 Strict JSIL Translation
32/40
ES5 Strict JSIL Translation Simplifications
33/40
ES5 Strict JSIL Translation Further Simplifications
34/40
ES5 Strict JSIL
Translation ◮ Proven correct with respect to an
◮ Tested using Test262
35/40
◮ We have used ES6 Test262 ◮ Targeted ES5 Strict Subset
◮ Getters and Setters ◮ Arguments Object ◮ Property attributes
◮ We pass 100% of our targeted ES5
14998 Tests 11328 Tests 3575 Tests 2365 Tests ES5 Strict Mode Chapters 8-14 Targeted Fragment
36/40
◮ Program logic for JSIL and a symbolic execution tool based
ES5 Strict + JS Logic Specs JSIL + JISL Specs Symbolic Execution Bi-abduction Logic Rules Entailment coreStar JSVerify
37/40
var Person = function (x) { this.name = x } var alice = new Person(”Alice”);
38/40
(xperson, @scope) → [lg]∗ (xperson, @code) → “PProc”∗ (xthis, “name”) → xsc := [xperson, @scope] xf := [xperson, @code] xret := xf (xsc, xthis, “Alice”) (xperson, @scope) → [lg]∗ (xperson, @code) → “PProc”∗ (xthis, “name”) → “Alice”∗ xsc . = [lg] ∗ xf . = “PProc”∗ xret . = undefined
{(xthis, “name”) → } PProc {(xthis, “name”) → x ∗ ret . = undefined} Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
@proto: lop
xproto
@proto: name: “Alice”
xthis
39/40
(xperson, @scope) → [lg]∗ (xperson, @code) → “PProc”
xf := [xperson, @code] xret := xf (xsc, undefined, “Alice”)
{(xthis, “name”) → } PProc {(xthis, “name”) → x ∗ ret . = undefined} Person:
lg
@code: “PProc” @scope: [lg] @proto: lfp prototype:
xperson
sayHi:
xproto
@proto: name: “Alice”
xthis
40/40
ES5 Strict JSIL JSIL Logic INFER Facebook Tool CBMC Oxford/Amazon VIPER ETH JSVerify