SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Hacking and Information Security Group
Organised with TechNext
Mr. Sandip Chaudhari
•13+ years experience in Software and Information Security Industry
•6+ years worked as a Professional Software Security Analyst and Secure Code
Auditor
•100+ in-house vulnerabilities discovered and reported
•Presented Security Research Paper at various security conferences around the
globe including New York, USA, Luxembourg, Luxembourg, Tokyo, Japan, Bangalore,
India
•Undertook multiple responsibilities in various roles like – Security Analyst,
Application Developer, Project Manager, Software Application Architect,
Information Security Researcher, CTO
•Proud to have worked along with, and be part of group that included – Dino Dai
Zovi, Shane Macaulay, Adam Green, Jonathan Leonard and Jeremy Jethro
Organizer and Mentor
We Are…The Speakers…
Sudarshan Pawar
Certified Security Expert(C.S.E.)
Certified Information Security Specialist (C.I.S.S.)
Security Xplained (TechNext Speaker)
Pursuing B.E.(Computer)
& a Security Professional
Prakashchandra Suthar
Cisco Certified Network Associate
Red Hat Linux Certified
Security Xplained (TechNext Speaker)
Computer Engg
Security Researcher
WHY are we in this room on weekend rather than
enjoying hot beverage on a rainy day?
Today’s Agenda
1. XSS: What does it mean?
2. Birth
3. Stats
4. Working
5. The Havoc it Created
6. Reason of attack
7. Causes
8. Types of XSS
9. Vulnerabilities in web programming
10. Solutions
11. Prevention Mechanisms
Blah blah….
CAPTURE THE FLAG
D.I.Y. (Do it yourself and
experience the dark side of the
Force...!!!)
Session 1 Session 2
BIRTH OF XSS
• Netscape introduced JavaScript in 1995. Soon
after, hackers realize that when someone surfs
their website they can force load any website
(webmail, banks, auction sites) in a frame and
use JavaScript to cross boundaries between the
two sites hence the name “cross site scripting.”
• The XSS explosion came in 2005 when the Samy
worm took down MySpace.
STATS
STATS: XSS ATTACKS
FEW AFFECTED ORGANISATIONS…
Myspace
Myspace Samy attack
PayPal
Annauniversity
Avast.
XSS Attack Scenario
www.sometrustedwebsite.com
Asia America Europe
BEFORE ATTACK…
www.sometrustedwebsite.com
Asia America Europe
AFTER ATTACK
(Injects script)
Injected Script can be:
• Malicious page
•Explicit Images
•Bots(to make zombies)
•Redirecting links
•Fake Login Pages
•Etc. etc.
(NOTE: Names of Continents is JUST used as an example representing users accessing a
trusted website)
How much financial loss it costs?
How much it will cost if your online bank
account is attacked ?
(Big Hint: Please be bold, take the lead,
stand-up and share how much money you
got in your bank right now)
CAN U TAKE THIS TYPE OF CHANCE….??
CAUSES
•A XSS vulnerability is majorly caused by
the failure of a site to sanitize user input
before returning it to the client’s web-
browser
REASON OF ATTACK
• Change Settings
• Cookie theft
• False Advertising
• Steal Form Tokens to make XSRF Easier
• And more, you have to be creative to exploit XSS
There are Three Types of XSS
• Persistent (Stored) XSS : Attack is stored on the
website server
• Non Persistent (reflected) XSS: user has to go through
a special link to be exposed
• DOM-based XSS: problem exists within the client-
side script
XSS Types
UNSANITIZED CODE: STORED XSS
<?php
?>
if(isset($_POST['btnSign']))
{
$message = trim($_POST['mtxMessage']);
$name = trim($_POST['txtName']);
// Sanitize message input
$message = stripslashes($message);
$message = mysql_real_escape_string($message);
// Sanitize name input
$name = mysql_real_escape_string($name);
$query = "INSERT INTO guestbook (comment,name) VALUES ('$messa
ge','$name');";
$result = mysql_query($query) or die('<pre>' . mysql_error() . '</pre>' );
}
UNSANITIZED CODE: REFLECTED XSS
<?php
{
Else // else generates HTML page on user input
{
echo '<pre>';
echo 'Hello ' . $_GET['name'];
echo '</pre>';
}
?>
$isempty = true;
}
if(!
array_key_exists ("name", $_GET) || $_GET['name'] == NULL || $_GET
['name'] == '') //checks for empty text...
DOM-Based XSS
Var html=
[ ‘<form class = “config”>’, ‘<fieldset>’ ,
‘<label for=“appSuite”>enter url:</label>’,
‘<input type=“text” name=“appSuite”
id=“appSuite”
value=“ ‘ ,options.appendUrl || ”,’ “/>’
‘</fieldset>’, </form>].join(‘ ’),
dlg=$((html)appendTo($body));
Solutions Fast Track
Filtering
1.Filtering can deliver unexpected results if you
aren’t careful to monitor the output.
2.Using a loop can reduce the risks associated with
filtering out content.
3.Filtering alone can introduce new risks by
creating new types of attacks. Therefore, it is
critical to understand the order in which filters are
applied and how they interact with one another.
Input Encoding
1. Input encoding can create a single choke point for
all encoding.
2.Things like SQL injection and command injection
can also be checked prior to storing information in a
database.
3. Input encoding cannot stop persistent XSS once
stored.
Output Encoding
1. Output encoding is more granular and can take
context into account.
2. Developers must perform output encoding
potentially many times for each location the
information is outputted.
Web Browser’s Security
1. Beware of long or overly complex URLs. Often
these are the most likely to contain vulnerabilities.
2. Do not click on unknown URLs in e-mail if at all
possible.
3. Choose a secure browser and customize your
security settings to reduce the risk of exploitation.
CODE SOLUTION: Stored xss
<?php
if(isset($_POST['btnSign']))
{
$message = trim($_POST['mtxMessage']);
$name = trim($_POST['txtName']);
// Sanitize message input
$message = stripslashes($message);
$message = mysql_real_escape_string($message);
$message = htmlspecialchars($message); 
// Sanitize name input
$name = stripslashes($name);
$name = mysql_real_escape_string($name);
$name = htmlspecialchars($name); 
$query = "INSERT INTO guestbook (comment,name) VALUES ('$message','$name');";
$result = mysql_query($query) or die('<pre>' . mysql_error() . '</pre>' );
}
SOLUTION:Reflected XSS
<?php
if(!array_key_exists ("name", $_GET) || $_GET['name'] == NULL ||
$_GET['name'] == '')
{
$isempty = true;
}
Else
{
echo '<pre>';
echo 'Hello ' . htmlspecialchars($_GET['name']);
echo '</pre>';
}
?>
DOM-Based
Var html=
‘<form class = “config”>’, ‘<fieldset>’ ,
‘<label for=“appSuite”>enter url:</label>’,
‘<input type=“text” name=“appSuite” id=“appSuite”
value=“ ‘ ,options.appendUrl || ”,’ “/>’
‘</fieldset>’, </form>.join(‘ ’),
dlg=$(html)appendTo($(‘body’));
appSuite.val(options.appSuiteUrl || ‘ ‘);
Rebels?
Tinkering?
Go beyond programming
Attack attacker’s attack
Attitude! Matters. But beware of the Dark Side
About You…
Any Doubts….
FAQ’s
1.Is there a safe browser?
2. Are you safe if you turn off JavaScript?
3. How can I stop myself from becoming
a victim of a JavaScript worm?
4.It’s hopeless. I can’t trust a single Web application.
Why did you do this to me?
5. I think I am infected. What can I do?
6. Does my anti-virus software protect me from XSS
attacks?
7. Can XSS worm propagate on my system?
8. XSS attacks can compromise my online account but
not my network.Is that true?
9. What is the best technique to evade XSS filters?
10. Are persistent XSS vulnerabilities more severe
than non-persistent ones?
11. How many URL’s can be tested in the various
history stealing hacks?
12. I run XYZ program that creates an HTML report.
How can I determine if it is vulnerable?
13. Is the browser-hijacking feature in XSS-proxy persistent?
XSS Lab
• Now is your chance to try some
hands on!
• Experience the thrill of hacking
• You’ve got to hack a blogger web
application using XSS
• For site URL refer the white-board
XSS Lab - Goal
• Goal of the lab is to steal the session
cookie of the logged in user (demo)
on the blogger application
• Use that cookie locally and login as
the demo user
• Demo user has an un-published
secret post, saved as draft, that has
some secret content
• All posts – published and drafts are
accessible after logging in, using
menu link – Manage Posts
• Call us as soon as you are able to
access the secret post!
XSS Lab – Code Review:
Vulnerability & Fix
Questions?
• What you want to ask, many already have that same
question on their mind. Be bold and lead
• OK, if you don’t want to speak and keep shut and keep
thinking about it in your mind and take those questions
home, make sure you email those to us and sleep well at
night!
What should be our topic for the next meet?
I hate to ask but, how can we make this better?

