Protecting Users by Confining JavaScript with COWL Deian Stefan, - - PowerPoint PPT Presentation

protecting users by confining javascript with cowl
SMART_READER_LITE
LIVE PREVIEW

Protecting Users by Confining JavaScript with COWL Deian Stefan, - - PowerPoint PPT Presentation

Protecting Users by Confining JavaScript with COWL Deian Stefan, Edward Z. Yang, Petr Marchenko, Alejandro Russo, Dave Herman, Brad Karp, David Mazires The Web No longer just a way of publishing static content The Web Now app


slide-1
SLIDE 1

Protecting Users by Confining JavaScript with COWL

Deian Stefan, Edward Z. Yang, Petr Marchenko, 
 Alejandro Russo, Dave Herman, Brad Karp, David Mazières

slide-2
SLIDE 2

The Web

No longer just a way of publishing static content

slide-3
SLIDE 3

Core reason: Easy to create complex client-side apps

➤ Combine code and data from different parties!


The Web

Now app platform; lot of client-side functionality

slide-4
SLIDE 4

Many apps handle sensitive data

Political views Location info Finances

slide-5
SLIDE 5

What do browsers do to ensure that the weather site cannot access my bank statements?

Third-party code? Sensitive data?

chase.com weather.com

slide-6
SLIDE 6

Idea: isolate content from different origins

➤ Compartmentalize code into contexts (tabs, iframes,…) ➤ Disallow cross-origin reads from contexts & servers



 
 
 
 
 


In the beginning: Same-origin Policy

chase.com chase.com weather.com weather.com

slide-7
SLIDE 7

Idea: isolate content from different origins

➤ Compartmentalize code into contexts (tabs, iframes,…) ➤ Disallow cross-origin reads from contexts & servers



 
 
 
 
 


In the beginning: Same-origin Policy

chase.com chase.com weather.com weather.com

slide-8
SLIDE 8

Idea: isolate content from different origins

➤ Compartmentalize code into contexts (tabs, iframes,…) ➤ Disallow cross-origin reads from contexts & servers



 
 
 
 
 


In the beginning: Same-origin Policy

chase.com chase.com weather.com weather.com

❌ ❌

slide-9
SLIDE 9

Problems with SOP

Not strict enough:
 can disclose data arbitrarily

➤ Third-party code can leak data ➤ Code runs with authority of page

Not flexible enough:
 can’t read cross-origin data

➤ No secure third-party mashups!

chase.com evil.biz mint.cc chase.com hsbc.com

❌ ❌

slide-10
SLIDE 10

chase.com evil.biz mint.cc chase.com hsbc.com

Today: SOP + CSP + CORS

Content Security Policy:

➤ Whitelist origins page can

communicate with


Cross-origin Resource Sharing:

➤ Server whitelists origins allowed

to read the data

❌ ❌

slide-11
SLIDE 11

Today: SOP + CSP + CORS

Discretionary Access Control Content Security Policy:

➤ Whitelist origins page can

communicate with


Cross-origin Resource Sharing:

➤ Server whitelists origins allowed

to read the data

slide-12
SLIDE 12

DAC is not enough!

Forces choice between functionality and privacy

➤ E.g., mint.com-like client-side third-party mashup



 
 


➤ Privacy: bank doesn’t give mint.cc access to data ➤ Functionality: bank cedes user data to mint.cc


(or worse: user cedes bank credentials)

mint.cc chase.com hsbc.com

? ?

slide-13
SLIDE 13

Reality: we give up privacy for functionality!

DAC is not enough!

slide-14
SLIDE 14

Mutually distrusting services

docs.google.com eff.org

Libraries with narrow APIs

chase.com sketchy.ru

Tightly-coupled libraries

chase.com

DAC is not enough!

Third-party mashups

hsbc.com mint.cc chase.com

slide-15
SLIDE 15

Third-party code + sensitive data

Challenge: allow untrusted code to compute on data

➤ E.g., chase wants to use password-strength checker


library needs to fetch list of common passwords

  • Safe to fetch list before looking at password!

Need: confinement (MAC)

➤ Impose restrictions on how code uses data



 


chase.com sketchy.ru sketchy.ru

p4ssw0rd

slide-16
SLIDE 16

Third-party code + sensitive data

Challenge: allow untrusted code to compute on data

➤ E.g., chase wants to use password-strength checker


library needs to fetch list of common passwords

  • Safe to fetch list before looking at password!

Need: confinement (MAC)

➤ Impose restrictions on how code uses data



 


chase.com sketchy.ru sketchy.ru

p4ssw0rd

slide-17
SLIDE 17

Third-party code + sensitive data

Challenge: allow untrusted code to compute on data

➤ E.g., chase wants to use password-strength checker


