SlideShare a Scribd company logo
1 of 26
Lightweight Self-Protecting JavaScript*
Phu H. Phung David Sands
Chalmers University of Technology
Gothenburg, Sweden
29.03.09 - 03.04.09, Dagstuhl Seminar 09141
Web Application Security
Dagstuhl 02 April 2009
Andrey Chudnov
Stevens Institute of Technology
New Jersey, USA
* In Proceedings of ASIACCS’09, 10-12 March 2009, Sydney, ACM Press
1/18
The concern problems
• Injected (untrusted) JavaScript code (e.g.XSS)
– A malicious user (the attacker) injects potentially
dangerous JavaScript code into a webpage via
data entry in the webpage, e.g.:
• blog
• forum
• web-mail
• Third party scripts (e.g. advertisement,
mashup web applications)
• Buggy code
Dagstuhl 09141, 2 April 2009Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
2/18
Previous solutions
Server Filtering for Script Detection
• detect and remove potential malicious scripts
Problems
• Parser mismatch problem: filter does not always
parse in the same way as browser
c.f. Samy / MySpace
• Dynamic scripts problematic...
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
3/18
Previous solutions
Server Filtering for Script Detection
detect and remove potential malicious scripts
Problems
Parser mismatch problem: filter does not always
parse in the same way as browser
c.f. Samy / MySpace, Yamanner / Yahoo Mail
• Dynamic scripts problematic...
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
<script>
document.write(‘<scr’);
document.write(‘ipt> malic’);
var i= 1;
document.write(‘ious code; </sc’);
document.write(‘ript>’);
</script>
<script> malicious code; </script>
Dagstuhl 09141, 2 April 2009
4/18
Previous solutions
Server Filtering for Script Detection
Prevent dynamic scripts by safe language subsets
(c.f. Facebook’s FBJS, ADsafe, CoreScript)
• Limits functionality
• Defeated by parser mismatch problem
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
5/18
Previous solutions
Behavioural Control:
Don’t try to detect bad scripts,
just prevent bad behaviour
• Modify browser with
reference monitor
• Transform code at
runtime to make it safe
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
• Requires
browser
modification,
e.g. BEEP
• Limited policies
• Parser mismatch
problem
• Dynamic code
runtime transformation
high overhead
e.g. BrowserShield
Dagstuhl 09141, 2 April 2009
6/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
Our approach:
Use an Inlined Reference Monitor
• “inline” the policy into the JavaScript code
so that the code becomes self-protecting
• The policy enforcement is implemented in
a lightweight manner
– does not require browser modification
– non invasive: the original code (and any dynamically
generated code) is not syntactically modified
– its implementation is a small and simple adaptation of
an aspect-oriented programming library
Dagstuhl 09141, 2 April 2009
7/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
The policy
• The enforcement mechanism is security
reference monitor-based
• Ensure safety property of program execution
• Examples:
• Only allow URI in a white-list when sending by
XMLHttpRequest
• Do not allow send after cookie read
• Limit the number of alerts to 2
Dagstuhl 09141, 2 April 2009
8/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
Enforcement method
• Intercept JavaScript API method call by
inlining policy into the call
– control or modify the bad behaviour
• Monitor access to sensitive properties
Dagstuhl 09141, 2 April 2009
9/18
• Use aspect-oriented programming (AOP)
to intercept JavaScript API method call
• No browser modification
• No syntactical script code modification
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
before( {target: window, method: 'alert'},
function() {
log('AOP test: window.alert is invoked');
}
);
Execution point =
Point cut in AOP
Advice
(additional code at an
execution point)
Lightweight
Advice types:
before, after, around
Dagstuhl 09141, 2 April 2009
10/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
AOP weaving: Adapt jQuery AOP
Dagstuhl 09141, 2 April 2009
Store the original method
Apply the policy
Control the original method
var wrap = function(pointcut, Policy) {
var source = (typeof(pointcut.target.prototype) != 'undefined‘)?
pointcut.target.prototype : pointcut.target;
var method = pointcut.method;
var original = source[method];
var aspect = function() {
var invocation = { object: this, args: arguments };
return Policy.apply(invocation.object,
[{ arguments: invocation.args,
method: method,
proceed : function(){ return original.apply(
invocation.object, invocation.args);}}] );
};
source[method] = aspect;
return aspect;
};
11/18
Enforcement method
alert
implementation
JavaScript execution environment
(e.g. browsers)
Native implementations
code pointers User
functions
alert(..) window.alert
alert
wrapper
(+policy code)
Attacker code
alert =
function(){...};
alert
wrapper
unique
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
12/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
The problems of dynamic feature
• Consider the behaviour of the code
– Avoid the problems of dynamic feature of
JavaScript
Dagstuhl 09141, 2 April 2009
%61%6C%65%72%74%28%27%58
%53%53%27%29%3B%0A%0A
alert(‘XSS’)
var abcxyz = window.alert;
abcxyz(‘XSS’);
eval(“alert(‘XSS’)”);
(function(){ return this;})().alert(‘XSS’);
13/18
• Use Mozilla-specific setter and getter*
object.prototype.__defineGetter__(...),
object.prototype.__defineSetter__(...)
* This feature is Mozilla-specific, however, it has been specified in the
current draft proposal for the next generations of JavaScript
(ECMA-262 3.1)
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
Monitoring Property access
Dagstuhl 09141, 2 April 2009
14/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
A realisation
• Structure of a webpage containing policy
enforcement code
• Policies are located in the first script tag
– Policy enforcement is applied for the rest of code
Dagstuhl 09141, 2 April 2009
The enforcement code can be deployed in
any sides: server side, proxy or plug-in
15/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
Effectiveness
• Defend real-world exploits
– phpBB 2.0.18 vulnerabilities – a stored XSS
attack (see demo)
– WebCal vulnerabilities –a reflected XSS attack
• Can enforce application-specific policies
– Using building blocks, i.e. security policy
patterns
Dagstuhl 09141, 2 April 2009
16/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
Security Policy Patterns (1)
• Preventing leakage of sensitive data
– monitoring sensitive data read and data output e.g.
write, redirect, XMLHttpRequest...
Dagstuhl 09141, 2 April 2009
enforcePolicy({target:XMLHttpRequest,
method: 'send'},
function(invocation){
XMLHttpRequestPolicy(invocation);});
17/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
Security Policy Patterns (2)
• Preventing impersonation attacks
– only allow URI in a defined white-list
Dagstuhl 09141, 2 April 2009
var XMLHttpRequestPolicy = function(invocation){
//allow the transaction if the
// URI is in the whitelist
if (AllowedURL(XMLHttpRequestURL)){
policylog("XMLHttpRequest is sent");
return invocation.proceed();
}
policylog("XMLHttpRequest is suppressed:“+
"potential impersonation attacks");
}
18/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
Security Policy Patterns (3)
• Preventing forgery attacks, e.g.
– open a new window without the location bar: enforce
corresponding invariants
– faked links: detect and disable the faked links
Dagstuhl 09141, 2 April 2009
var checkLinks = function(){
var links = document.links;
if (!links){ policylog('no links'); return; }
for(var i = 0; i < links.length; i++) {
if (!AllowedLinks(links[i].href))
{
links[i].href =
"javascript:alert('disabled link')";
}
}
}
19/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
Security Policy Patterns (4)
• Preventing resource abuse
– limit or prohibit potential abuse functions
Dagstuhl 09141, 2 April 2009
20/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
Overhead
Render: 5.37%
Weaving slowdown 6,33 times (We measure
micro-benchmark with operations)
Dagstuhl 09141, 2 April 2009
21/18
Limitations
• Policies cannot span multiple pages
– frame and iframe are separate pages!
• Implementation Specific Solutions and
Problems
– Use of custom getter and setter (in Mozilla,
but not in IE)
– Problems handling Mozilla’s delete semantics
Both problems solved in ECMA-262 v3.1
proposal
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
22/18
Summary
• Our approach is to control and modify the
behaviour of JavaScript by transforming
the code to make it self-protecting
– no browser modifications
– non-invasive
• solve the problem of dynamic scripts
• avoiding the need for extensive runtime code
transformation
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
23/18
Further concerns
• Case studies for particular web
applications
• Integration with other methods
• Securing JavaScript AOP
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
ASIACCS'09, 10 March 2009Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
25/18
Attacks to the Unique Reference Property
• Restoring built-in methods from another
page
– Creates a new window, frame or iframe to
manufacture a pointer to the original built-in
methods
• Mozilla’s delete operator
– Our wrapper methods are not built-in, they are
deletable and the deletion exposes the
original built-in.
Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009

More Related Content

Similar to Lightweight Self-Protecting JavaScript

Writting Better Software
Writting Better SoftwareWritting Better Software
Writting Better Softwaresvilen.ivanov
 
Automatic binary deobfuscation
Automatic binary deobfuscationAutomatic binary deobfuscation
Automatic binary deobfuscationUltraUploader
 
Web Application Firewall - Web Application & Web Services Security integrated...
Web Application Firewall - Web Application & Web Services Security integrated...Web Application Firewall - Web Application & Web Services Security integrated...
Web Application Firewall - Web Application & Web Services Security integrated...Thomas Malmberg
 
Formal Methods for Dependable Neural Networks
Formal Methods for Dependable Neural Networks Formal Methods for Dependable Neural Networks
Formal Methods for Dependable Neural Networks Chih-Hong Cheng
 
Webinar–Vulnerabilities in Containerised Production Environments
Webinar–Vulnerabilities in Containerised Production EnvironmentsWebinar–Vulnerabilities in Containerised Production Environments
Webinar–Vulnerabilities in Containerised Production EnvironmentsSynopsys Software Integrity Group
 
An Application-Oriented Approach for Computer Security Education
An Application-Oriented Approach for Computer Security EducationAn Application-Oriented Approach for Computer Security Education
An Application-Oriented Approach for Computer Security EducationXiao Qin
 
MODEL-DRIVEN ENGINEERING (MDE) in Practice
MODEL-DRIVEN ENGINEERING (MDE) in PracticeMODEL-DRIVEN ENGINEERING (MDE) in Practice
MODEL-DRIVEN ENGINEERING (MDE) in PracticeHussein Alshkhir
 
Prototyping for knowledge based entrepreneurship
Prototyping for knowledge based entrepreneurshipPrototyping for knowledge based entrepreneurship
Prototyping for knowledge based entrepreneurshipVlad Manea
 
Automating safety engineering with model based techniques
Automating safety engineering with model based techniquesAutomating safety engineering with model based techniques
Automating safety engineering with model based techniquesJuha-Pekka Tolvanen
 
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]Websec México, S.C.
 
