SlideShare a Scribd company logo
Cross-site scripting
defense
Presented by
Sarker Iftekhar Alam
Yemi Aladeokin
Igbape Maro
Outline
 Introduction to XSS
 Conditions for Cross site scripting
 Cross site scripting key players
 Types of XSS
 How to test for cross site scripting
 Defending against Cross site scripting
 XSS prevention rules summary
 Conclusion
Introduction to XSS
Scripting: Web Browsers can execute commands
 Embedded in HTML page
 Supports different languages (JavaScript, VBScript, ActiveX, etc.)
 Most prominent: JavaScript
“Cross-Site” means: Foreign script sent via a server to a client
 Attacker makes Web-Server deliver malicious script code
 Malicious script is executed in Client’s Web Browser
Attack:
 Steal Access Credentials, Denial-of-Service, Modify Web pages
 Execute any command at the client machine
Cross-Site Scripting
Cross site scripting (XSS) vulnerability is mainly caused by the failure of web
applications in sanitizing user inputs embedded in web pages.
To add to this, many other attack methods, such as Information Disclosures,
Content Spoofing and Stolen Credentials could all be side-effects of an XSS attack.
CONDITIONS FOR CROSS-SITE SCRIPTING
 A Web application accepts user input
 The input is used to create dynamic content
 The input is insufficiently validated
Cross Site Scripting Defense Presentation
Cross-Site Scripting – Key Players
 An Attacker
• Anonymous Internet User
• Malicious Internal User
 An organization`s web server (i.e. Web application)
• External (e.g.: Shop, Information, CRM, Supplier)
• Internal (e.g.: Employees Self Service Portal)
 A Client
• Any type of customer
• Anonymous user accessing the Web-Server
Cross-Site Scripting – Key Players
Denial-of-Service
 Crash Users`Browser, Pop-Up-Flodding, Redirection
Access to authentication credentials for Web application
 Cookies, Username and Password
 Normal users (Personal data, Business data, Misuse of account)
 High privileged users (Control over Web application, web server and database)
Access to User`s machine
 Use ActiveX objects to control machine
 Upload local data to attacker`s machine
Spoil public image of company
Type of XSS
Stored or Persistent XSS:
 Data provided by a client is first stored on the server such as a database
or file system and later displayed to the users. This scenario usually
requires a particular kind of vulnerable application, particular one that
involves storing data in a database.
 Persistent XSS is less frequent but the damage can be more devastating
because once the payload is stored, it has the potential of infecting all
of the visitors to the vulnerable web page.
 Persistent XSS is also referred to as Type 2 XSS because the attack is
carried out via two requests: one for injecting malicious code and
having it stored on the web server, and the other for when victims load
HTML pages containing the payload.
 Typical goals of Persistent XSS attacks: Cookie theft and Data theft
Example:
Forums / message boards
Once a forum is identified as vulnerable, attackers may open a new topic and insert malicious
scripts in the topic title or body. They can also tag the topic using popular keywords so that the
topic is a popular search result. The content of the forum post will be stored by the server. When
the victims browse topics or search for certain keywords, they may reach the infected topic. When
the topic loads, its contents will be sent to the victim’s browser and the payload may be executed.
Alternatively, attackers may build tools that automatically post malicious scripts in replies on
popular / sticky topics, send private messages containing the payload to forum members, etc..
Defending Against Persistent / Stored
XSS
a) Server-side
 Validate User Input
The best way to prevent Persistent XSS is to make sure that all user input is properly
validated before it gets stored permanently on the web server,
 Sanitize static contents
A second line of defense, make sure that the static content presented to users is
also sanitized.
b) Client-side
 Disable JavaScript
Users cannot take any particular actions in order to prevent such an attack, other
than disabling JavaScript within their browser (disabling JavaScript is not seen as an
adequate solution since several websites require it to function properly).
 Update web browsers
