Analyzing ¡Information ¡ Flow ¡in ¡JSE’s ¡ ¡
Nick ¡Taylor ¡ David ¡Erichsen ¡
Analyzing Information Flow in JSEs Nick Taylor David - - PowerPoint PPT Presentation
Analyzing Information Flow in JSEs Nick Taylor David Erichsen Introduction: JavaScript Dynamic computer programming language Generally used by client
Nick ¡Taylor ¡ David ¡Erichsen ¡
Dynamic ¡computer ¡programming ¡language ¡ Generally ¡used ¡by ¡client ¡to ¡allow ¡scripts ¡to ¡interact ¡with ¡ users ¡ Supported ¡by ¡all ¡major ¡browsers ¡ Easy ¡to ¡code ¡in ¡for ¡inexperienced ¡developers ¡and ¡easy ¡to ¡ modify ¡by ¡others ¡ Can ¡be ¡readily ¡ported ¡across ¡platforms ¡ Useful ¡for ¡creating ¡frameworks ¡ ¡
JavaScript-‑based ¡browser ¡extensions ¡(JSEs) ¡improve ¡ core ¡functionality ¡of ¡web ¡browsers ¡
PDF ¡Readers ¡ Flash ¡Players ¡ File ¡Downloaders ¡
Firebug ¡
To ¡enable ¡more ¡elaborate ¡functionalities, ¡browsers ¡ execute ¡JSE’s ¡with ¡elevated ¡privileges ¡ Malicious ¡JSEs ¡can ¡misuse ¡these ¡privileges ¡to ¡ compromise ¡confidentiality ¡and ¡integrity ¡
Stealing ¡sensitive ¡data ¡ Executing ¡arbitrary ¡code ¡on ¡host ¡system ¡
Even ¡if ¡a ¡JSE ¡is ¡not ¡overtly ¡malicious, ¡vulnerabilities ¡in ¡ the ¡JSE ¡and ¡the ¡browser ¡may ¡allow ¡a ¡remote ¡attacker ¡ to ¡compromise ¡browser ¡security. ¡
¡
The ¡problem ¡is ¡that ¡JSE’s ¡are ¡not ¡secure. ¡ ¡Thus ¡JSE’s ¡pose ¡a ¡threat ¡ to ¡browser ¡security. ¡ Factors ¡that ¡add ¡to ¡the ¡problem ¡
Inadequate ¡sandboxing ¡of ¡Javascript ¡in ¡a ¡JSE. ¡
browser ¡e.g ¡can ¡freely ¡access ¡sensitive ¡entities ¡such ¡as ¡the ¡cookie ¡store ¡ and ¡browsing ¡history ¡
Browser ¡and ¡JSE ¡vulnerabilities ¡
Even ¡if ¡a ¡JSE ¡is ¡not ¡malicious, ¡vulnerabilities ¡in ¡the ¡browser ¡and ¡in ¡JSEs ¡ may ¡allow ¡a ¡malicious ¡website ¡to ¡access ¡and ¡misuse ¡the ¡privileges ¡of ¡a ¡ JSE ¡
Tracked ¡information ¡flow ¡at ¡the ¡system ¡level ¡by ¡tracking ¡ information ¡flow ¡at ¡the ¡machine ¡instruction ¡level ¡
Didn’t ¡allow ¡analysts ¡to ¡observe ¡flow ¡of ¡information ¡at ¡JavaScript ¡
Restricted ¡to ¡memory ¡words ¡and ¡machine ¡instructions ¡ Developed ¡techniques ¡to ¡identify ¡spyware ¡behavior ¡in ¡untrusted ¡ browser ¡extensions, ¡particularly ¡in ¡plugins ¡and ¡BHOs ¡(Browser ¡ Helper ¡Object), ¡which ¡are ¡distributed ¡as ¡binary ¡executable. ¡ ¡
These ¡approaches ¡rely ¡on ¡whole-‑system ¡information ¡flow ¡ tracking ¡and ¡on ¡monitoring ¡plugin/browser ¡interactions. ¡ ¡
Security ¡Architecture ¡for ¡Web ¡Browsers ¡(Sabre) ¡
A ¡system ¡that ¡uses ¡in-‑browser ¡information-‑flow ¡ tracking ¡to ¡analyze ¡JSEs ¡ Associates ¡each ¡JavaScript ¡object ¡in-‑memory ¡with ¡a ¡ label ¡that ¡determines ¡if ¡the ¡object ¡contains ¡sensitive ¡ information ¡ Modifies ¡the ¡label ¡when ¡corresponding ¡object ¡is ¡ modified ¡by ¡JavaScript ¡code ¡(JSEs ¡and ¡Web ¡Apps) ¡ Raises ¡alert ¡if ¡it ¡deems ¡object ¡containing ¡sensitive ¡ information ¡is ¡uses ¡in ¡unsafe ¡way ¡
Detecting ¡confidentiality ¡violations ¡
If ¡a ¡JSE ¡attempts ¡to ¡send ¡a ¡JavaScript ¡object ¡containing ¡ sensitive ¡data ¡over ¡a ¡network ¡or ¡write ¡to ¡a ¡file ¡
Detecting ¡integrity ¡violations ¡
If ¡a ¡JSE ¡attempts ¡to ¡execute ¡a ¡script ¡received ¡from ¡an ¡ untrusted ¡domain ¡with ¡elevated ¡privileges ¡
Precisely ¡tracks ¡information ¡flows ¡across ¡different ¡ browser ¡subsystems, ¡including ¡DOM, ¡local ¡storage ¡ and ¡the ¡network ¡ Is ¡able ¡to ¡declassify ¡or ¡endorse ¡information ¡flows ¡ Handles ¡information ¡flows, ¡some ¡implicit ¡flows ¡and ¡ cross-‑domain ¡flows ¡
Includes ¡code ¡executed ¡by ¡web ¡applications, ¡JSEs ¡and ¡ all ¡other ¡JavaScript ¡that ¡comprises ¡the ¡browser ¡ Guards ¡against: ¡
Attackers ¡trying ¡to ¡hide ¡malicious ¡code ¡using ¡ JavaScript ¡in ¡multiple ¡browser ¡subsystems ¡ Code ¡that ¡is ¡used ¡in ¡XUL ¡overlays ¡that ¡may ¡be ¡included ¡ into ¡browser ¡core ¡
Sabre ¡identifies ¡an ¡information ¡flow ¡violation ¡by ¡a ¡ JSE ¡
An ¡analyst ¡may ¡be ¡needed ¡to ¡determine ¡whether ¡the ¡ violation ¡is ¡an ¡attack ¡or ¡part ¡of ¡the ¡valid ¡behavior ¡of ¡ the ¡JSE ¡à à ¡whitelist ¡
Ex) ¡PwdHash ¡– ¡searches ¡and ¡modifies ¡passwords ¡entered ¡
trusted ¡
JavaScript ¡code ¡in ¡a ¡browser ¡and ¡its ¡JSEs ¡interacts ¡ heavily ¡with ¡other ¡subsystems ¡ex) ¡DOM, ¡cookies, ¡ saved ¡passwords, ¡local ¡file ¡system ¡ Must ¡monitor ¡all ¡information ¡flows ¡across ¡all ¡the ¡ subsystems ¡because ¡attackers ¡often ¡use ¡multiple ¡ subsystems ¡for ¡JSE ¡attacks ¡
Used ¡a ¡modified ¡version ¡of ¡SpiderMonkey ¡(a ¡JavaScript ¡ interpreter ¡in ¡Firefox) ¡to ¡track ¡information ¡flow ¡
Altered ¡representation ¡of ¡JavaScript ¡objects ¡to ¡include ¡ security ¡labels ¡ Improved ¡interpretation ¡of ¡JavaScript ¡byte ¡code ¡instructions ¡ to ¡modify ¡labels ¡à à ¡propagate ¡info ¡flow ¡ Modified ¡browser ¡subsystems ¡(DOM ¡and ¡XPCOM) ¡to ¡store ¡ and ¡propagate ¡security ¡labels ¡ JavaScript ¡code ¡is ¡executed ¡by ¡interpreter ¡ Identifies ¡source ¡of ¡JavaScript ¡byte ¡code ¡being ¡interpretted ¡
Sabre ¡detects ¡flows ¡from ¡sensitive ¡sources ¡(information) ¡to ¡low-‑ sensitivity ¡sinks ¡which ¡includes ¡file ¡systems ¡and ¡networks. ¡ In ¡addition ¡to ¡modifying ¡the ¡JS ¡interpreter ¡to ¡raising ¡an ¡alert ¡ when ¡a ¡sensitive ¡object ¡is ¡written ¡to ¡a ¡low-‑sensitivity ¡sink, ¡Sabre ¡ also ¡modifies ¡the ¡browser’s ¡document ¡interface ¡to ¡raise ¡an ¡alert ¡ when ¡a ¡DOM ¡node ¡that ¡stores ¡sensitive ¡data ¡derived ¡from ¡a ¡JSE ¡is ¡ sent ¡over ¡the ¡network. ¡ A ¡file ¡system ¡is ¡both ¡a ¡source ¡and ¡a ¡sink ¡ Confidentiality-‑violating ¡information-‑flows ¡can ¡also ¡be ¡detected ¡ using ¡a ¡similar ¡set ¡of ¡low-‑integrity ¡sources ¡and ¡high-‑integrity ¡ sinks ¡
Associates ¡each ¡in-‑memory ¡JS ¡object ¡with ¡a ¡pair ¡of ¡ security ¡labels ¡which ¡track ¡the ¡flow ¡of: ¡
Sensitive ¡information ¡ Low-‑integrity ¡information ¡ ¡
Each ¡label ¡stores: ¡
Sensitivity ¡level-‑ ¡does ¡it ¡store ¡sensitive ¡info? ¡ Boolean ¡flag-‑ ¡was ¡object ¡modified ¡by ¡JS ¡code ¡in ¡JSE ¡ Names ¡of ¡JSEs ¡and ¡web ¡domains ¡that ¡have ¡been ¡ modified ¡by ¡object ¡
Explicit ¡Flows-‑ ¡handles ¡assignments ¡by ¡propagating ¡ the ¡label ¡of ¡the ¡RHS ¡of ¡an ¡assignment ¡to ¡its ¡LHS ¡
If ¡RHS ¡is ¡complex ¡algorithm/logic ¡operation, ¡the ¡result ¡ is ¡considered ¡sensitive ¡if ¡any ¡arguments ¡are ¡sensitive ¡ JS ¡supports ¡dynamic ¡creation ¡of ¡complex ¡objects ¡
Labels ¡inherit ¡parent ¡labels, ¡though ¡they ¡can ¡be ¡modified ¡ Parents ¡of ¡arrays ¡and ¡other ¡similar ¡data ¡structures ¡inherit ¡ the ¡aggregate ¡of ¡their ¡children ¡to ¡prevent ¡information ¡ leaks ¡ Function ¡calls ¡inherit ¡the ¡label ¡of ¡the ¡parent ¡scope ¡ 127 ¡models ¡to ¡handle ¡cross-‑domain ¡function ¡calls ¡
Implicit ¡Flows-‑ ¡Used ¡for ¡conditions, ¡loops, ¡exception ¡ and ¡other ¡related ¡statements ¡
Control ¡dependency ¡between ¡a ¡conditional ¡expression ¡ and ¡statements ¡executed ¡within ¡the ¡conditional ¡
if(document.cookie.length ¡> ¡0) ¡then ¡{T} ¡else ¡{F} ¡
Scope ¡of ¡each ¡branch ¡inherits ¡the ¡label ¡of ¡its ¡conditional ¡
Some ¡implicit ¡flows ¡cannot ¡be ¡detected ¡using ¡labeled ¡ scopes ¡
Instruction ¡Provenance-‑ ¡the ¡provenance ¡of ¡each ¡JS ¡ instruction ¡is ¡used ¡to ¡determine ¡whether ¡a ¡JS ¡object ¡ is ¡modified ¡by ¡a ¡JSE ¡
To ¡support ¡declassification ¡of ¡sensitive ¡information, ¡Sabre ¡ extends ¡the ¡JS ¡interpreter ¡with ¡the ¡ability ¡to ¡declassify ¡
which ¡specifies ¡how ¡the ¡browser ¡must ¡declassify ¡a ¡ sensitive ¡object. ¡ ¡Flows ¡that ¡violate ¡integrity ¡can ¡similarly ¡ be ¡handled ¡with ¡an ¡endorsement ¡policy. ¡ Sabre ¡Supports ¡two ¡kinds ¡of ¡declassification ¡(and ¡ endorsement) ¡policies: ¡
Sink-‑specific ¡ JSE-‑specific ¡
A ¡sink-‑specific ¡policy ¡permits ¡declassification ¡of ¡
by ¡that ¡instruction. ¡ A ¡JSE-‑specific ¡policy ¡permits ¡declassification ¡of ¡all ¡ flows ¡from ¡a ¡JSE ¡and ¡can ¡be ¡used ¡when ¡a ¡JSE ¡is ¡
Using ¡24 ¡JSE ¡for ¡testing ¡Sabre ¡the ¡test ¡set ¡included ¡ both ¡JSE’s ¡with ¡known ¡malicious ¡flows ¡as ¡well ¡as ¡ JSE’s ¡with ¡unknown ¡flows. ¡ Performance ¡
Using ¡a ¡V8 ¡suite, ¡the ¡Sabra-‑enabled ¡browser ¡had ¡a ¡ mean ¡score ¡of ¡29.16 ¡compared ¡to ¡97.91 ¡for ¡an ¡ unmodified ¡browser ¡ Had ¡a ¡2.36x ¡and ¡1.6x ¡runtime ¡overhead ¡with ¡V8 ¡suite ¡& ¡ SunSpider ¡respectively ¡ Cause ¡for ¡overhead ¡is ¡analyzing ¡overlays ¡(without ¡
¡In ¡testing ¡vulnerable ¡JSE ¡the ¡researchers ¡used ¡one ¡JSE ¡to ¡ discuss ¡which ¡is ¡the ¡exploit ¡against ¡Greasemonkey ¡which ¡ attempted ¡to ¡transmit ¡the ¡contents ¡of ¡a ¡file ¡on ¡the ¡host ¡to ¡an ¡ attacker, ¡thereby ¡violating ¡confidentiality, ¡while ¡exploits ¡against ¡ Firebug ¡attempted ¡to ¡start ¡a ¡process ¡on ¡the ¡host ¡and ¡modify ¡the ¡ contents ¡of ¡a ¡file ¡on ¡disk, ¡thereby ¡violating ¡integrity. ¡In ¡each ¡ case, ¡Sabre ¡precisely ¡identified ¡the ¡information ¡flow ¡violation. ¡ To ¡test ¡malicious ¡JSEs, ¡we ¡considered ¡FFSniFF ¡and ¡BrowserSpy, ¡ both ¡of ¡which ¡exhibit ¡the ¡same ¡behavior—they ¡steal ¡passwords ¡ and ¡other ¡sensitive ¡entries ¡from ¡web ¡forms ¡and ¡hide ¡their ¡ presence ¡from ¡the ¡user ¡by ¡removing ¡themselves ¡from ¡the ¡ browser’s ¡extension ¡manager. ¡Sabre ¡raised ¡an ¡alert ¡when ¡ FFSniFF ¡and ¡BrowserSpy ¡attempted ¡to ¡transmit ¡passwords ¡to ¡a ¡ remote ¡attacker ¡via ¡the ¡network ¡
Browser ¡extension ¡security: ¡ ¡
spyware ¡behavior ¡in ¡untrusted ¡browser ¡extensions, ¡particularly ¡in ¡ plugins ¡and ¡BHOs, ¡which ¡are ¡distributed ¡as ¡binary ¡executables. ¡ These ¡approaches ¡rely ¡on ¡whole-‑system ¡information ¡flow ¡tracking ¡
interactions ¡but ¡supplements ¡such ¡monitoring ¡with ¡information ¡on ¡ sensitivity/integrity ¡of ¡JavaScript ¡objects ¡
detect ¡confidentiality-‑violating ¡JavaScript ¡code ¡[16]. ¡This ¡idea ¡has ¡ been ¡applied ¡by ¡Vogt ¡et ¡al.[42] ¡to ¡detect ¡cross-‑site ¡scripting ¡
taint ¡tracking ¡techniques ¡for ¡JavaScript ¡with ¡promising ¡results, ¡but ¡
In ¡addition ¡to ¡the ¡above ¡work ¡on ¡JavaScript ¡ sandboxing, ¡recent ¡research ¡has ¡investigated ¡ static ¡analysis ¡techniques ¡for ¡JavaScript ¡code ¡[32], ¡ particularly ¡to ¡statically ¡ensure ¡compliance ¡with ¡ site-‑specific ¡policies ¡and ¡to ¡ensure ¡the ¡integrity ¡of ¡ client-‑side ¡JavaScript ¡code ¡of ¡a ¡web ¡application ¡ [28]. ¡