JavaOne 2016 "Java, Microservices, Cloud and Containers"
JavaOne 2016 "Java, Microservices, Cloud and Containers"JavaOne 2016 "Java, Microservices, Cloud and Containers"
JavaOne 2016 "Java, Microservices, Cloud and Containers"Daniel Bryant
 
Ethical Hacking Conference 2015- Building Secure Products -a perspective
 Ethical Hacking Conference 2015- Building Secure Products -a perspective Ethical Hacking Conference 2015- Building Secure Products -a perspective
Ethical Hacking Conference 2015- Building Secure Products -a perspectiveDr. Anish Cheriyan (PhD)
 
Lean Model-Driven Development through Model-Interpretation: the CPAL design ...
Lean Model-Driven Development through  Model-Interpretation: the CPAL design ...Lean Model-Driven Development through  Model-Interpretation: the CPAL design ...
Lean Model-Driven Development through Model-Interpretation: the CPAL design ...Nicolas Navet
 
82_PHOTOLAB-----Project PPT.pdfhejeenejsn
82_PHOTOLAB-----Project PPT.pdfhejeenejsn82_PHOTOLAB-----Project PPT.pdfhejeenejsn
82_PHOTOLAB-----Project PPT.pdfhejeenejsnshivam003d
 
HiPEAC 2019 Tutorial - Maestro RTOS
HiPEAC 2019 Tutorial - Maestro RTOSHiPEAC 2019 Tutorial - Maestro RTOS
HiPEAC 2019 Tutorial - Maestro RTOSTulipp. Eu
 
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdfAstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdfFarHanWasif1
 