Weitere ähnliche Inhalte

Was ist angesagt?

Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Ikhade Maro Igbape
 
Reflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingReflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingInMobi Technology
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterMichael Coates
 
Cross Site Scripting(XSS)
Cross Site Scripting(XSS)Cross Site Scripting(XSS)
Cross Site Scripting(XSS)Nabin Dutta
 
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Cross site scripting (xss) attacks issues and defense - by sandeep kumbharCross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Cross site scripting (xss) attacks issues and defense - by sandeep kumbharSandeep Kumbhar
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scriptingkinish kumar
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Barrel Software
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defensesMohammed A. Imran
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scriptingashutosh rai
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)Manish Kumar
 
Deep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionDeep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionVishal Kumar
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Amit Tyagi
 
Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxAaron Weaver
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)Ritesh Gupta
 
Dom based xss
Dom based xssDom based xss
Dom based xssLê Giáp
 
What is xss, blind xss and xploiting google gadgets
What is xss, blind xss and xploiting google gadgetsWhat is xss, blind xss and xploiting google gadgets
What is xss, blind xss and xploiting google gadgetsZiv Ginsberg
 

Was ist angesagt? (20)

Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
 
Reflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingReflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site Scripting
 
Cross site scripting XSS
Cross site scripting XSSCross site scripting XSS
Cross site scripting XSS
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning Center
 
