SlideShare ist ein Scribd-Unternehmen logo
1 von 23
#ABOUT ME
• Shubham Gupta (@hackerspider1)
• IT – Security Analyst at Broctagon Solutions.
• Bug Bounty Hunter.
• Capture The Flag (CTF) player.
• Acknowledged by more then 200 Organization.
2
TODAYS TALK
• Introduction
• Impact
• Types of XSS
• How XSS works
• Demo
• XSS Prevention
• Q&A?
3
INTRODUCTION TO XSS
•XSS is a code injection attack allowing the injection of
malicious code into a website
•Currently one of the most common attack
•Every website needs to turn on Javascript
•Caused by insufficient input validation
•JavaScript, VBScript, ActiveX, HTML, or Flash
4
IMPACT
• Stealing other user’s cookies
• Stealing their private information
• Performing actions on behalf of other users
• Redirecting to other websites
• Showing ads in hidden iframes and pop-ups
5
TYPES OF XSS
• Non-persistent XSS
• Persistent XSS
• Dom based XSS
6
NON-PERSISTENT XSS
• Non-persistent XSS or Reflected XSS
• Query in HTTP parameters or HTML form
• Affects XSS without properly sanitizing the request
7
PERSISTENT XSS
• Persistent XSS or Stored XSS
• Occurs when data is saved on server side
• Classic example: message board
8
DOM BASED XSS
•DOM (Document Object Model)
•Cross-site scripting vulnerability
•Appears in the DOM instead of part of the
HTML
•The payload cannot be found in the response
•Observed on runtime or by investigating the
DOM of the page
9
Example
…
var pos =
document.URL.indexOf("name=")+5
;
document.write(document.URL.sub
string(pos,document.URL.length));
HOW XSS WORKS?
• Web server gets data from web client
(POST, GET, COOKIES etc.) with the
request
• Malicious user can include client sidecode
snippets (javascript) into the data
10
Example :
Shubham<script>alert(“hacked”)</
script>
11
Server
Hacker’s Browser
http request with
XSS JavaScript
http response with
XSS JavaScript
XSS OUTPUT
12
DEMO
13
REFLECTED XSS
14
15
STORED XSS
16
17
DOM BASED XSS
18
PREVENTIONS
•MORE THAN 70% OF WEB SECURITY ISSUES CAUSED BY XSS
•NEVER TRUST USER/CLIENT INPUT!
• CLIENT-SIDE CHECKS/CONTROLS HAVE TO BE INVOKED ON THE SERVER
TOO.
•IMPROPER INPUT VALIDATION
•IMPROPER OUTPUT VALIDATION
19
20
•VALIDATE INPUT
•LETTERS IN A NUMBER FIELD?
•10 DIGITS FOR 4 DIGIT YEAR FIELD?
•OFTEN ONLY NEED ALPHANUMERIC
•CAREFUL WITH < > " ' AND =
•WHITELIST (E.G. /[A-ZA-Z0-9]{0,20}/)
•REJECT, DON’T TRY AND SANITIZE
21
• VALIDATE OUTPUT
•ENCODE HTML OUTPUT
• IF DATA CAME FROM USER INPUT, A DATABASE, OR A FILE
• RESPONSE.WRITE(HTTPUTILITY.HTMLENCODE(REQUEST.FORM["NAME
"]));
• NOT 100% EFFECTIVE BUT PREVENTS MOST VULNERABILITIES
•ENCODE URL OUTPUT
• IF RETURNING URL STRINGS
• RESPONSE.WRITE(HTTPUTILITY.URLENCODE(URLSTRING));
THANKS
22
Q&A?
23

Weitere ähnliche Inhalte

Was ist angesagt?

Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
levigross
 
Web security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-kearyWeb security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-keary
drewz lin
 

Was ist angesagt? (20)

Make profit with UI-Redressing attacks.
Make profit with UI-Redressing attacks.Make profit with UI-Redressing attacks.
Make profit with UI-Redressing attacks.
 
Ekoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's MethodologyEkoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's Methodology
 
Bounty Craft: Bug bounty reports how do they work, @sushihack presents at Nu...
Bounty Craft: Bug bounty reports  how do they work, @sushihack presents at Nu...Bounty Craft: Bug bounty reports  how do they work, @sushihack presents at Nu...
Bounty Craft: Bug bounty reports how do they work, @sushihack presents at Nu...
 
Logical Attacks(Vulnerability Research)
Logical Attacks(Vulnerability Research)Logical Attacks(Vulnerability Research)
Logical Attacks(Vulnerability Research)
 
Nbt con december-2014-slides
Nbt con december-2014-slidesNbt con december-2014-slides
Nbt con december-2014-slides
 
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
 
Writing vuln reports that maximize payouts - Nullcon 2016
Writing vuln reports that maximize payouts - Nullcon 2016Writing vuln reports that maximize payouts - Nullcon 2016
Writing vuln reports that maximize payouts - Nullcon 2016
 
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)
 
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
 
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
 
Locking Down Your WordPress Site
Locking Down Your WordPress SiteLocking Down Your WordPress Site
Locking Down Your WordPress Site
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirty
 
Introduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & DefenseIntroduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & Defense
 
Word camp pune 2013 security
Word camp pune 2013   securityWord camp pune 2013   security
Word camp pune 2013 security
 
Web security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-kearyWeb security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-keary
 
Kludges and PHP. Why Should You Use a WAF?
Kludges and PHP. Why Should You Use a WAF?Kludges and PHP. Why Should You Use a WAF?
Kludges and PHP. Why Should You Use a WAF?
 
MR201504 Web Defacing Attacks Targeting WordPress
MR201504 Web Defacing Attacks Targeting WordPressMR201504 Web Defacing Attacks Targeting WordPress
MR201504 Web Defacing Attacks Targeting WordPress
 
JavaScript Security
JavaScript SecurityJavaScript Security
JavaScript Security
 
Two scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesTwo scoops of Django - Security Best Practices
Two scoops of Django - Security Best Practices
 

Ähnlich wie XSS (Cross Site Scripting)

Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
OWASP Khartoum
 
웹 개발을 위해 꼭 알아야하는 보안 공격
웹 개발을 위해 꼭 알아야하는 보안 공격웹 개발을 위해 꼭 알아야하는 보안 공격
웹 개발을 위해 꼭 알아야하는 보안 공격
선협 이
 
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
 

Ähnlich wie XSS (Cross Site Scripting) (20)

Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101
 
Devbeat Conference - Developer First Security
Devbeat Conference - Developer First SecurityDevbeat Conference - Developer First Security
Devbeat Conference - Developer First Security
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
 
Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)
 
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)
 
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
 
