Gulfstream Staged Sta4c Analysis for Streaming JavaScript - - PowerPoint PPT Presentation

gulfstream
SMART_READER_LITE
LIVE PREVIEW

Gulfstream Staged Sta4c Analysis for Streaming JavaScript - - PowerPoint PPT Presentation

Gulfstream Staged Sta4c Analysis for Streaming JavaScript Applica4ons Salvatore Guarnieri Ben Livshits University of Washington Microso3 Research Web applica4on


slide-1
SLIDE 1

Gulfstream ¡

Salvatore ¡Guarnieri ¡ University ¡of ¡Washington ¡ Ben ¡Livshits ¡ Microso3 ¡Research ¡

Staged ¡Sta4c ¡Analysis ¡for ¡Streaming ¡JavaScript ¡Applica4ons ¡

slide-2
SLIDE 2

2 ¡

Third ¡Party ¡Server ¡ Web ¡applica4on ¡ widget.js ¡ Web ¡page ¡

slide-3
SLIDE 3

Safe ¡Code ¡Inclusion ¡In ¡JavaScript ¡

Run8me ¡Enforcement ¡

  • Conscript ¡[Oakland ¡10] ¡
  • BrowserShield ¡[OSDI ¡06] ¡
  • Caja ¡

Sta8c ¡Analysis ¡

  • Gatekeeper ¡[USENIX ¡Sec ¡09] ¡
  • Staged ¡Informa4on ¡flow ¡for ¡

JavaScript ¡[PLDI ¡09] ¡

3 ¡

Whole ¡program ¡analysis ¡approaches ¡require ¡ the ¡en4re ¡program ¡

slide-4
SLIDE 4

4 ¡

slide-5
SLIDE 5

5 ¡

JavaScript ¡programs ¡are ¡streaming ¡

slide-6
SLIDE 6

<HTML> <HEAD> <SCRIPT> function foo(){...} var f = foo; </SCRIPT> <SCRIPT> function bar(){...} if (...) f = bar; </SCRIPT> </HEAD> <BODY onclick="f();"> ...</BODY> </HTML>

Script ¡Crea8on ¡

6 ¡

What ¡does ¡f ¡ refer ¡to? ¡

slide-7
SLIDE 7

Incremental ¡Loading ¡in ¡Facebook ¡

7 ¡

157 ¡ 29 ¡ 20 ¡ 13 ¡ 0 ¡ 50 ¡ 100 ¡ 150 ¡ 200 ¡ 250 ¡ KB ¡ Profile ¡ Inbox ¡ Friends ¡ Home ¡ 71% ¡

slide-8
SLIDE 8

✔ ¡

Gulfstream ¡In ¡Ac8on ¡

8 ¡

Offline ¡ Online ¡

slide-9
SLIDE 9

Gulfstream ¡In ¡Ac8on ¡

9 ¡

Offline ¡ Online ¡

✔ ¡ ✔ ¡

slide-10
SLIDE 10

Gulfstream ¡In ¡Ac8on ¡

10 ¡

Offline ¡ Online ¡

✔ ¡

slide-11
SLIDE 11

Outline ¡

  • Mo4va4on ¡
  • Implementa4on ¡
  • Evalua4on ¡
  • Conclusions ¡

11 ¡

slide-12
SLIDE 12

Queries ¡

  • We ¡want ¡to ¡determine ¡something ¡about ¡the ¡

program ¡

  • Example ¡

– What ¡does ¡f() ¡refer ¡to ¡ – Detect ¡alert ¡calls ¡ – Does ¡this ¡program ¡use ¡setTimeout ¡

12 ¡

slide-13
SLIDE 13

Points-­‑To ¡Analysis ¡

  • Provides ¡deep ¡program ¡understanding ¡
  • Can ¡be ¡used ¡to ¡construct ¡call ¡graphs ¡
  • Is ¡the ¡founda4on ¡of ¡further ¡analyses ¡
  • Answers ¡a ¡simple ¡ques4on: ¡What ¡heap ¡

loca4ons ¡does ¡ ¡variable ¡x ¡point ¡to ¡

13 ¡

slide-14
SLIDE 14

Points-­‑To ¡Example ¡

14 ¡

1. var A = new Object(); 2. var B = new Object(); 3. x = new Object(); 4. x.foo = new Object(); 5. y = new Object(); 6. y.bar = x; 7. y.add = function(a, b) {} 8. y.add(A, B)

!" !# !$ !% !& ' ( ) * +,-.# /00 +,-." +,-.% 122 314 145# 145"

slide-15
SLIDE 15

Implementa8on ¡Strategies ¡

Datalog ¡with ¡bddbddb ¡ + ¡Fast ¡for ¡large ¡programs ¡ + ¡Highly ¡tuned ¡

  • ­‑ ¡Large ¡startup ¡cost ¡
  • ­‑ ¡Difficult ¡to ¡implement ¡in ¡the ¡

