Wrap Your Objects Safely Olaf Owe Gerardo Schneider {olaf, - - PowerPoint PPT Presentation

wrap your objects safely
SMART_READER_LITE
LIVE PREVIEW

Wrap Your Objects Safely Olaf Owe Gerardo Schneider {olaf, - - PowerPoint PPT Presentation

Wrap Your Objects Safely Olaf Owe Gerardo Schneider {olaf, gerardo}@ifi.uio.no Department of Informatics University of Oslo, Norway FESCA, 28 March 2009 York, UK Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 1 / 12


slide-1
SLIDE 1

Wrap Your Objects Safely

Olaf Owe Gerardo Schneider

{olaf, gerardo}@ifi.uio.no Department of Informatics University of Oslo, Norway

FESCA, 28 March 2009 – York, UK

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 1 / 12

slide-2
SLIDE 2

Motivation

How to enforce security in open distributed systems? Restrict the uploading/downloading of applications compromising data privacy, confidentiality, etc

Sandbox model of Java

A set of rules to limit an untrusted applet to execute certain operations when arriving to the site whether the browser resides

Only download “signed” code

Up to the user to allow which code to accept

Other solutions?

Different boxed calculi

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 2 / 12

slide-3
SLIDE 3

Motivation

How to enforce security in open distributed systems? Restrict the uploading/downloading of applications compromising data privacy, confidentiality, etc

Sandbox model of Java

A set of rules to limit an untrusted applet to execute certain operations when arriving to the site whether the browser resides

Only download “signed” code

Up to the user to allow which code to accept

Other solutions?

Different boxed calculi

We want to address this at the programming language level

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 2 / 12

slide-4
SLIDE 4

Our Proposal

General Aspects

A programming language primitive to wrap objects (and components) A wrapper is a membrane defined around an object to isolate it from its environment

The membrane itself The operational part —automaton

Communication between the inside and the outside of the membrane is controlled by the wrapper automaton Two possibilities:

The untrusted part is what is inside the wrapper The untrusted part is the environment

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 3 / 12

slide-5
SLIDE 5

Our Proposal

safeNew and Creol

safeNew C (P;A) creates an instance of class C (and parameters P), wrapped with automaton A We need

A language for defining the wrapper automaton Extend a programming language with the safeNew Enforce the properties of the wrapper at runtime

Implementation in Creol

Asynchronous object-based modeling/programming language Active objects Non-blocking method calls (processor release points) (Executable) operational semantics in Rewriting Logic (Maude)

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 4 / 12

slide-6
SLIDE 6

Creol

  • O1

O5 O6 O4 O7 O2 O3

I1,1 I2,1 I2,2 I3,1 I3,2 I3,3 I5,1 I4,1 I5,2 I6,2 I6,1 I6,3 q4 q6 q5 q3 q1 q2 I7,1 q7

N

Oi: objects Ii,j are its interfaces qi its message queue N is the network

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 5 / 12

slide-7
SLIDE 7

Creol

Syntax

Syntactic categories Definitions t in Label g in Guard p in MtdCall s in Stm v in Var e in Expr m in Mtd x in ObjExpr b in BoolExpr g ::= wait | b | t? | g ∧ g p ::= x.m | m s ::= ε | s; s s ::= (s) | v := e | v := new Id(e) | if b then s else s fi | while b do s od | !p(e) | t!p(e) | t?(v) | p(e; v) | await g | await p(e; v)

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 6 / 12

slide-8
SLIDE 8

Creol

Semantics

Configuration:

  • p none : → Config [ctor] .
  • p _ _ :Config Config → Config

[ctor assoc comm identity: none] .

A Creol object:

<o : C | Att: A, Lvar: L, Pr: S, PrQ: P, InQ: Q, Icnt : I , Ocnt: N >

A Creol class:

<C : Cl | Mtd: M, Att: A >

Object creation in Creol:

(New): <C : Cl | Mtd: M, Att: A >

<O : C’ | Pr: v:= new C; S, Ocnt: N > − → <C : Cl | Mtd: M, Att: A > <O : C’ | Pr: v:=ob(O,N); S, Ocnt: N+1 > <ob(O,N): C | Att: A+(this → ob(O,N)), Lvar: ε, Pr: run(), PrQ: ε, InQ: ε, Icnt: 1, Ocnt: 1 > .

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 7 / 12

slide-9
SLIDE 9

Creol

Semantics

Configuration:

  • p none : → Config [ctor] .
  • p _ _ :Config Config → Config

[ctor assoc comm identity: none] .

A Creol object:

<o : C | Att: A, Lvar: L, Pr: S, PrQ: P, InQ: Q, Icnt : I , Ocnt: N >

A Creol class:

<C : Cl | Mtd: M, Att: A >

Object creation in Creol:

(New): <C : Cl | Mtd: M, Att: A >

<O : C’ | Pr: v:= new C; S, Ocnt: N > − → <C : Cl | Mtd: M, Att: A > <O : C’ | Pr: v:=ob(O,N); S, Ocnt: N+1 > <ob(O,N): C | Att: A+(this → ob(O,N)), Lvar: ε, Pr: run(), PrQ: ε, InQ: ε, Icnt: 1, Ocnt: 1 > .

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 7 / 12

slide-10
SLIDE 10

Enhancing Creol with Wrappers

  • O1

N O5 O6 O4 O7 O2 O3

I1,1 I2,1 I2,2 I3,1 I3,2 I3,3 I5,1 I4,1 I5,2 I6,2 I6,1 I6,3 q4 q6 q5 q3 q1 q2 I7,1 q7

W

LN LN ′

W ′

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 8 / 12

slide-11
SLIDE 11

Enhancing Creol with Wrappers

Configurations (System: Config / class decl):

  • p _+_ : Classes

System → Config [ctor ]. Wrapper definition: sort Wrapper . subsorts Wrapper < System .

  • p {_|_} :Config

Automaton →Wrapper [ctor]. Operational rule for the safeNew:

(safeNew): CL +<O: C’ |Pr: v:=safeNew C(FA); S, Ocnt: N >

− → CL + <O: C’ | Pr: v:=ob(O,N); S, Ocnt: N+1 > { classes (CL,C) + <ob(O,N): C | Att: A+(this → ob(O,N)), Lvar:ε, Pr: run(), PrQ: ε, InQ: ε, Icnt: 1, Ocnt: 1 > | FA } . A possible wrapper configuration may then look like: {< C : CL|... > + < o : C|... > (m to o) (m′ to o′) | FA}

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 9 / 12

slide-12
SLIDE 12

Enhancing Creol with Wrappers

Configurations (System: Config / class decl):

  • p _+_ : Classes

System → Config [ctor ]. Wrapper definition: sort Wrapper . subsorts Wrapper < System .

  • p {_|_} :Config

Automaton →Wrapper [ctor]. Operational rule for the safeNew:

(safeNew): CL +<O: C’ |Pr: v:=safeNew C(FA); S, Ocnt: N >

− → CL + <O: C’ | Pr: v:=ob(O,N); S, Ocnt: N+1 > { classes (CL,C) + <ob(O,N): C | Att: A+(this → ob(O,N)), Lvar:ε, Pr: run(), PrQ: ε, InQ: ε, Icnt: 1, Ocnt: 1 > | FA } . A possible wrapper configuration may then look like: {< C : CL|... > + < o : C|... > (m to o) (m′ to o′) | FA}

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 9 / 12

slide-13
SLIDE 13

Enhancing Creol with Wrappers

Configurations (System: Config / class decl):

  • p _+_ : Classes

System → Config [ctor ]. Wrapper definition: sort Wrapper . subsorts Wrapper < System .

  • p {_|_} :Config

Automaton →Wrapper [ctor]. Operational rule for the safeNew:

(safeNew): CL +<O: C’ |Pr: v:=safeNew C(FA); S, Ocnt: N >

− → CL + <O: C’ | Pr: v:=ob(O,N); S, Ocnt: N+1 > { classes (CL,C) + <ob(O,N): C | Att: A+(this → ob(O,N)), Lvar:ε, Pr: run(), PrQ: ε, InQ: ε, Icnt: 1, Ocnt: 1 > | FA } . A possible wrapper configuration may then look like: {< C : CL|... > + < o : C|... > (m to o) (m′ to o′) | FA}

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 9 / 12

slide-14
SLIDE 14

Example: Readers and Writers

Without Wrappers

rwcons := new RWController(db)

db is an interface of the DataBase class

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 10 / 12

slide-15
SLIDE 15

Example: Readers and Writers

Without Wrappers

rwcons := new RWController(db)

db is an interface of the DataBase class

class RWController(db: DataBase) begin var free: Bool = true, readers: ObjSet = ∅, writer: Obj = null pr, pw: Nat = 0 // pending calls to db.read and db.write with RWClient

  • p OR() == await free; if writer = null then free := false;

await (writer = null); free := true fi; readers := readers ∪ {caller}

  • p CR() == await (caller ∈ readers); readers := readers \ {caller}
  • p OW() == await free; free := false;

await (readers = ∅ ∧ pr = 0 ∧ writer = null); free := true; writer := caller

  • p CW() == await (pw = 0 ∧ writer = caller); writer := null
  • p read(in k: Key out x: Data) == await (caller ∈ readers);

pr := pr + 1; await db.read(k; x); pr := pr – 1

  • p write(in k: Key, x: Data) == await (writer = caller);

pw := pw + 1; await db.write(k,x); pw := pw – 1 end

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 10 / 12

slide-16
SLIDE 16

Example: Readers and Writers

With Wrappers

rwcons := safeNew DataBase(;Aut)

No need of all the code above

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 11 / 12

slide-17
SLIDE 17

Example: Readers and Writers

With Wrappers

rwcons := safeNew DataBase(;Aut)

No need of all the code above

i : exp(comp (·) to user) / o : exp(comp (·) to user) / c := c − 1 i : imp(invoc read(user, t, k) to db) /

  • : imp(invoc read(user, t, k) to db) /

c := c + 1 c := 0 i : exp(comp (·) to u) / c := c − 1 / o : exp(comp (·) to u) i : imp(invoc ow(u) to db) / c == 0

  • : exp(comp (t) to user) / c == 0

i : imp(invoc cw(user, t) to db) / / user := u / tag := t

  • : exp(comp (tag) to user)

/ u = user / o : exp(comp (·) to u) i : exp(comp (·) to u) / c := c − 1 c > 0 c := c + 1 s0 s1 s3 s2

  • : exp(comp (tag) to user)

/ c == 0 / o : imp(invoc read(·) to db) / c := c + 1 i : imp(invoc read(·) to db)

  • : imp(invoc write(user, t, k, x) to db) /

i : imp(invoc write(user, t, k, x) to db) / Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 11 / 12

slide-18
SLIDE 18

Conclusions

Extending Creol with wrappers is easy

We needed also to modify some of the transportation rules

Advantages of the (wrapper) automaton over Creol code

Separation of concern Facilitate verification

Components defined as wrapped objects (including classes) Localities: wrappers + identifiers Wrappers as adaptors The automaton could be written using the functional language of Creol Need for a library with “standard” wrappers Explore applications in smart cards

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 12 / 12

slide-19
SLIDE 19

Conclusions

Extending Creol with wrappers is easy

We needed also to modify some of the transportation rules

Advantages of the (wrapper) automaton over Creol code

Separation of concern Facilitate verification

Components defined as wrapped objects (including classes) Localities: wrappers + identifiers Wrappers as adaptors The automaton could be written using the functional language of Creol Need for a library with “standard” wrappers Explore applications in smart cards

Owe, Schneider () Wrap Your Objects Safely FESCA, 28 March 2009 12 / 12