Enforcing Corporate Security Policies via Computational Intelligence Techniques
Enforcing Corporate Security Policies via Computational Intelligence TechniquesEnforcing Corporate Security Policies via Computational Intelligence Techniques
Enforcing Corporate Security Policies via Computational Intelligence TechniquesJuan J. Merelo
 
5 Practical Steps to a Successful Deep Learning Research
5 Practical Steps to a Successful  Deep Learning Research5 Practical Steps to a Successful  Deep Learning Research
5 Practical Steps to a Successful Deep Learning ResearchBrodmann17
 
The Green Lab - [04 B] [PWA] Experiment setup
The Green Lab - [04 B] [PWA] Experiment setupThe Green Lab - [04 B] [PWA] Experiment setup
The Green Lab - [04 B] [PWA] Experiment setupIvano Malavolta
 

Similar to Lightweight Self-Protecting JavaScript (20)

Writting Better Software
Writting Better SoftwareWritting Better Software
Writting Better Software
 
Automatic binary deobfuscation
Automatic binary deobfuscationAutomatic binary deobfuscation
Automatic binary deobfuscation
 
Web Application Firewall - Web Application & Web Services Security integrated...
Web Application Firewall - Web Application & Web Services Security integrated...Web Application Firewall - Web Application & Web Services Security integrated...
Web Application Firewall - Web Application & Web Services Security integrated...
 