The only thing that can help in this case is using secure and up to date web
browsers, with XSS filters turned on and hope for the best
Types of XSS
Reflected XSS: n a reflected cross-site scripting attack, the user unwittingly
sends code to a web server which then "reflects" that code back to the user's
browser, where it is executed and performs a malicious act
Typical goals: Session Hijacking, Bypassing access control and Malware
Attack
Session hijacking process:
 Hacker sends link to victim, link contain XSS
 Victim views page via XSS link supplied by attacker
 XSS code executes on victims browser and sends cookie to attackers
server
 Cookie is stolen. The attacker can then hijack the victims session
Cross Site Scripting Defense Presentation
Type of XSS
DOM-based vulnerabilities
 DOM XSS is a type of attack which relies on inappropriate handling, in
the HTML page, of the data from its associated DOM.
 Among the objects in the DOM, there are several which the attacker
can manipulate in order to generate the XSS condition, and the most
popular, from this perspective, is the document.url,
document.location and document.referrer objects.
 The Document Object Model is a convention for representing and
working with objects in an HTML document (as well as in other
document types)
Defending against DOM XSS attacks
 The DOM XSS attack is difficult to detect by server-side attack
detection and prevention tools, because usually the malicious payload
does not get to the server and hence cannot be sanitized in the
server-side code, like in the case of other XSS attacks.
 Sanitization and prevention techniques apply, but in this case the
code review as well as the implementation of sanitization
functionality needs to be performed on the client-side code.
 Avoiding client-side sensitive actions such as rewriting or redirection,
using client-side data;
 Using intrusion prevention systems which are able to inspect inbound
URL parameters and prevent the inappropriate pages to be served.
How to test for Cross site scripting
 Make notes of all the pages that display input originating from current
or other users.
 Test by injecting malicious JavaScript to see if they are ultimately
displayed back to the user.
 Carry out an examination of the code to ensure that the application
data is HTML encoded before it is rendered to users.
Defending Cross Site Scripting
 Appropriate output encoding or avoidance of thread input
* The contextual output encoding or escaping method is the major
defense mechanism to stop cross site scripting.
* HTML entity encoding
* Javascript escaping
* CSS escaping
Defending Cross Site Scripting (contd.)
 Securely authenticating untrusted HTML input
Many forums and webmail like to allow users to implement some
of the structures that html provides.
 It could be limited subset of html markup
 It prevent switching into any execution context
HTML sanitization engine must run during untrusted html content
accessing to ensure that it does not contain any xss.
Defending Cross Site Scripting (contd.)
 Cookie based Security
Many web applications rely on session cookies for authentication
between individual HTTP requests, and because client-side
scripts generally have access to these cookies and its easy to
steal the session cookies. To mitigate this threat:-
* Attach the session cookies to the IP address of the user who
actually login.
* Allow only that IP who can access that session only.
* Can be use HttpOnly flag which allows a web server to set a
cookie that is unavailable to client-side scripts
Defending Cross Site Scripting (contd.)
 HTTPOnly Cookie Flag
Microsoft Developers defines HTTPOnly as additional flag included in
set-cookie HTTP response header. Using this flag mitigates risk of client
side scripting.
When client access any website, website server sets this HTTPOnly. It
can only be set if browsers supports it if not browser ignores it.
Defending Cross Site Scripting (contd.)
Scanning Service
* Scanning web application with the scanner such as The Zed Attack
proxy (ZAP) , the client receives detailed information on how it was
performed and thus has a chance to fix the issues before the same attack
is attempted by someone else.
Defending Cross Site Scripting (contd.)
After scanning , it can provide the details vulnerabilities of the web
application with the solution and the risk level . This will help to identify
and fix the problem easily.
XSS Prevention Rules Summary
Context Code Sample Defence
HTML Body <body> DATA </body> HTML Escape
Convert & to &amp
Convert < to &lt
Convert > to &gt
Convert " to &quot
Convert ' to &#x27
Convert / to &#x2F
HTML Attributes <div attr=DATA> </div> escape all characters with the HTML
Entity &#xHH; format, include spaces
except alphanumeric.
GET or POST
parameter
<a href=”DATA”> </a> Replace space with +
Escape every character except
alphanumeric with % followed by two
digit HEX code
JavaScript
Variable
<script>alert(“DATA”)</script> Escape all characters with Unicode
escaping format. uXXXX
Avoid backslash encoding
CSS value <div style=”height:DATA”> </div> CSS escaping supports XX and
XXXXXX (CSS hexadecimal encoding).
HTML Body (HTML
data type)
<div> DATA</div> Using libraries like AntySamy, HTML
Sanitizer
Q & A
Ad