Cross Site Scripting(XSS)
Cross Site Scripting(XSS)Cross Site Scripting(XSS)
Cross Site Scripting(XSS)
 
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Cross site scripting (xss) attacks issues and defense - by sandeep kumbharCross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
Xss (cross site scripting)
Xss (cross site scripting)Xss (cross site scripting)
Xss (cross site scripting)
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defenses
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
 
Deep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionDeep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL Injection
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
 
Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert Box
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
 
Dom based xss
Dom based xssDom based xss
Dom based xss
 
What is xss, blind xss and xploiting google gadgets
What is xss, blind xss and xploiting google gadgetsWhat is xss, blind xss and xploiting google gadgets
What is xss, blind xss and xploiting google gadgets
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
XSS Injection Vulnerabilities
XSS Injection VulnerabilitiesXSS Injection Vulnerabilities
XSS Injection Vulnerabilities
 

Andere mochten auch

Grails vs XSS: Defending Grails against XSS attacks
Grails vs XSS: Defending Grails against XSS attacksGrails vs XSS: Defending Grails against XSS attacks
Grails vs XSS: Defending Grails against XSS attackstheratpack
 
Cross Site Scripting Augusta For Matrix Session
Cross Site Scripting Augusta For Matrix SessionCross Site Scripting Augusta For Matrix Session
Cross Site Scripting Augusta For Matrix SessionAbhishek kumar
 
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRFBe Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRFMark Stanton
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encodingEoin Keary
 
Denis Baranov: Root via XSS
Denis Baranov: Root via XSSDenis Baranov: Root via XSS
Denis Baranov: Root via XSSqqlan
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threatAvădănei Andrei
 
Cross Site Scripting - Web Defacement Techniques
Cross Site Scripting - Web Defacement TechniquesCross Site Scripting - Web Defacement Techniques
Cross Site Scripting - Web Defacement TechniquesRonan Dunne, CEH, SSCP
 
Cross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with JavaCross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with JavaJim Manico
 