library needs to fetch list of common passwords

  • Safe to fetch list before looking at password!

Need: confinement (MAC)

➤ Impose restrictions on how code uses data



 


chase.com sketchy.ru sketchy.ru

p4ssw0rd p4ssw0rd

p4ssw0rd

slide-18
SLIDE 18

Third-party code + sensitive data

Challenge: allow untrusted code to compute on data

➤ E.g., chase wants to use password-strength checker


library needs to fetch list of common passwords

  • Safe to fetch list before looking at password!

Need: confinement (MAC)

➤ Impose restrictions on how code uses data



 


chase.com sketchy.ru sketchy.ru

p4ssw0rd p4ssw0rd

weak! p4ssw0rd

slide-19
SLIDE 19

Isn’t confinement a solved problem?

Confinement for Haskell ➠ Hails Confinement for Java ➠ Jif! Change JavaScript to enforce IFC with JSFlow

slide-20
SLIDE 20

Dev…

slide-21
SLIDE 21

Design constraints

  • Can’t expect developers to learn new language
  • Can’t touch JavaScript runtime

➤ Highly optimized JITs ➤ Add 1 instruction on hot path ➠ no upstream!

  • Can’t radically change the security model

➤ Ingrained notion of principals: origins ➤ Keep iframes, pages, etc. as security boundaries

slide-22
SLIDE 22

The good news

Web turns out to be a good fit for confinement By accident… …if you just look at it right

slide-23
SLIDE 23

The good news

  • Browsers already offer execution contexts

➤ Isolation enforced across context boundaries

  • Can enforce MAC at context granularity

➤ No need to change language runtime! [BFlow]

  • Can easily add new DOM-level APIs

➤ Attach policies to messages [Hails]

slide-24
SLIDE 24

Key (old) concepts: expressed in practical way?

  • 1. Labels: using origins to specify MAC policies
  • 2. Labeled communication: security across contexts

➤ Avoid changing existing communication APIs

  • 3. Privileges: using origins to manage trust

Confinement with Origin Web Labels (COWL)

slide-25
SLIDE 25

Labels

  • Every piece of data is protected by a label
  • Label specifies, in terms of origin(s), who cares

about the data

➤ E.g., data sensitive to Chase: Label(“chase.com”) ➤ E.g., data sensitive to both Chase and HSBC:

Label(“chase.com”).and(“hsbc.com”)
 
 


chase.com

chase.com p4ssw0rd

hsbc.com

hsbc.com

slide-26
SLIDE 26

Label tracking

  • COWL tracks labels at context/server granularity

➤ Pages, iframes, workers, servers

  • Messages can be labeled differently from context

➤ Both servers & JavaScript can label messages ➤ The right way to share sensitive data!

chase.com

chase.com

chase.com

public p4ssw0rd chase.com

slide-27
SLIDE 27

Labeled Communication

  • Browser-server communication must respect

labels!
 
 
 


chase.com sketchy.ru

p4ssw0rd chase.com

sketchy.ru chase.com

slide-28
SLIDE 28

Labeled Communication

  • Communication across browser contexts must

respect label
 
 


chase.com

sketchy.ru

sketchy.ru

chase.com sketchy.ru

public

slide-29
SLIDE 29

Labeled Communication

  • Communication across browser contexts must

respect label
 
 


chase.com

sketchy.ru

sketchy.ru

chase.com sketchy.ru

public

slide-30
SLIDE 30

Labeled Communication

  • Communication across browser contexts must

respect label
 
 


chase.com

sketchy.ru

sketchy.ru

chase.com sketchy.ru

public p4ssw0rd

chase.com

slide-31
SLIDE 31

chase.com

Adjusting labels to read data

  • Contexts can adopt more restrictive label

➤ I.e., add an origin to its label ➤ Can then read data from that origin ➤ Give up ability to write to contexts without it



 


sketchy.ru public

sketchy.ru sketch.ru

p4ssw0rd public

slide-32
SLIDE 32

chase.com

Adjusting labels to read data

  • Contexts can adopt more restrictive label

➤ I.e., add an origin to its label ➤ Can then read data from that origin ➤ Give up ability to write to contexts without it



 


sketchy.ru p4ssw0rd chase.com public

sketchy.ru sketch.ru

p4ssw0rd public

slide-33
SLIDE 33

chase.com

Adjusting labels to read data

  • Contexts can adopt more restrictive label

➤ I.e., add an origin to its label ➤ Can then read data from that origin ➤ Give up ability to write to contexts without it



 


sketchy.ru p4ssw0rd chase.com public

sketchy.ru sketch.ru

p4ssw0rd public p4ssw0rd chase.com

slide-34
SLIDE 34

chase.com

Adjusting labels to read data

  • Contexts can adopt more restrictive label