More Related Content

What's hot (20)

Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)
Daniel Tumser
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site Scripting
Ali Mattash
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
kinish kumar
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
Amit Tyagi
 
The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting Guide
Daisuke_Dan
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defenses
Mohammed A. Imran
 
Cross Site Scripting(XSS)
Cross Site Scripting(XSS)Cross Site Scripting(XSS)
Cross Site Scripting(XSS)
Nabin Dutta
 
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
InMobi Technology
 
Xss (cross site scripting)
Xss (cross site scripting)Xss (cross site scripting)
Xss (cross site scripting)
vinayh.vaghamshi _
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
Manish Kumar
 
Xss attack
Xss attackXss attack
Xss attack
Manjushree Mashal
 
CSRF Basics
CSRF BasicsCSRF Basics
CSRF Basics
n|u - The Open Security Community
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
Ritesh Gupta
 
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
Sandeep Kumbhar
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
Barrel Software
 
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
Vishal Kumar
 
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
Michael Coates
 
Xss ppt
Xss pptXss ppt
Xss ppt
penetration Tester
 
XSS- an application security vulnerability
XSS-   an application security vulnerabilityXSS-   an application security vulnerability
XSS- an application security vulnerability
Soumyasanto Sen
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
Daniel Miessler
 
Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)
Daniel Tumser
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site Scripting
Ali Mattash
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
kinish kumar
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
Amit Tyagi
 
The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting Guide
Daisuke_Dan
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defenses
Mohammed A. Imran
 
Cross Site Scripting(XSS)
Cross Site Scripting(XSS)Cross Site Scripting(XSS)
Cross Site Scripting(XSS)
Nabin Dutta
 
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
InMobi Technology
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
Manish Kumar
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
Ritesh Gupta
 
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
Sandeep Kumbhar
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
Barrel Software
 
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
Vishal Kumar
 
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
Michael Coates
 
XSS- an application security vulnerability
XSS-   an application security vulnerabilityXSS-   an application security vulnerability
XSS- an application security vulnerability
Soumyasanto Sen
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
Daniel Miessler
 

Viewers also liked (7)

Webセキュリティ入門(xss)
Webセキュリティ入門(xss)Webセキュリティ入門(xss)
Webセキュリティ入門(xss)
KageShiron
 
XSS - Attacks & Defense
XSS - Attacks & DefenseXSS - Attacks & Defense
XSS - Attacks & Defense
Blueinfy Solutions
 
ウェブセキュリティの最近の話題早分かり
ウェブセキュリティの最近の話題早分かりウェブセキュリティの最近の話題早分かり
ウェブセキュリティの最近の話題早分かり
Hiroshi Tokumaru
 
ウェブアプリケーションセキュリティ超入門
ウェブアプリケーションセキュリティ超入門ウェブアプリケーションセキュリティ超入門
ウェブアプリケーションセキュリティ超入門
Hiroshi Tokumaru
 
条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化
Takuya Ueda
 
セキュリティの都市伝説を暴く
セキュリティの都市伝説を暴くセキュリティの都市伝説を暴く
セキュリティの都市伝説を暴く
Hiroshi Tokumaru
 