Acunetix - Web Vulnerability Scanner
Acunetix -  Web Vulnerability ScannerAcunetix -  Web Vulnerability Scanner
Acunetix - Web Vulnerability ScannerComguard India
 
Sql Injection and XSS
Sql Injection and XSSSql Injection and XSS
Sql Injection and XSSMike Crabb
 
Netsparker - Hosting Zirvesi 2010
Netsparker - Hosting Zirvesi 2010Netsparker - Hosting Zirvesi 2010
Netsparker - Hosting Zirvesi 2010Onur YILMAZ
 
Xss what the heck-!
Xss   what the heck-!Xss   what the heck-!
Xss what the heck-!VodqaBLR
 
Acunetix technical presentation v7 setembro2011
Acunetix technical presentation v7 setembro2011Acunetix technical presentation v7 setembro2011
Acunetix technical presentation v7 setembro2011Wlad1m1r
 

Andere mochten auch (19)

Grails vs XSS: Defending Grails against XSS attacks
Grails vs XSS: Defending Grails against XSS attacksGrails vs XSS: Defending Grails against XSS attacks
Grails vs XSS: Defending Grails against XSS attacks
 
XSS - Attacks & Defense
XSS - Attacks & DefenseXSS - Attacks & Defense
XSS - Attacks & Defense
 
Cross Site Scripting Augusta For Matrix Session
Cross Site Scripting Augusta For Matrix SessionCross Site Scripting Augusta For Matrix Session
Cross Site Scripting Augusta For Matrix Session
 
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRFBe Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRF
 
Blind XSS & Click Jacking
Blind XSS & Click JackingBlind XSS & Click Jacking
Blind XSS & Click Jacking
 
Blind XSS
Blind XSSBlind XSS
Blind XSS
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 
XSS Remediation
XSS RemediationXSS Remediation
XSS Remediation
 
Denis Baranov: Root via XSS
Denis Baranov: Root via XSSDenis Baranov: Root via XSS
Denis Baranov: Root via XSS
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threat
 
Cross Site Scripting - Web Defacement Techniques
Cross Site Scripting - Web Defacement TechniquesCross Site Scripting - Web Defacement Techniques
Cross Site Scripting - Web Defacement Techniques
 
Cross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with JavaCross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with Java
 
Acunetix - Web Vulnerability Scanner
Acunetix -  Web Vulnerability ScannerAcunetix -  Web Vulnerability Scanner
Acunetix - Web Vulnerability Scanner
 
Sql Injection and XSS
Sql Injection and XSSSql Injection and XSS
Sql Injection and XSS
 
Netsparker - Hosting Zirvesi 2010
Netsparker - Hosting Zirvesi 2010Netsparker - Hosting Zirvesi 2010
Netsparker - Hosting Zirvesi 2010
 
Blind xss
Blind xssBlind xss
Blind xss
 
Apache Multiview Vulnerability
Apache Multiview VulnerabilityApache Multiview Vulnerability
Apache Multiview Vulnerability
 
Xss what the heck-!
Xss   what the heck-!Xss   what the heck-!
Xss what the heck-!
 
Acunetix technical presentation v7 setembro2011
Acunetix technical presentation v7 setembro2011Acunetix technical presentation v7 setembro2011
Acunetix technical presentation v7 setembro2011
 

Ähnlich wie Xss talk, attack and defense

Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultMohammed ALDOUB
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Jay Nagar
 
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
Mr. Mohammed Aldoub  - A case study of django web applications that are secur...Mr. Mohammed Aldoub  - A case study of django web applications that are secur...
Mr. Mohammed Aldoub - A case study of django web applications that are secur...nooralmousa
 
Django (Web Applications that are Secure by Default)
Django �(Web Applications that are Secure by Default�)Django �(Web Applications that are Secure by Default�)
Django (Web Applications that are Secure by Default)Kishor Kumar
 
Crash Course In Brain Surgery
Crash Course In Brain SurgeryCrash Course In Brain Surgery
Crash Course In Brain Surgerymorisson
 
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelinesZakaria SMAHI
 