Formal Methods for Dependable Neural Networks
Formal Methods for Dependable Neural Networks Formal Methods for Dependable Neural Networks
Formal Methods for Dependable Neural Networks
 
Webinar–Vulnerabilities in Containerised Production Environments
Webinar–Vulnerabilities in Containerised Production EnvironmentsWebinar–Vulnerabilities in Containerised Production Environments
Webinar–Vulnerabilities in Containerised Production Environments
 
An Application-Oriented Approach for Computer Security Education
An Application-Oriented Approach for Computer Security EducationAn Application-Oriented Approach for Computer Security Education
An Application-Oriented Approach for Computer Security Education
 
MODEL-DRIVEN ENGINEERING (MDE) in Practice
MODEL-DRIVEN ENGINEERING (MDE) in PracticeMODEL-DRIVEN ENGINEERING (MDE) in Practice
MODEL-DRIVEN ENGINEERING (MDE) in Practice
 
Prototyping for knowledge based entrepreneurship
Prototyping for knowledge based entrepreneurshipPrototyping for knowledge based entrepreneurship
Prototyping for knowledge based entrepreneurship
 
Automating safety engineering with model based techniques
Automating safety engineering with model based techniquesAutomating safety engineering with model based techniques
Automating safety engineering with model based techniques
 
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
 
JavaOne 2016 "Java, Microservices, Cloud and Containers"
JavaOne 2016 "Java, Microservices, Cloud and Containers"JavaOne 2016 "Java, Microservices, Cloud and Containers"
JavaOne 2016 "Java, Microservices, Cloud and Containers"
 
Ethical Hacking Conference 2015- Building Secure Products -a perspective
 Ethical Hacking Conference 2015- Building Secure Products -a perspective Ethical Hacking Conference 2015- Building Secure Products -a perspective
Ethical Hacking Conference 2015- Building Secure Products -a perspective
 
Ch01lect1 ud
Ch01lect1 udCh01lect1 ud
Ch01lect1 ud
 
Lean Model-Driven Development through Model-Interpretation: the CPAL design ...
Lean Model-Driven Development through  Model-Interpretation: the CPAL design ...Lean Model-Driven Development through  Model-Interpretation: the CPAL design ...
Lean Model-Driven Development through Model-Interpretation: the CPAL design ...
 
82_PHOTOLAB-----Project PPT.pdfhejeenejsn
82_PHOTOLAB-----Project PPT.pdfhejeenejsn82_PHOTOLAB-----Project PPT.pdfhejeenejsn
82_PHOTOLAB-----Project PPT.pdfhejeenejsn
 
HiPEAC 2019 Tutorial - Maestro RTOS
HiPEAC 2019 Tutorial - Maestro RTOSHiPEAC 2019 Tutorial - Maestro RTOS
HiPEAC 2019 Tutorial - Maestro RTOS
 
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdfAstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
 
Enforcing Corporate Security Policies via Computational Intelligence Techniques
Enforcing Corporate Security Policies via Computational Intelligence TechniquesEnforcing Corporate Security Policies via Computational Intelligence Techniques
Enforcing Corporate Security Policies via Computational Intelligence Techniques
 
5 Practical Steps to a Successful Deep Learning Research
5 Practical Steps to a Successful  Deep Learning Research5 Practical Steps to a Successful  Deep Learning Research
5 Practical Steps to a Successful Deep Learning Research
 
The Green Lab - [04 B] [PWA] Experiment setup
The Green Lab - [04 B] [PWA] Experiment setupThe Green Lab - [04 B] [PWA] Experiment setup
The Green Lab - [04 B] [PWA] Experiment setup
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 