著名PHPアプリの脆弱性に学ぶセキュアコーディングの原則
著名PHPアプリの脆弱性に学ぶセキュアコーディングの原則著名PHPアプリの脆弱性に学ぶセキュアコーディングの原則
著名PHPアプリの脆弱性に学ぶセキュアコーディングの原則
Hiroshi Tokumaru
 
Webセキュリティ入門(xss)
Webセキュリティ入門(xss)Webセキュリティ入門(xss)
Webセキュリティ入門(xss)
KageShiron
 
ウェブセキュリティの最近の話題早分かり
ウェブセキュリティの最近の話題早分かりウェブセキュリティの最近の話題早分かり
ウェブセキュリティの最近の話題早分かり
Hiroshi Tokumaru
 
ウェブアプリケーションセキュリティ超入門
ウェブアプリケーションセキュリティ超入門ウェブアプリケーションセキュリティ超入門
ウェブアプリケーションセキュリティ超入門
Hiroshi Tokumaru
 
条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化
Takuya Ueda
 
セキュリティの都市伝説を暴く
セキュリティの都市伝説を暴くセキュリティの都市伝説を暴く
セキュリティの都市伝説を暴く
Hiroshi Tokumaru
 
著名PHPアプリの脆弱性に学ぶセキュアコーディングの原則
著名PHPアプリの脆弱性に学ぶセキュアコーディングの原則著名PHPアプリの脆弱性に学ぶセキュアコーディングの原則
著名PHPアプリの脆弱性に学ぶセキュアコーディングの原則
Hiroshi Tokumaru
 
Ad

Similar to Cross Site Scripting Defense Presentation (20)

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
 
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET Journal
 
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
 
Session7-XSS & CSRF
Session7-XSS & CSRFSession7-XSS & CSRF
Session7-XSS & CSRF
zakieh alizadeh
 
STORED XSS IN DVWA
STORED XSS IN DVWASTORED XSS IN DVWA
STORED XSS IN DVWA
Rutvik patel
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
yashvirsingh48
 
Xssandcsrf
XssandcsrfXssandcsrf
Xssandcsrf
Prabhanshu Saraswat
 
Web hacking refers to exploitation of applications via HTTP which can be done
Web hacking refers to exploitation of applications via HTTP which can be doneWeb hacking refers to exploitation of applications via HTTP which can be done
Web hacking refers to exploitation of applications via HTTP which can be done
ssuserf8636d
 
React security vulnerabilities
React security vulnerabilitiesReact security vulnerabilities
React security vulnerabilities
AngelinaJasper
 
Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )
Irfad Imtiaz
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application Security
Chris Hillman
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scriptingSecure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
XSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing toolXSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing tool
Arjun Jain
 
Cross site scripting
Cross site scripting Cross site scripting
Cross site scripting
Bilal Mazhar MS(IS)Cyber Security II Privacy Professional
 
Web Vulnerabilities And Exploitation - Compromising The Web
Web Vulnerabilities And Exploitation - Compromising The WebWeb Vulnerabilities And Exploitation - Compromising The Web
Web Vulnerabilities And Exploitation - Compromising The Web
Zero Science Lab
 
4.Xss
4.Xss4.Xss
4.Xss
phanleson
 
Complete xss walkthrough
Complete xss walkthroughComplete xss walkthrough
Complete xss walkthrough
Ahmed Elhady Mohamed
 
CROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.pptCROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.ppt
yashvirsingh48
 
