SlideShare une entreprise Scribd logo
1  sur  22
Developing Secure Web
Application
Cross-Site Scripting
(XSS)
Cezar Coca
Endava

10th of November 2012
Agenda


• Why?
• Formal description
• Same Origin Policy
• How to perform an XSS attack
• Demo
• Prevention of XSS attacks
OWASP Top Ten (2010 Edition)




                        http://www.owasp.org/index.php/Top_10
At first sight




                 =
Second sight
XSS formal description

Types – at least two primary flavors

• Non-persistent (or reflected)
• Persistent (or stored)
Typical impact
• Steal user’s session (hijack session)
• Rewrite web page
• Redirect user to phishing or malware site
• Most Severe: Install XSS proxy
Same Origin Policy – Security Domain
Same Origin Policy - DOM
Same Origin Policy - DOM
Same Origin Policy - DOM
Reflected XSS Illustrated




             Attacker send the victim a misleading email with a link
         1
             containing malicious JavaScript
Reflected XSS Illustrated


When the victim clicks on the
link, the HTTP request is initiated
from the victim's browser and
sent to the vulnerable Web
application.                                  2




                    Attacker send the victim a misleading email with a link
              1
                    containing malicious JavaScript
Reflected XSS Illustrated
                                                  The malicious JavaScript is then
                                                  reflected back to the victim's browser,
                                                  where it is executed in the context of
When the victim clicks on the                     the victim user's session
link, the HTTP request is initiated
from the victim's browser and                           3
sent to the vulnerable Web
application.                                  2




                    Attacker send the victim a misleading email with a link
              1
                    containing malicious JavaScript
DEMO – deployment diagram
LET’S HACK
Second sight
Prevention of XSS Attack – part 1
• Input Validation
  • Canonicalize data first
      •   Prevent encoded attacks

  •   Black list testing is no solution
      •    Black lists are never complete!

  •   White list testing is better
      •   Only what you expect will pass

      •   Regular expressions

  • HTML Encoding
      •   HTML encoding of all input when put into output pages
Prevention of XSS Attack – Multiple contexts
Browser have multiple contexts that must be considered!




     HTML        HTML       <STYLE>    <SCRIPT>      URL
     Body      Attributes   Context     Context     Context
Prevention of XSS Attack – Session Hijacking
• Session hijacking
  • “HttpOnly" Cookies
  • "secure" Cookies. Cookies are only sent over SSL
  • Disable TRACE
• References:
  • http://www.owasp.org/index.php/XSS_(Cross Site Scripting) Prevention
    Cheat Sheet

  • http://ha.ckers.org/xss.html
  • http://www.owasp.org/index.php/ESAPI
Diamond Sponsors




Platinum Sponsors                    Gold Sponsors


Training Partners   Media Partners          Other Partners

Contenu connexe

Tendances

Cm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xssCm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xss
dcervigni
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site Scripting
Ali Mattash
 
Xss 101 by-sai-shanthan
Xss 101 by-sai-shanthanXss 101 by-sai-shanthan
Xss 101 by-sai-shanthan
Raghunath G
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
Manish Kumar
 
The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting Guide
Daisuke_Dan
 

Tendances (20)

Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
XSS- an application security vulnerability
XSS-   an application security vulnerabilityXSS-   an application security vulnerability
XSS- an application security vulnerability
 
Xss
XssXss
Xss
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
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
 
Cm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xssCm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xss
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
 
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)
 
Secure coding | XSS Attacks on current Web Applications
Secure coding | XSS Attacks on current Web ApplicationsSecure coding | XSS Attacks on current Web Applications
Secure coding | XSS Attacks on current Web Applications
 
Xss what the heck-!
Xss   what the heck-!Xss   what the heck-!
Xss what the heck-!
 
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
 
Identifying XSS Vulnerabilities
Identifying XSS VulnerabilitiesIdentifying XSS Vulnerabilities
Identifying XSS Vulnerabilities
 