Lightweight Self-Protecting JavaScript

  • 1. Lightweight Self-Protecting JavaScript* Phu H. Phung David Sands Chalmers University of Technology Gothenburg, Sweden 29.03.09 - 03.04.09, Dagstuhl Seminar 09141 Web Application Security Dagstuhl 02 April 2009 Andrey Chudnov Stevens Institute of Technology New Jersey, USA * In Proceedings of ASIACCS’09, 10-12 March 2009, Sydney, ACM Press
  • 2. 1/18 The concern problems • Injected (untrusted) JavaScript code (e.g.XSS) – A malicious user (the attacker) injects potentially dangerous JavaScript code into a webpage via data entry in the webpage, e.g.: • blog • forum • web-mail • Third party scripts (e.g. advertisement, mashup web applications) • Buggy code Dagstuhl 09141, 2 April 2009Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
  • 3. 2/18 Previous solutions Server Filtering for Script Detection • detect and remove potential malicious scripts Problems • Parser mismatch problem: filter does not always parse in the same way as browser c.f. Samy / MySpace • Dynamic scripts problematic... Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
  • 4. 3/18 Previous solutions Server Filtering for Script Detection detect and remove potential malicious scripts Problems Parser mismatch problem: filter does not always parse in the same way as browser c.f. Samy / MySpace, Yamanner / Yahoo Mail • Dynamic scripts problematic... Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se <script> document.write(‘<scr’); document.write(‘ipt> malic’); var i= 1; document.write(‘ious code; </sc’); document.write(‘ript>’); </script> <script> malicious code; </script> Dagstuhl 09141, 2 April 2009
  • 5. 4/18 Previous solutions Server Filtering for Script Detection Prevent dynamic scripts by safe language subsets (c.f. Facebook’s FBJS, ADsafe, CoreScript) • Limits functionality • Defeated by parser mismatch problem Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
  • 6. 5/18 Previous solutions Behavioural Control: Don’t try to detect bad scripts, just prevent bad behaviour • Modify browser with reference monitor • Transform code at runtime to make it safe Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se • Requires browser modification, e.g. BEEP • Limited policies • Parser mismatch problem • Dynamic code runtime transformation high overhead e.g. BrowserShield Dagstuhl 09141, 2 April 2009
  • 7. 6/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Our approach: Use an Inlined Reference Monitor • “inline” the policy into the JavaScript code so that the code becomes self-protecting • The policy enforcement is implemented in a lightweight manner – does not require browser modification – non invasive: the original code (and any dynamically generated code) is not syntactically modified – its implementation is a small and simple adaptation of an aspect-oriented programming library Dagstuhl 09141, 2 April 2009
  • 8. 7/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se The policy • The enforcement mechanism is security reference monitor-based • Ensure safety property of program execution • Examples: • Only allow URI in a white-list when sending by XMLHttpRequest • Do not allow send after cookie read • Limit the number of alerts to 2 Dagstuhl 09141, 2 April 2009
  • 9. 8/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Enforcement method • Intercept JavaScript API method call by inlining policy into the call – control or modify the bad behaviour • Monitor access to sensitive properties Dagstuhl 09141, 2 April 2009
  • 10. 9/18 • Use aspect-oriented programming (AOP) to intercept JavaScript API method call • No browser modification • No syntactical script code modification Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se before( {target: window, method: 'alert'}, function() { log('AOP test: window.alert is invoked'); } ); Execution point = Point cut in AOP Advice (additional code at an execution point) Lightweight Advice types: before, after, around Dagstuhl 09141, 2 April 2009
  • 11. 10/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se AOP weaving: Adapt jQuery AOP Dagstuhl 09141, 2 April 2009 Store the original method Apply the policy Control the original method var wrap = function(pointcut, Policy) { var source = (typeof(pointcut.target.prototype) != 'undefined‘)? pointcut.target.prototype : pointcut.target; var method = pointcut.method; var original = source[method]; var aspect = function() { var invocation = { object: this, args: arguments }; return Policy.apply(invocation.object, [{ arguments: invocation.args, method: method, proceed : function(){ return original.apply( invocation.object, invocation.args);}}] ); }; source[method] = aspect; return aspect; };
  • 12. 11/18 Enforcement method alert implementation JavaScript execution environment (e.g. browsers) Native implementations code pointers User functions alert(..) window.alert alert wrapper (+policy code) Attacker code alert = function(){...}; alert wrapper unique Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
  • 13. 12/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se The problems of dynamic feature • Consider the behaviour of the code – Avoid the problems of dynamic feature of JavaScript Dagstuhl 09141, 2 April 2009 %61%6C%65%72%74%28%27%58 %53%53%27%29%3B%0A%0A alert(‘XSS’) var abcxyz = window.alert; abcxyz(‘XSS’); eval(“alert(‘XSS’)”); (function(){ return this;})().alert(‘XSS’);
  • 14. 13/18 • Use Mozilla-specific setter and getter* object.prototype.__defineGetter__(...), object.prototype.__defineSetter__(...) * This feature is Mozilla-specific, however, it has been specified in the current draft proposal for the next generations of JavaScript (ECMA-262 3.1) Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Monitoring Property access Dagstuhl 09141, 2 April 2009
  • 15. 14/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se A realisation • Structure of a webpage containing policy enforcement code • Policies are located in the first script tag – Policy enforcement is applied for the rest of code Dagstuhl 09141, 2 April 2009 The enforcement code can be deployed in any sides: server side, proxy or plug-in
  • 16. 15/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Effectiveness • Defend real-world exploits – phpBB 2.0.18 vulnerabilities – a stored XSS attack (see demo) – WebCal vulnerabilities –a reflected XSS attack • Can enforce application-specific policies – Using building blocks, i.e. security policy patterns Dagstuhl 09141, 2 April 2009
  • 17. 16/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Security Policy Patterns (1) • Preventing leakage of sensitive data – monitoring sensitive data read and data output e.g. write, redirect, XMLHttpRequest... Dagstuhl 09141, 2 April 2009 enforcePolicy({target:XMLHttpRequest, method: 'send'}, function(invocation){ XMLHttpRequestPolicy(invocation);});
  • 18. 17/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Security Policy Patterns (2) • Preventing impersonation attacks – only allow URI in a defined white-list Dagstuhl 09141, 2 April 2009 var XMLHttpRequestPolicy = function(invocation){ //allow the transaction if the // URI is in the whitelist if (AllowedURL(XMLHttpRequestURL)){ policylog("XMLHttpRequest is sent"); return invocation.proceed(); } policylog("XMLHttpRequest is suppressed:“+ "potential impersonation attacks"); }
  • 19. 18/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Security Policy Patterns (3) • Preventing forgery attacks, e.g. – open a new window without the location bar: enforce corresponding invariants – faked links: detect and disable the faked links Dagstuhl 09141, 2 April 2009 var checkLinks = function(){ var links = document.links; if (!links){ policylog('no links'); return; } for(var i = 0; i < links.length; i++) { if (!AllowedLinks(links[i].href)) { links[i].href = "javascript:alert('disabled link')"; } } }
  • 20. 19/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Security Policy Patterns (4) • Preventing resource abuse – limit or prohibit potential abuse functions Dagstuhl 09141, 2 April 2009
  • 21. 20/18Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Overhead Render: 5.37% Weaving slowdown 6,33 times (We measure micro-benchmark with operations) Dagstuhl 09141, 2 April 2009
  • 22. 21/18 Limitations • Policies cannot span multiple pages – frame and iframe are separate pages! • Implementation Specific Solutions and Problems – Use of custom getter and setter (in Mozilla, but not in IE) – Problems handling Mozilla’s delete semantics Both problems solved in ECMA-262 v3.1 proposal Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
  • 23. 22/18 Summary • Our approach is to control and modify the behaviour of JavaScript by transforming the code to make it self-protecting – no browser modifications – non-invasive • solve the problem of dynamic scripts • avoiding the need for extensive runtime code transformation Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
  • 24. 23/18 Further concerns • Case studies for particular web applications • Integration with other methods • Securing JavaScript AOP Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009
  • 25. ASIACCS'09, 10 March 2009Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se
  • 26. 25/18 Attacks to the Unique Reference Property • Restoring built-in methods from another page – Creates a new window, frame or iframe to manufacture a pointer to the original built-in methods • Mozilla’s delete operator – Our wrapper methods are not built-in, they are deletable and the deletion exposes the original built-in. Phu H. Phung, David Sands, Andrey Chudnov – cse.chalmers.se Dagstuhl 09141, 2 April 2009