Xss_Hritwik_Roy.pptx@kjfbbwefhjoiqrw[i0-3envnvig87trhgohiulefvonvrivfgkmlghoi...
Xss_Hritwik_Roy.pptx@kjfbbwefhjoiqrw[i0-3envnvig87trhgohiulefvonvrivfgkmlghoi...Xss_Hritwik_Roy.pptx@kjfbbwefhjoiqrw[i0-3envnvig87trhgohiulefvonvrivfgkmlghoi...
Xss_Hritwik_Roy.pptx@kjfbbwefhjoiqrw[i0-3envnvig87trhgohiulefvonvrivfgkmlghoi...
jafixew160
 
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
 
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET Journal
 
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
 
STORED XSS IN DVWA
STORED XSS IN DVWASTORED XSS IN DVWA
STORED XSS IN DVWA
Rutvik patel
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
yashvirsingh48
 
Web hacking refers to exploitation of applications via HTTP which can be done
Web hacking refers to exploitation of applications via HTTP which can be doneWeb hacking refers to exploitation of applications via HTTP which can be done
Web hacking refers to exploitation of applications via HTTP which can be done
ssuserf8636d
 
React security vulnerabilities
React security vulnerabilitiesReact security vulnerabilities
React security vulnerabilities
AngelinaJasper
 
Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )
Irfad Imtiaz
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application Security
Chris Hillman
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scriptingSecure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
XSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing toolXSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing tool
Arjun Jain
 
Web Vulnerabilities And Exploitation - Compromising The Web
Web Vulnerabilities And Exploitation - Compromising The WebWeb Vulnerabilities And Exploitation - Compromising The Web
Web Vulnerabilities And Exploitation - Compromising The Web
Zero Science Lab
 
CROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.pptCROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.ppt
yashvirsingh48
 
Xss_Hritwik_Roy.pptx@kjfbbwefhjoiqrw[i0-3envnvig87trhgohiulefvonvrivfgkmlghoi...
Xss_Hritwik_Roy.pptx@kjfbbwefhjoiqrw[i0-3envnvig87trhgohiulefvonvrivfgkmlghoi...Xss_Hritwik_Roy.pptx@kjfbbwefhjoiqrw[i0-3envnvig87trhgohiulefvonvrivfgkmlghoi...
Xss_Hritwik_Roy.pptx@kjfbbwefhjoiqrw[i0-3envnvig87trhgohiulefvonvrivfgkmlghoi...
jafixew160
 
Report on xss and do s
Report on xss and do sReport on xss and do s
Report on xss and do s
mehr77
 
Ad

Recently uploaded (19)

Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC
 
Perguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolhaPerguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolha
socaslev
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation TemplateSmart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
yojeari421237
 
IT Services Workflow From Request to Resolution
IT Services Workflow From Request to ResolutionIT Services Workflow From Request to Resolution
IT Services Workflow From Request to Resolution
mzmziiskd
 
White and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptxWhite and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptx
canumatown
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
Understanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep WebUnderstanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep Web
nabilajabin35
 
DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)
APNIC
 
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry SweetserAPNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC
 
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
DataProvider1
 
5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx
andani26
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 
Computers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers NetworksComputers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers Networks
Tito208863
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 
Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC
 
Perguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolhaPerguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolha
socaslev
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation TemplateSmart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
yojeari421237
 
IT Services Workflow From Request to Resolution
IT Services Workflow From Request to ResolutionIT Services Workflow From Request to Resolution
IT Services Workflow From Request to Resolution
mzmziiskd
 
White and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptxWhite and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptx
canumatown
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
Understanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep WebUnderstanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep Web
nabilajabin35
 
DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)
APNIC
 
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry SweetserAPNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC
 
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
DataProvider1
 
5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx
andani26
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 
Computers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers NetworksComputers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers Networks
Tito208863
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 

Cross Site Scripting Defense Presentation

  • 1. Cross-site scripting defense Presented by Sarker Iftekhar Alam Yemi Aladeokin Igbape Maro
  • 2. Outline  Introduction to XSS  Conditions for Cross site scripting  Cross site scripting key players  Types of XSS  How to test for cross site scripting  Defending against Cross site scripting  XSS prevention rules summary  Conclusion
  • 3. Introduction to XSS Scripting: Web Browsers can execute commands  Embedded in HTML page  Supports different languages (JavaScript, VBScript, ActiveX, etc.)  Most prominent: JavaScript “Cross-Site” means: Foreign script sent via a server to a client  Attacker makes Web-Server deliver malicious script code  Malicious script is executed in Client’s Web Browser Attack:  Steal Access Credentials, Denial-of-Service, Modify Web pages  Execute any command at the client machine
  • 4. Cross-Site Scripting Cross site scripting (XSS) vulnerability is mainly caused by the failure of web applications in sanitizing user inputs embedded in web pages. To add to this, many other attack methods, such as Information Disclosures, Content Spoofing and Stolen Credentials could all be side-effects of an XSS attack. CONDITIONS FOR CROSS-SITE SCRIPTING  A Web application accepts user input  The input is used to create dynamic content  The input is insufficiently validated
  • 6. Cross-Site Scripting – Key Players  An Attacker • Anonymous Internet User • Malicious Internal User  An organization`s web server (i.e. Web application) • External (e.g.: Shop, Information, CRM, Supplier) • Internal (e.g.: Employees Self Service Portal)  A Client • Any type of customer • Anonymous user accessing the Web-Server
  • 7. Cross-Site Scripting – Key Players Denial-of-Service  Crash Users`Browser, Pop-Up-Flodding, Redirection Access to authentication credentials for Web application  Cookies, Username and Password  Normal users (Personal data, Business data, Misuse of account)  High privileged users (Control over Web application, web server and database) Access to User`s machine  Use ActiveX objects to control machine  Upload local data to attacker`s machine Spoil public image of company
  • 8. Type of XSS Stored or Persistent XSS:  Data provided by a client is first stored on the server such as a database or file system and later displayed to the users. This scenario usually requires a particular kind of vulnerable application, particular one that involves storing data in a database.  Persistent XSS is less frequent but the damage can be more devastating because once the payload is stored, it has the potential of infecting all of the visitors to the vulnerable web page.  Persistent XSS is also referred to as Type 2 XSS because the attack is carried out via two requests: one for injecting malicious code and having it stored on the web server, and the other for when victims load HTML pages containing the payload.  Typical goals of Persistent XSS attacks: Cookie theft and Data theft
  • 9. Example: Forums / message boards Once a forum is identified as vulnerable, attackers may open a new topic and insert malicious scripts in the topic title or body. They can also tag the topic using popular keywords so that the topic is a popular search result. The content of the forum post will be stored by the server. When the victims browse topics or search for certain keywords, they may reach the infected topic. When the topic loads, its contents will be sent to the victim’s browser and the payload may be executed. Alternatively, attackers may build tools that automatically post malicious scripts in replies on popular / sticky topics, send private messages containing the payload to forum members, etc..
  • 10. Defending Against Persistent / Stored XSS a) Server-side  Validate User Input The best way to prevent Persistent XSS is to make sure that all user input is properly validated before it gets stored permanently on the web server,  Sanitize static contents A second line of defense, make sure that the static content presented to users is also sanitized. b) Client-side  Disable JavaScript Users cannot take any particular actions in order to prevent such an attack, other than disabling JavaScript within their browser (disabling JavaScript is not seen as an adequate solution since several websites require it to function properly).  Update web browsers The only thing that can help in this case is using secure and up to date web browsers, with XSS filters turned on and hope for the best
  • 11. Types of XSS Reflected XSS: n a reflected cross-site scripting attack, the user unwittingly sends code to a web server which then "reflects" that code back to the user's browser, where it is executed and performs a malicious act Typical goals: Session Hijacking, Bypassing access control and Malware Attack Session hijacking process:  Hacker sends link to victim, link contain XSS  Victim views page via XSS link supplied by attacker  XSS code executes on victims browser and sends cookie to attackers server  Cookie is stolen. The attacker can then hijack the victims session
  • 13. Type of XSS DOM-based vulnerabilities  DOM XSS is a type of attack which relies on inappropriate handling, in the HTML page, of the data from its associated DOM.  Among the objects in the DOM, there are several which the attacker can manipulate in order to generate the XSS condition, and the most popular, from this perspective, is the document.url, document.location and document.referrer objects.  The Document Object Model is a convention for representing and working with objects in an HTML document (as well as in other document types)
  • 14. Defending against DOM XSS attacks  The DOM XSS attack is difficult to detect by server-side attack detection and prevention tools, because usually the malicious payload does not get to the server and hence cannot be sanitized in the server-side code, like in the case of other XSS attacks.  Sanitization and prevention techniques apply, but in this case the code review as well as the implementation of sanitization functionality needs to be performed on the client-side code.  Avoiding client-side sensitive actions such as rewriting or redirection, using client-side data;  Using intrusion prevention systems which are able to inspect inbound URL parameters and prevent the inappropriate pages to be served.
  • 15. How to test for Cross site scripting  Make notes of all the pages that display input originating from current or other users.  Test by injecting malicious JavaScript to see if they are ultimately displayed back to the user.  Carry out an examination of the code to ensure that the application data is HTML encoded before it is rendered to users.
  • 16. Defending Cross Site Scripting  Appropriate output encoding or avoidance of thread input * The contextual output encoding or escaping method is the major defense mechanism to stop cross site scripting. * HTML entity encoding * Javascript escaping * CSS escaping
  • 17. Defending Cross Site Scripting (contd.)  Securely authenticating untrusted HTML input Many forums and webmail like to allow users to implement some of the structures that html provides.  It could be limited subset of html markup  It prevent switching into any execution context HTML sanitization engine must run during untrusted html content accessing to ensure that it does not contain any xss.
  • 18. Defending Cross Site Scripting (contd.)  Cookie based Security Many web applications rely on session cookies for authentication between individual HTTP requests, and because client-side scripts generally have access to these cookies and its easy to steal the session cookies. To mitigate this threat:- * Attach the session cookies to the IP address of the user who actually login. * Allow only that IP who can access that session only. * Can be use HttpOnly flag which allows a web server to set a cookie that is unavailable to client-side scripts
  • 19. Defending Cross Site Scripting (contd.)  HTTPOnly Cookie Flag Microsoft Developers defines HTTPOnly as additional flag included in set-cookie HTTP response header. Using this flag mitigates risk of client side scripting. When client access any website, website server sets this HTTPOnly. It can only be set if browsers supports it if not browser ignores it.
  • 20. Defending Cross Site Scripting (contd.) Scanning Service * Scanning web application with the scanner such as The Zed Attack proxy (ZAP) , the client receives detailed information on how it was performed and thus has a chance to fix the issues before the same attack is attempted by someone else.
  • 21. Defending Cross Site Scripting (contd.) After scanning , it can provide the details vulnerabilities of the web application with the solution and the risk level . This will help to identify and fix the problem easily.
  • 22. XSS Prevention Rules Summary Context Code Sample Defence HTML Body <body> DATA </body> HTML Escape Convert & to &amp Convert < to &lt Convert > to &gt Convert " to &quot Convert ' to &#x27 Convert / to &#x2F HTML Attributes <div attr=DATA> </div> escape all characters with the HTML Entity &#xHH; format, include spaces except alphanumeric. GET or POST parameter <a href=”DATA”> </a> Replace space with + Escape every character except alphanumeric with % followed by two digit HEX code JavaScript Variable <script>alert(“DATA”)</script> Escape all characters with Unicode escaping format. uXXXX Avoid backslash encoding CSS value <div style=”height:DATA”> </div> CSS escaping supports XX and XXXXXX (CSS hexadecimal encoding). HTML Body (HTML data type) <div> DATA</div> Using libraries like AntySamy, HTML Sanitizer
  • 23. Q & A