➤ I.e., add an origin to its label ➤ Can then read data from that origin ➤ Give up ability to write to contexts without it



 


sketchy.ru chase.com p4ssw0rd chase.com public

sketchy.ru sketch.ru

p4ssw0rd

public p4ssw0rd

slide-35
SLIDE 35

chase.com

Adjusting labels to read data

  • Contexts can adopt more restrictive label

➤ I.e., add an origin to its label ➤ Can then read data from that origin ➤ Give up ability to write to contexts without it



 


sketchy.ru chase.com p4ssw0rd chase.com public

sketchy.ru sketch.ru

p4ssw0rd

public p4ssw0rd weak!

slide-36
SLIDE 36
  • 1. Origins are a natural way to specify labels
  • 2. Leverage contexts as security boundaries

➤ Mixed-granularity: label messages

  • 3. Use origins to express privileges (see paper)

Summary: COWL design

Web was made for confinement

slide-37
SLIDE 37

What can we do with this?

slide-38
SLIDE 38
  • Read-only client-side personal finance service



 
 
 


  • Banks can make labeled statements available

to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.cc chase.com hsbc.com

slide-39
SLIDE 39
  • Read-only client-side personal finance service



 
 
 


  • Banks can make labeled statements available

to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.cc chase.com hsbc.com

chase.com

slide-40
SLIDE 40
  • Read-only client-side personal finance service



 
 
 


  • Banks can make labeled statements available

to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.cc chase.com hsbc.com

slide-41
SLIDE 41
  • Read-only client-side personal finance service



 
 
 


  • Banks can make labeled statements available

to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.cc chase.com hsbc.com

hsbc.com

slide-42
SLIDE 42
  • Read-only client-side personal finance service



 
 
 


  • Banks can make labeled statements available

to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.cc chase.com hsbc.com

slide-43
SLIDE 43
  • Read-only client-side personal finance service



 
 
 


  • Banks can make labeled statements available

to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.cc chase.com hsbc.com

chase.com

slide-44
SLIDE 44
  • Read-only client-side personal finance service



 
 
 


  • Banks can make labeled statements available

to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.cc chase.com hsbc.com

chase.com hsb.com

❌ ❌

slide-45
SLIDE 45
  • Read-only client-side personal finance service



 
 
 


  • Banks can make labeled statements available

to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.cc chase.com hsbc.com

chase.com hsb.com

❌ ❌

slide-46
SLIDE 46

We built it…

slide-47
SLIDE 47

Implementations

  • DOM-level API for both Firefox and Chromium

➤ No changes to JavaScript engines ➤ Maintain existing communication APIs ➤ For each page COWL only enabled on first use of API

  • Gecko and Blink: roughly 4K lines of C++ each
slide-48
SLIDE 48

Evaluation: Performance

  • Overhead of securing a mashup service?
  • Overhead of compartmentalization?
  • Will adding COWL slow the existing Web?
slide-49
SLIDE 49

Evaluation: Performance

  • Overhead of securing a mashup service?
  • Overhead of compartmentalization?
  • Will adding COWL slow the existing Web?

Worst-case (loopback, trivial app code)
 end-to-end page load: roughly 16% [16ms]


  • For real apps: relative overhead is small!
slide-50
SLIDE 50

Mutually distrusting services

docs.google.com eff.org

Libraries with narrow APIs

chase.com sketchy.ru

Tightly-coupled libraries

chase.com

Evaluation: Applicability

Third-party mashups

hsbc.com mint.cc chase.com

slide-51
SLIDE 51

Deployability

  • High degree of backward compatibility

➤ Does not affect pages that do not use COWL API

  • Reuse existing concepts (origins, contexts)

➤ Expect it to be friendly to developers

  • Implementations possible for major browsers

➤ Changes don’t touch JavaScript engine

slide-52
SLIDE 52

Limitations & future work

  • Covert channels

➤ Malicious code may still covertly leak data ➤ COWL enforces MAC in addition to existing DAC

  • Compartmentalization

➤ Cannot just label and run existing apps ➤ Compartmentalizing applications requires thought

slide-53
SLIDE 53

Related work

  • Coarse-grained confinement: BFlow

➤ Mainly concerned with untrusted code ➤ COWL also handles the mutually distrusting case

  • Fine-grained confinement: JSFlow

➤ Better fit for tightly-coupled libraries ➤ New semantics, 100x slowdown

slide-54
SLIDE 54

Conclusion

Today: give up privacy for flexibility

➤ Modern web apps need to compute on sensitive data ➤ DAC is crucial, but insufficient!

COWL: confinement for client-side code

➤ Naturally extends the existing web model ➤ Achieves both flexibility and privacy without slowdown

slide-55
SLIDE 55

Thanks!

http://cowl.ws