protecting users by confining javascript with...

55
Protecting Users by Confining JavaScript with COWL Deian Stefan, Edward Z. Yang, Petr Marchenko, Alejandro Russo, Dave Herman, Brad Karp, David Mazières

Upload: others

Post on 15-Mar-2021

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Protecting Users by Confining JavaScript with COWL

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

Page 2: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

The WebNo longer just a way of publishing static content

Page 3: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Core reason: Easy to create complex client-side apps

➤ Combine code and data from different parties!

The WebNow app platform; lot of client-side functionality

Page 4: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Many apps handle sensitive data

Political views Location infoFinances

Page 5: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Third-party code? Sensitive data?

chase.com

weather.com

Page 6: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 7: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 8: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 9: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 10: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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 ✓

Page 11: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 12: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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.ccchase.com hsbc.com

? ?

Page 13: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Reality: we give up privacy for functionality!

DAC is not enough!

Page 14: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 15: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 16: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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 ❌

Page 17: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 18: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 19: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Isn’t confinement a solved problem? Confinement for Haskell ➠ Hails

Confinement for Java ➠ Jif!

Change JavaScript to enforce IFC with JSFlow

Page 20: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Dev…

Page 21: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 22: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

The good news

Web turns out to be a good fit for confinement

By accident…

…if you just look at it right

Page 23: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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]

Page 24: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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)

Page 25: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 26: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 27: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Labeled Communication

• Browser-server communication must respect labels!

chase.comsketchy.ru

p4ssw0rdchase.com

sketchy.ruchase.com

Page 28: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Labeled Communication

• Communication across browser contexts must respect label

chase.com

sketchy.ru

sketchy.ru

chase.com sketchy.ru

public

Page 29: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Labeled Communication

• Communication across browser contexts must respect label

chase.com

sketchy.ru

sketchy.ru

chase.com sketchy.ru

public

Page 30: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Labeled Communication

• Communication across browser contexts must respect label

chase.com

sketchy.ru

sketchy.ru

chase.com sketchy.ru

publicp4ssw0rd

chase.com

Page 31: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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.rusketch.rup4ssw0rd

public

Page 32: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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.compublic

sketchy.rusketch.rup4ssw0rd

public

Page 33: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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.compublic

sketchy.rusketch.rup4ssw0rd

public

p4ssw0rd

chase.com

Page 34: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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.compublic

sketchy.rusketch.rup4ssw0rd ❌

public

p4ssw0rd

Page 35: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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.compublic

sketchy.rusketch.rup4ssw0rd ❌

public

p4ssw0rd

weak!

Page 36: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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 designWeb was made for confinement

Page 37: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

What can we do with this?

Page 38: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

• Read-only client-side personal finance service

• Banks can make labeled statements available to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.ccchase.com hsbc.com

Page 39: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

• Read-only client-side personal finance service

• Banks can make labeled statements available to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.ccchase.com hsbc.com

chase.com

Page 40: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

• Read-only client-side personal finance service

• Banks can make labeled statements available to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.ccchase.com hsbc.com

Page 41: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

• Read-only client-side personal finance service

• Banks can make labeled statements available to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.ccchase.com hsbc.com

hsbc.com

Page 42: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

• Read-only client-side personal finance service

• Banks can make labeled statements available to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.ccchase.com hsbc.com

Page 43: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

• Read-only client-side personal finance service

• Banks can make labeled statements available to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.ccchase.com hsbc.com

chase.com

Page 44: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

• Read-only client-side personal finance service

• Banks can make labeled statements available to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.ccchase.com hsbc.com

chase.com hsb.com

❌❌

Page 45: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

• Read-only client-side personal finance service

• Banks can make labeled statements available to Mint ➠ Flexibility+Privacy!

Example: client-side Mint

mint.ccchase.com hsbc.com

chase.com hsb.com

❌❌

Page 46: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

We built it…

Page 47: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 48: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Evaluation: Performance

• Overhead of securing a mashup service?

• Overhead of compartmentalization?

• Will adding COWL slow the existing Web?

Page 49: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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!

Page 50: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 51: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 52: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 53: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 54: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

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

Page 55: Protecting Users by Confining JavaScript with COWLcseweb.ucsd.edu/~dstefan/pubs/stefan:2014:protecting... · 2016. 9. 20. · • DOM-level API for both Firefox and Chromium No changes

Thanks! http://cowl.ws