Security Vulnerabilities
Security VulnerabilitiesSecurity Vulnerabilities
Security Vulnerabilities
 
Owasp Top 10 A3: Cross Site Scripting (XSS)
Owasp Top 10 A3: Cross Site Scripting (XSS)Owasp Top 10 A3: Cross Site Scripting (XSS)
Owasp Top 10 A3: Cross Site Scripting (XSS)
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
Html5 security
Html5 securityHtml5 security
Html5 security
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
 
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)
 
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
CNIT 129S: Ch 12: Attacking Users: Cross-Site ScriptingCNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
 
Ch 12 Attacking Users - XSS
Ch 12 Attacking Users - XSSCh 12 Attacking Users - XSS
Ch 12 Attacking Users - XSS
 
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
CNIT 129S: Ch 12: Attacking Users: Cross-Site ScriptingCNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
 
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
 
웹 개발을 위해 꼭 알아야하는 보안 공격
웹 개발을 위해 꼭 알아야하는 보안 공격웹 개발을 위해 꼭 알아야하는 보안 공격
웹 개발을 위해 꼭 알아야하는 보안 공격
 
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...
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 

Kürzlich hochgeladen

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Kürzlich hochgeladen (20)

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 

XSS (Cross Site Scripting)

  • 1.
  • 2. #ABOUT ME • Shubham Gupta (@hackerspider1) • IT – Security Analyst at Broctagon Solutions. • Bug Bounty Hunter. • Capture The Flag (CTF) player. • Acknowledged by more then 200 Organization. 2
  • 3. TODAYS TALK • Introduction • Impact • Types of XSS • How XSS works • Demo • XSS Prevention • Q&A? 3
  • 4. INTRODUCTION TO XSS •XSS is a code injection attack allowing the injection of malicious code into a website •Currently one of the most common attack •Every website needs to turn on Javascript •Caused by insufficient input validation •JavaScript, VBScript, ActiveX, HTML, or Flash 4
  • 5. IMPACT • Stealing other user’s cookies • Stealing their private information • Performing actions on behalf of other users • Redirecting to other websites • Showing ads in hidden iframes and pop-ups 5
  • 6. TYPES OF XSS • Non-persistent XSS • Persistent XSS • Dom based XSS 6
  • 7. NON-PERSISTENT XSS • Non-persistent XSS or Reflected XSS • Query in HTTP parameters or HTML form • Affects XSS without properly sanitizing the request 7
  • 8. PERSISTENT XSS • Persistent XSS or Stored XSS • Occurs when data is saved on server side • Classic example: message board 8
  • 9. DOM BASED XSS •DOM (Document Object Model) •Cross-site scripting vulnerability •Appears in the DOM instead of part of the HTML •The payload cannot be found in the response •Observed on runtime or by investigating the DOM of the page 9 Example … var pos = document.URL.indexOf("name=")+5 ; document.write(document.URL.sub string(pos,document.URL.length));
  • 10. HOW XSS WORKS? • Web server gets data from web client (POST, GET, COOKIES etc.) with the request • Malicious user can include client sidecode snippets (javascript) into the data 10 Example : Shubham<script>alert(“hacked”)</ script>
  • 11. 11 Server Hacker’s Browser http request with XSS JavaScript http response with XSS JavaScript
  • 15. 15
  • 17. 17
  • 19. PREVENTIONS •MORE THAN 70% OF WEB SECURITY ISSUES CAUSED BY XSS •NEVER TRUST USER/CLIENT INPUT! • CLIENT-SIDE CHECKS/CONTROLS HAVE TO BE INVOKED ON THE SERVER TOO. •IMPROPER INPUT VALIDATION •IMPROPER OUTPUT VALIDATION 19
  • 20. 20 •VALIDATE INPUT •LETTERS IN A NUMBER FIELD? •10 DIGITS FOR 4 DIGIT YEAR FIELD? •OFTEN ONLY NEED ALPHANUMERIC •CAREFUL WITH < > " ' AND = •WHITELIST (E.G. /[A-ZA-Z0-9]{0,20}/) •REJECT, DON’T TRY AND SANITIZE
  • 21. 21 • VALIDATE OUTPUT •ENCODE HTML OUTPUT • IF DATA CAME FROM USER INPUT, A DATABASE, OR A FILE • RESPONSE.WRITE(HTTPUTILITY.HTMLENCODE(REQUEST.FORM["NAME "])); • NOT 100% EFFECTIVE BUT PREVENTS MOST VULNERABILITIES •ENCODE URL OUTPUT • IF RETURNING URL STRINGS • RESPONSE.WRITE(HTTPUTILITY.URLENCODE(URLSTRING));

Hinweis der Redaktion

  1. These holes show up when the data provided by a web client, most commonly in HTTP query parameters or in HTML form submissions, is used immediately by server-side scripts to generate a page of results for that user, without properly sanitizing the request. Because HTML documents have a flat, serial structure that mixes control statements, formatting, and the actual content, any non-validated user-supplied data included in the resulting page without proper HTML encoding, may lead to markup injection. 
  2. It occurs when the data provided by the attacker is saved by the server, and then permanently displayed on “normal” pages returned to other users in the course of regular browsing, without proper HTML escaping. A classic example of this is with online message boards where users are allowed to post HTML formatted messages for other users to read.
  3. DOM Based XSS simply means a Cross-site scripting vulnerability that appears in the DOM (Document Object Model) instead of part of the HTML. In reflective and stored Cross-site scripting attacks you can see the vulnerability payload in the response page but in DOM based cross-site scripting, the HTML source code and response of the attack will be exactly the same, i.e. the payload cannot be found in the response. It can only be observed on runtime or by investigating the DOM of the page. Example … var pos = document.URL.indexOf("name=")+5; document.write(document.URL.substring(pos,document.URL.length));