browser ¡

  • Used ¡in ¡Gatekeeper ¡[USENIX ¡

Sec ¡09] ¡ Graph-­‑based ¡flow ¡analysis ¡ + ¡Very ¡small ¡startup ¡cost ¡ + ¡Customized ¡to ¡work ¡with ¡ Gulfstream ¡

  • ­‑ ¡Does ¡not ¡scale ¡well ¡

15 ¡

slide-16
SLIDE 16

Implementa8on ¡

  • Normalize ¡JavaScript ¡

– Turn ¡program ¡into ¡a ¡series ¡of ¡simple ¡statements ¡ – Introduce ¡temporaries ¡as ¡necessary ¡

  • Create ¡flow ¡graph ¡– ¡Use ¡normalized ¡program ¡

to ¡generate ¡flow ¡constraints ¡

  • Serialize ¡flow ¡graph ¡– ¡Encode ¡the ¡flow-­‑graph ¡

so ¡online ¡analysis ¡can ¡use ¡it ¡to ¡update ¡results ¡

16 ¡

slide-17
SLIDE 17

Implementa8on ¡Con8nued ¡

  • Perform ¡points-­‑to ¡analysis ¡

– Traverse ¡flow ¡graph ¡to ¡find ¡all ¡aliases ¡ – Follow ¡flow ¡through ¡method ¡boundaries ¡ – Generate ¡points-­‑to ¡map ¡for ¡queries ¡to ¡use ¡

  • Queries ¡– ¡Use ¡points-­‑to ¡data ¡and ¡flow ¡graph ¡to ¡

answer ¡queries ¡

17 ¡

slide-18
SLIDE 18

Evalua8on ¡

  • Ques4on ¡– ¡Is ¡Gulfstream ¡faster ¡than ¡non-­‑staged ¡

analysis ¡

  • Benchmarks ¡

– Synthe4cally ¡generated ¡ – Scraped ¡from ¡Google ¡code ¡ – Scraped ¡from ¡Facebook ¡

  • Simulate ¡diverse ¡environments ¡

– CPU ¡speed ¡and ¡network ¡proper4es ¡ – Cell ¡phone, ¡laptop, ¡desktop, ¡etc. ¡

18 ¡

slide-19
SLIDE 19

0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 8 ¡ 30 ¡ 35 ¡ 40 ¡ 45 ¡ 50 ¡ 55 ¡ 60 ¡ 65 ¡ Seconds ¡ Total ¡Page ¡Size ¡(KB) ¡ Gulfstream ¡ Full ¡Analysis ¡ bddbddb ¡

Laptop ¡Running ¡Time ¡Comparison ¡

19 ¡

Aner ¡30KB ¡of ¡updates, ¡ Gulfstream ¡is ¡no ¡longer ¡ faster ¡

slide-20
SLIDE 20

Simulated ¡Devices ¡

  • Low ¡power ¡mobile ¡
  • High ¡power ¡

20 ¡

slide-21
SLIDE 21

Simulated ¡Devices ¡

  • Low ¡power ¡mobile ¡
  • High ¡power ¡

21 ¡

slide-22
SLIDE 22

Lessons ¡Learned ¡

  • Slow ¡devices ¡benefit ¡from ¡Gulfstream ¡
  • A ¡slow ¡network ¡can ¡negate ¡the ¡benefits ¡of ¡the ¡

staged ¡analysis ¡

  • Large ¡page ¡updates ¡don’t ¡benefit ¡from ¡

Gulfstream ¡

22 ¡

slide-23
SLIDE 23

Facebook ¡Experiment ¡

  • Visit ¡4 ¡pages ¡

– Home ¡ – Friends ¡ – Inbox ¡ – Profile ¡

  • Each ¡page ¡loads ¡addi4onal ¡JavaScript ¡

23 ¡

slide-24
SLIDE 24

Gulfstream ¡Savings: ¡Slow ¡Devices ¡

24 ¡

0 ¡ 50 ¡ 100 ¡ 150 ¡ 200 ¡ 250 ¡ 300 ¡ 350 ¡ Seconds ¡ profile ¡ ¡ inbox ¡ ¡ friends ¡ ¡ home ¡ ¡

slide-25
SLIDE 25

Gulfstream ¡Savings: ¡Fast ¡Devices ¡

25 ¡

0 ¡ 2 ¡ 4 ¡ 6 ¡ 8 ¡ 10 ¡ 12 ¡ Seconds ¡ profile ¡ ¡ inbox ¡ ¡ friends ¡ ¡ home ¡ ¡ 10 ¡seconds ¡ saved ¡

slide-26
SLIDE 26

Conclusion ¡

  • Gulfstream, ¡staged ¡analysis ¡for ¡JavaScript ¡
  • Staged ¡analysis ¡

– Offline ¡on ¡the ¡server ¡ – Online ¡in ¡the ¡browser ¡

  • Wide ¡range ¡of ¡experiments ¡

– For ¡small ¡updates, ¡Gulfstream ¡is ¡faster ¡ – Devices ¡with ¡slow ¡CPU ¡benefit ¡most ¡

26 ¡

slide-27
SLIDE 27

The ¡End ¡

  • Contact: ¡salvatore.guarnieri@gmail.com ¡

27 ¡