340 likes | 457 Views
An Information Flow Inlining Compiler for a Core of JavaScript. Jos é Fragoso Santos Tamara Rezk Equipe Project INDES. Web Applications. Combine data and/or code from multiple origins to create a new service. Are commonly implemented in JavaScript. Security Vulnerabilities.
E N D
An Information Flow Inlining Compiler for a Core of JavaScript José Fragoso Santos Tamara Rezk Equipe Project INDES
Web Applications Combine data and/or code from multiple origins to create a new service Are commonlyimplemented in JavaScript
Security Vulnerabilities Internal script that combines the external content integrator.html Integrator.js dom Solution: InformationFlowControl Integrity External Code Gadget A Gadget B Gadget C Confidentiality
JavaScript Security Leaks POLICY: Addresses are SECRET (H) Security Leaks due to: Extensible Objects 1 address_table = {}; … register_addr = function(name, addr) { if (!address_table[name]) { address_table[name] = addr; }} register_add(“Jose Santos”, “jose.santos@inria.fr”); address_table[“Jose Santos”] leaks Informationatlevel H
JavaScript Security Leaks Defining Features of JavaScript Extensible Objects Prototypical Inheritance 1 2 o1 = {}; o1.p = h; o2 = {}; o2.__proto__ = o1; o2.p o2.p leaksinformationatlevel H
JavaScript Security Leaks Defining Features of JavaScript Extensible Objects Prototypical Inheritance Constructs for Checking the Existence of Properties 1 2 3 o1 = {}; if (h()) { o1.p = 1 } o1.p o1.p leaksinformationatlevel H
JavaScript Security Leaks Defining Features of JavaScript Extensible Objects Prototypical Inheritance Constructs for Checking the Existence of Properties Binding of Global Variables 1 2 3 4 x = h; f = function (x) { return this.x; } l = f(0); l leaksinformationatlevelH
Information Flow Control Levels Public Outputs Should NOT Depend on Secret Inputs Label Object Properties with Security Levels Assign a Level to the Domain of Every Object Establish a Lattice of Security Levels Label Variables with Security Levels 1 2 3 4 Γ : Variables → Levels Σ : References x PropertyNames → Levels Σ : References → Levels
Attacker Model What can an attacker see? The domains of the objects labeled with L Values of variables labeled with L Values of properties labeled with L 1 2 3
Attacker Model What can an attacker see? Low-Proj High-Proj Memory
Attacker Model What can an attacker see? o1 p1H: v1 p2L: v2 p2L: v2 p3L: v3 Low-Projection p3L: v3 DomainL: p1, p2, p3 DomainL: p1, p2, p3
Attacker Model What can an attacker see? o1 p1H: v1 p2L: v2 p2L: v2 p3L: v3 Low-Projection p3L: v3 DomainH: p1, p2, p3
Security Property When should a program P be allowed to execute? LP0 = LP0’ LP1 = LP1’ InitialMems DivergentExecutions Are Assumed NOT To LeakInformation HP0’ HP1’ LP0’ Executionof P: LP0 LP1 HP1 HP0 LP1’ Final Mems
SecurityByCompilation Rewrite a program P as P’ so that: P’ only executes if the execution of P is SECURE The semantics of P’ is contained in the semantics of P 1 2
Security By Compilation A Recipe for Designing Inlining Transformations: Specify a Program Transformation that Inlines the Monitor Prove the Inlining Transformation Correct Specify a Monitored Semantics Prove the Monitored Semantics Secure 1 2 3 4
Monitored Semantics Security Labeling = Abstract Memory Execute the Program in the: Real Memory 1 2 VariableLabeling Current Scope Object Final Value InitialMemory LeveloftheCurrentContext Final Memory Expression to Evaluate LeveloftheExpression Final VariableLabeling Final ObjectLabeling ObjectLabeling r, pc ├ <μ, Γ, Σ, e> → <μ’, Γ’, Σ’, v, σ>
Monitored Semantics • Idea: • Visible Resources cannot be updated in • invisible contexts No-Sensitive Upgrades High Executions do NOT change the low projection of the memory
Monitored Semantics pL: l No-Sensitive Upgrades Low-Projections o1 = {}; o1.p = l; if (h()) { o1.p = 0 } o1 o1 domL: {p} domL: {p} h() Є {false, 0, null, undefined} h() Є {false, 0, null, undefined}
Monitored Semantics Property Assignment: e0[e1] = e2 Evaluatesub-expressions: r, pc ├ <μ, Γ, Σ, e0> → <μ0, Γ0, Σ0, r0, σ0> r, pc ├ <μ, Γ, Σ, e0[e1] = e2> → <μ’, Γ, Σ’, v’, σ’>
Monitored Semantics Property Assignment Evaluatesub-expressions: r, pc ├ <μ0, Γ0, Σ0, e1> → <μ1, Γ1, Σ1, m1, σ1> r, pc ├ <μ, Γ, Σ, e0[e1] = e2> → <μ’, Γ, Σ’, v’, σ’>
Monitored Semantics Property Assignment Evaluatesub-expressions: r, pc ├ <μ1, Γ1, Σ1, e2> → <μ2, Γ2, Σ2, v2, σ2> r, pc ├ <μ, Γ, Σ, e0[e1] = e2> → <μ’, Γ, Σ’, v’, σ’>
Monitored Semantics Property Assignment e0 → r0, σ0, e1 → m1, σ1, e2 → v2, σ2 No-sensitive upgrades: σ0˅ σ1 ˅ pc ≤ Σ(r0, m1) if m Є μ2(r0, dom) σ0˅ σ1 ˅ pc ≤ Σ(r0, dom) if m Є μ2(r0, dom) r, pc ├ <μ, Γ, Σ, e0[e1] = e2> → <μ’, Γ’, Σ’, v’, σ’>
Monitored Semantics Property Assignment e0 → r0, σ0, e1 → m1, σ1, e2 → v2, σ2 MemoryandLabelingUpdates: μ’ = μ2[(r0, m1) → σ0˅ σ1 ˅ σ2 ˅ pc ] Σ’ = Σ2[(r0, m1) → σ0˅ σ1 ˅ σ2 ˅ pc ] r, pc ├ <μ, Γ, Σ, e0[e1] = e2> → <μ’, Γ’, Σ’, v’, σ’>
Instrumentation Similarity Relation Encode the labelings in the memory S Memory μ Labeling Γ, Σ Instrumented Memory μ'
Instrumentation Pair Up Each Variable with a Shadow Variable that holds its level LabeledMemory μ, Γ, Σ InstrumentedMemory μinst • Variable: x • Value: μ(x) • Level: Γ(x) • Variable: x • ShadowVariable: levx • Value: μinst(x) • Level: μinst(levx)
Instrumentation Pair Up Each Property with a Shadow Property that holds its level LabeledMemory μ, Γ, Σ InstrumentedMemory μinst • Object: o (ro) • Property: p • Value: μ(ro)(p) • Level: Σ(ro)(p) • Object: o (ro) • Property: p • ShadowProperty: levp • Value: μinst(ro)(p) • Level: μinst(ro) (levp)
InstrumentingObjects p: σp p: vp S p: vp lev_p: σp q: σq q: vq q: vq lev_q: σq lev_s: σs s: σs s: vs s: vs domain: σdom lev_dom: σdom Σ(o) o o’
Instrumentation Encode the labelings in the memory Comp(P) = P’ S S μi' μi μ' μ Γ’, Σ’ Γ, Σ Monitored Execution of P Execution of P’
Compiler Specification Comp(e) = <e’, x, l> l bookkeeps the level of e e’ simulates the execution of e in the monitored semantics x bookkeeps the value to which e evaluates 1 2 3
Compiler Specification Property Assignment: e0[e1] = e2 Compile SubExpressions: Comp(e0) = <e0’, x0, l0> Comp(e1) = <e1’, x1, l1> Comp(e2) = <e2’, x2, l2>
Compiler Specification Property Assignment: e0[e1] = e2 Comp(ei) = <ei’, xi, li> i = 0,1,2 Constraint: if (x1Є dom(x0)) { check(l0˅ l1 ˅ pc ≤ x0[shadow(x1)]) } else { check(l0˅ l1 ˅ pc ≤ x0[“lev_dom”]) }
Compiler Specification Property Assignment: e0[e1] = e2 Comp(ei) = <ei’, xi, li> i = 0,1,2 Comp(e0[e1] = e2) = e0’; e1’; e2’ Constraint x0[x1] = x2; x0[shadow(x1)] = l0˅ l1 ˅ l2
Conclusions In Summary: An information flow monitor for a a core of JavaScript A prototype implementation A program transformation that inlines the monitor 1 2 3