Xss 101 by-sai-shanthan
Xss 101 by-sai-shanthanXss 101 by-sai-shanthan
Xss 101 by-sai-shanthan
 
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 (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
 
The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting Guide
 

Similaire à Developing Secure Web Application - Cross-Site Scripting (XSS)

Web application security
Web application securityWeb application security
Web application security
Jin Castor
 
Report on xss and do s
Report on xss and do sReport on xss and do s
Report on xss and do s
mehr77
 
logout.php Session Data after Logout Username Email . $_.docx
logout.php Session Data after Logout  Username  Email  . $_.docxlogout.php Session Data after Logout  Username  Email  . $_.docx
logout.php Session Data after Logout Username Email . $_.docx
smile790243
 

Similaire à Developing Secure Web Application - Cross-Site Scripting (XSS) (20)

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 XSSCross site scripting XSS
Cross site scripting XSS
 
A Survey of Exploitation and Detection Methods of XSS Vulnerabilities.pptx
A Survey of Exploitation and Detection Methods of XSS Vulnerabilities.pptxA Survey of Exploitation and Detection Methods of XSS Vulnerabilities.pptx
A Survey of Exploitation and Detection Methods of XSS Vulnerabilities.pptx
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scriptingSecure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
 
Xss frame work
Xss frame workXss frame work
Xss frame work
 
Web application security
Web application securityWeb application security
Web application security
 
Webapplicationsecurity05 2010 100601100553 Phpapp02
Webapplicationsecurity05 2010 100601100553 Phpapp02Webapplicationsecurity05 2010 100601100553 Phpapp02
Webapplicationsecurity05 2010 100601100553 Phpapp02
 
Client sidesec 2013 - script injection
Client sidesec 2013 - script injectionClient sidesec 2013 - script injection
Client sidesec 2013 - script injection
 
Xss ppt
Xss pptXss ppt
Xss ppt
 
Application Context and Discovering XSS without
Application Context and Discovering XSS without Application Context and Discovering XSS without
Application Context and Discovering XSS without
 
Report on xss and do s
Report on xss and do sReport on xss and do s
Report on xss and do s
 
Xss attack
Xss attackXss attack
Xss attack
 
Secure webbrowsing 1
Secure webbrowsing 1Secure webbrowsing 1
Secure webbrowsing 1
 
logout.php Session Data after Logout Username Email . $_.docx
logout.php Session Data after Logout  Username  Email  . $_.docxlogout.php Session Data after Logout  Username  Email  . $_.docx
logout.php Session Data after Logout Username Email . $_.docx
 
Secure Form Processing and Protection - Sunshine PHP 2015
Secure Form Processing and Protection - Sunshine PHP 2015Secure Form Processing and Protection - Sunshine PHP 2015
Secure Form Processing and Protection - Sunshine PHP 2015
 
Session7-XSS & CSRF
Session7-XSS & CSRFSession7-XSS & CSRF
Session7-XSS & CSRF
 
Convincing Developers to take Cross-Site Scripting Seriously
Convincing Developers to take Cross-Site Scripting SeriouslyConvincing Developers to take Cross-Site Scripting Seriously
Convincing Developers to take Cross-Site Scripting Seriously
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
 
Web Security.pdf
Web Security.pdfWeb Security.pdf
Web Security.pdf
 
Xss ppt
Xss pptXss ppt
Xss ppt
 

Plus de Codecamp Romania

Plus de Codecamp Romania (20)

Cezar chitac the edge of experience
Cezar chitac   the edge of experienceCezar chitac   the edge of experience
Cezar chitac the edge of experience
 
Cloud powered search
Cloud powered searchCloud powered search
Cloud powered search
 
Ccp
CcpCcp
Ccp
 
Business analysis techniques exercise your 6-pack
Business analysis techniques   exercise your 6-packBusiness analysis techniques   exercise your 6-pack
Business analysis techniques exercise your 6-pack
 
Bpm company code camp - configuration or coding with pega
Bpm company   code camp - configuration or coding with pegaBpm company   code camp - configuration or coding with pega
Bpm company code camp - configuration or coding with pega
 
Andrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabaseAndrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabase
 
Agility and life
Agility and lifeAgility and life
Agility and life
 
2015 dan ardelean develop for windows 10
2015 dan ardelean   develop for windows 10 2015 dan ardelean   develop for windows 10
2015 dan ardelean develop for windows 10
 
The bigrewrite
The bigrewriteThe bigrewrite
The bigrewrite
 
The case for continuous delivery
The case for continuous deliveryThe case for continuous delivery
The case for continuous delivery
 
Stefan stolniceanu spritekit, 2 d or not 2d
Stefan stolniceanu   spritekit, 2 d or not 2dStefan stolniceanu   spritekit, 2 d or not 2d
Stefan stolniceanu spritekit, 2 d or not 2d
 
Sizing epics tales from an agile kingdom
Sizing epics   tales from an agile kingdomSizing epics   tales from an agile kingdom
Sizing epics tales from an agile kingdom
 
Scale net apps in aws
Scale net apps in awsScale net apps in aws
Scale net apps in aws
 
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
 
Parallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowParallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflow
 
Material design screen transitions in android
Material design screen transitions in androidMaterial design screen transitions in android
Material design screen transitions in android
 
Kickstart your own freelancing career
Kickstart your own freelancing careerKickstart your own freelancing career
Kickstart your own freelancing career
 
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu   the soft stuff is the hard stuff. the agile soft skills toolkitIonut grecu   the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
 
Ecma6 in the wild
Ecma6 in the wildEcma6 in the wild
Ecma6 in the wild
 
Diana antohi me against myself or how to fail and move forward
Diana antohi   me against myself  or how to fail  and move forwardDiana antohi   me against myself  or how to fail  and move forward
Diana antohi me against myself or how to fail and move forward
 

Developing Secure Web Application - Cross-Site Scripting (XSS)

  • 1. Developing Secure Web Application Cross-Site Scripting (XSS) Cezar Coca Endava 10th of November 2012
  • 2. Agenda • Why? • Formal description • Same Origin Policy • How to perform an XSS attack • Demo • Prevention of XSS attacks
  • 3. OWASP Top Ten (2010 Edition) http://www.owasp.org/index.php/Top_10
  • 6. XSS formal description Types – at least two primary flavors • Non-persistent (or reflected) • Persistent (or stored) Typical impact • Steal user’s session (hijack session) • Rewrite web page • Redirect user to phishing or malware site • Most Severe: Install XSS proxy
  • 7. Same Origin Policy – Security Domain
  • 11. Reflected XSS Illustrated Attacker send the victim a misleading email with a link 1 containing malicious JavaScript
  • 12. Reflected XSS Illustrated When the victim clicks on the link, the HTTP request is initiated from the victim's browser and sent to the vulnerable Web application. 2 Attacker send the victim a misleading email with a link 1 containing malicious JavaScript
  • 13. Reflected XSS Illustrated The malicious JavaScript is then reflected back to the victim's browser, where it is executed in the context of When the victim clicks on the the victim user's session link, the HTTP request is initiated from the victim's browser and 3 sent to the vulnerable Web application. 2 Attacker send the victim a misleading email with a link 1 containing malicious JavaScript
  • 17. Prevention of XSS Attack – part 1 • Input Validation • Canonicalize data first • Prevent encoded attacks • Black list testing is no solution • Black lists are never complete! • White list testing is better • Only what you expect will pass • Regular expressions • HTML Encoding • HTML encoding of all input when put into output pages
  • 18. Prevention of XSS Attack – Multiple contexts Browser have multiple contexts that must be considered! HTML HTML <STYLE> <SCRIPT> URL Body Attributes Context Context Context
  • 19. Prevention of XSS Attack – Session Hijacking • Session hijacking • “HttpOnly" Cookies • "secure" Cookies. Cookies are only sent over SSL • Disable TRACE • References: • http://www.owasp.org/index.php/XSS_(Cross Site Scripting) Prevention Cheat Sheet • http://ha.ckers.org/xss.html • http://www.owasp.org/index.php/ESAPI
  • 20.
  • 21.
  • 22. Diamond Sponsors Platinum Sponsors Gold Sponsors Training Partners Media Partners Other Partners