Understanding Application Threat Modelling & Architecture
 Understanding Application Threat Modelling & Architecture Understanding Application Threat Modelling & Architecture
Understanding Application Threat Modelling & ArchitecturePriyanka Aash
 
The Principles of Secure Development - BSides Las Vegas 2009
The Principles of Secure Development - BSides Las Vegas 2009The Principles of Secure Development - BSides Las Vegas 2009
The Principles of Secure Development - BSides Las Vegas 2009Security Ninja
 
Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Aman Singh
 
Invited Talk - Cyber Security and Open Source
Invited Talk - Cyber Security and Open SourceInvited Talk - Cyber Security and Open Source
Invited Talk - Cyber Security and Open Sourcehack33
 
Security testing for web developers
Security testing for web developersSecurity testing for web developers
Security testing for web developersmatthewhughes
 
Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101 Stormpath
 
Thoughts on Defensive Development for Sitecore
Thoughts on Defensive Development for SitecoreThoughts on Defensive Development for Sitecore
Thoughts on Defensive Development for SitecorePINT Inc
 
LIFT OFF 2017: Ransomware and IR Overview
LIFT OFF 2017: Ransomware and IR OverviewLIFT OFF 2017: Ransomware and IR Overview
LIFT OFF 2017: Ransomware and IR OverviewRobert Herjavec
 

Ähnlich wie Xss talk, attack and defense (20)

Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by Default
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )
 
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
Mr. Mohammed Aldoub  - A case study of django web applications that are secur...Mr. Mohammed Aldoub  - A case study of django web applications that are secur...
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
 
Django (Web Applications that are Secure by Default)
Django �(Web Applications that are Secure by Default�)Django �(Web Applications that are Secure by Default�)
Django (Web Applications that are Secure by Default)
 
Crash Course In Brain Surgery
Crash Course In Brain SurgeryCrash Course In Brain Surgery
Crash Course In Brain Surgery
 
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelines
 
Cross site scripting
Cross site scripting Cross site scripting
Cross site scripting
 
Understanding Application Threat Modelling & Architecture
 Understanding Application Threat Modelling & Architecture Understanding Application Threat Modelling & Architecture
Understanding Application Threat Modelling & Architecture
 
The Principles of Secure Development - BSides Las Vegas 2009
The Principles of Secure Development - BSides Las Vegas 2009The Principles of Secure Development - BSides Las Vegas 2009
The Principles of Secure Development - BSides Las Vegas 2009
 
Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)
 
Invited Talk - Cyber Security and Open Source
Invited Talk - Cyber Security and Open SourceInvited Talk - Cyber Security and Open Source
Invited Talk - Cyber Security and Open Source
 
Security testing for web developers
Security testing for web developersSecurity testing for web developers
Security testing for web developers
 
Website Security: A Guide to Defending Your Website
Website Security: A Guide to Defending Your WebsiteWebsite Security: A Guide to Defending Your Website
Website Security: A Guide to Defending Your Website
 
Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101
 
Thoughts on Defensive Development for Sitecore
Thoughts on Defensive Development for SitecoreThoughts on Defensive Development for Sitecore
Thoughts on Defensive Development for Sitecore
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
 
Toronto mule meetup #5
Toronto mule meetup #5Toronto mule meetup #5
Toronto mule meetup #5
 
What is Ethical Hacking?
What is Ethical Hacking? What is Ethical Hacking?
What is Ethical Hacking?
 
LIFT OFF 2017: Ransomware and IR Overview
LIFT OFF 2017: Ransomware and IR OverviewLIFT OFF 2017: Ransomware and IR Overview
LIFT OFF 2017: Ransomware and IR Overview
 

Kürzlich hochgeladen

Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 

Kürzlich hochgeladen (20)

Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 

Xss talk, attack and defense

  • 1. Hacking and Information Security Group Organised with TechNext
  • 2. Mr. Sandip Chaudhari •13+ years experience in Software and Information Security Industry •6+ years worked as a Professional Software Security Analyst and Secure Code Auditor •100+ in-house vulnerabilities discovered and reported •Presented Security Research Paper at various security conferences around the globe including New York, USA, Luxembourg, Luxembourg, Tokyo, Japan, Bangalore, India •Undertook multiple responsibilities in various roles like – Security Analyst, Application Developer, Project Manager, Software Application Architect, Information Security Researcher, CTO •Proud to have worked along with, and be part of group that included – Dino Dai Zovi, Shane Macaulay, Adam Green, Jonathan Leonard and Jeremy Jethro Organizer and Mentor
  • 3. We Are…The Speakers… Sudarshan Pawar Certified Security Expert(C.S.E.) Certified Information Security Specialist (C.I.S.S.) Security Xplained (TechNext Speaker) Pursuing B.E.(Computer) & a Security Professional Prakashchandra Suthar Cisco Certified Network Associate Red Hat Linux Certified Security Xplained (TechNext Speaker) Computer Engg Security Researcher
  • 4. WHY are we in this room on weekend rather than enjoying hot beverage on a rainy day?
  • 5. Today’s Agenda 1. XSS: What does it mean? 2. Birth 3. Stats 4. Working 5. The Havoc it Created 6. Reason of attack 7. Causes 8. Types of XSS 9. Vulnerabilities in web programming 10. Solutions 11. Prevention Mechanisms Blah blah…. CAPTURE THE FLAG D.I.Y. (Do it yourself and experience the dark side of the Force...!!!) Session 1 Session 2
  • 6. BIRTH OF XSS • Netscape introduced JavaScript in 1995. Soon after, hackers realize that when someone surfs their website they can force load any website (webmail, banks, auction sites) in a frame and use JavaScript to cross boundaries between the two sites hence the name “cross site scripting.” • The XSS explosion came in 2005 when the Samy worm took down MySpace.
  • 16. www.sometrustedwebsite.com Asia America Europe AFTER ATTACK (Injects script) Injected Script can be: • Malicious page •Explicit Images •Bots(to make zombies) •Redirecting links •Fake Login Pages •Etc. etc. (NOTE: Names of Continents is JUST used as an example representing users accessing a trusted website)
  • 17. How much financial loss it costs? How much it will cost if your online bank account is attacked ? (Big Hint: Please be bold, take the lead, stand-up and share how much money you got in your bank right now)
  • 18. CAN U TAKE THIS TYPE OF CHANCE….??
  • 19. CAUSES •A XSS vulnerability is majorly caused by the failure of a site to sanitize user input before returning it to the client’s web- browser
  • 20. REASON OF ATTACK • Change Settings • Cookie theft • False Advertising • Steal Form Tokens to make XSRF Easier • And more, you have to be creative to exploit XSS
  • 21. There are Three Types of XSS • Persistent (Stored) XSS : Attack is stored on the website server • Non Persistent (reflected) XSS: user has to go through a special link to be exposed • DOM-based XSS: problem exists within the client- side script XSS Types
  • 22. UNSANITIZED CODE: STORED XSS <?php ?> if(isset($_POST['btnSign'])) { $message = trim($_POST['mtxMessage']); $name = trim($_POST['txtName']); // Sanitize message input $message = stripslashes($message); $message = mysql_real_escape_string($message); // Sanitize name input $name = mysql_real_escape_string($name); $query = "INSERT INTO guestbook (comment,name) VALUES ('$messa ge','$name');"; $result = mysql_query($query) or die('<pre>' . mysql_error() . '</pre>' ); }
  • 23. UNSANITIZED CODE: REFLECTED XSS <?php { Else // else generates HTML page on user input { echo '<pre>'; echo 'Hello ' . $_GET['name']; echo '</pre>'; } ?> $isempty = true; } if(! array_key_exists ("name", $_GET) || $_GET['name'] == NULL || $_GET ['name'] == '') //checks for empty text...
  • 24. DOM-Based XSS Var html= [ ‘<form class = “config”>’, ‘<fieldset>’ , ‘<label for=“appSuite”>enter url:</label>’, ‘<input type=“text” name=“appSuite” id=“appSuite” value=“ ‘ ,options.appendUrl || ”,’ “/>’ ‘</fieldset>’, </form>].join(‘ ’), dlg=$((html)appendTo($body));
  • 25. Solutions Fast Track Filtering 1.Filtering can deliver unexpected results if you aren’t careful to monitor the output. 2.Using a loop can reduce the risks associated with filtering out content. 3.Filtering alone can introduce new risks by creating new types of attacks. Therefore, it is critical to understand the order in which filters are applied and how they interact with one another.
  • 26. Input Encoding 1. Input encoding can create a single choke point for all encoding. 2.Things like SQL injection and command injection can also be checked prior to storing information in a database. 3. Input encoding cannot stop persistent XSS once stored. Output Encoding 1. Output encoding is more granular and can take context into account. 2. Developers must perform output encoding potentially many times for each location the information is outputted.
  • 27. Web Browser’s Security 1. Beware of long or overly complex URLs. Often these are the most likely to contain vulnerabilities. 2. Do not click on unknown URLs in e-mail if at all possible. 3. Choose a secure browser and customize your security settings to reduce the risk of exploitation.
  • 28. CODE SOLUTION: Stored xss <?php if(isset($_POST['btnSign'])) { $message = trim($_POST['mtxMessage']); $name = trim($_POST['txtName']); // Sanitize message input $message = stripslashes($message); $message = mysql_real_escape_string($message); $message = htmlspecialchars($message);  // Sanitize name input $name = stripslashes($name); $name = mysql_real_escape_string($name); $name = htmlspecialchars($name);  $query = "INSERT INTO guestbook (comment,name) VALUES ('$message','$name');"; $result = mysql_query($query) or die('<pre>' . mysql_error() . '</pre>' ); }
  • 29. SOLUTION:Reflected XSS <?php if(!array_key_exists ("name", $_GET) || $_GET['name'] == NULL || $_GET['name'] == '') { $isempty = true; } Else { echo '<pre>'; echo 'Hello ' . htmlspecialchars($_GET['name']); echo '</pre>'; } ?>
  • 30. DOM-Based Var html= ‘<form class = “config”>’, ‘<fieldset>’ , ‘<label for=“appSuite”>enter url:</label>’, ‘<input type=“text” name=“appSuite” id=“appSuite” value=“ ‘ ,options.appendUrl || ”,’ “/>’ ‘</fieldset>’, </form>.join(‘ ’), dlg=$(html)appendTo($(‘body’)); appSuite.val(options.appSuiteUrl || ‘ ‘);
  • 31. Rebels? Tinkering? Go beyond programming Attack attacker’s attack Attitude! Matters. But beware of the Dark Side About You…
  • 33. FAQ’s 1.Is there a safe browser? 2. Are you safe if you turn off JavaScript? 3. How can I stop myself from becoming a victim of a JavaScript worm? 4.It’s hopeless. I can’t trust a single Web application. Why did you do this to me? 5. I think I am infected. What can I do?
  • 34. 6. Does my anti-virus software protect me from XSS attacks? 7. Can XSS worm propagate on my system? 8. XSS attacks can compromise my online account but not my network.Is that true? 9. What is the best technique to evade XSS filters? 10. Are persistent XSS vulnerabilities more severe than non-persistent ones?
  • 35. 11. How many URL’s can be tested in the various history stealing hacks? 12. I run XYZ program that creates an HTML report. How can I determine if it is vulnerable? 13. Is the browser-hijacking feature in XSS-proxy persistent?
  • 36. XSS Lab • Now is your chance to try some hands on! • Experience the thrill of hacking • You’ve got to hack a blogger web application using XSS • For site URL refer the white-board
  • 37. XSS Lab - Goal • Goal of the lab is to steal the session cookie of the logged in user (demo) on the blogger application • Use that cookie locally and login as the demo user • Demo user has an un-published secret post, saved as draft, that has some secret content • All posts – published and drafts are accessible after logging in, using menu link – Manage Posts • Call us as soon as you are able to access the secret post!
  • 38. XSS Lab – Code Review: Vulnerability & Fix
  • 39. Questions? • What you want to ask, many already have that same question on their mind. Be bold and lead • OK, if you don’t want to speak and keep shut and keep thinking about it in your mind and take those questions home, make sure you email those to us and sleep well at night!
  • 40. What should be our topic for the next meet? I hate to ask but, how can we make this better?