SlideShare a Scribd company logo
*Introduction...........................................................................................................................................
*Cross Site Scripting Attacks.................................................................................................................
*Prevention............................................................................................................................................
*Conclusion............................................................................................................................................
Name: Daisuke Dan
Website:TheHackersBay.org
Twitter: @TheHackersBay
The Cross Site Scripting Guide
XSS stands for Cross-Site-Scripting. It is basically an attack, that is used to execute HTML and
Javascript on the web-page. This attack can be done by submitting queries into text-boxes, or even
into the URL. The results come back reading the text as HTML, so it executes the scripts instead of
displaying them in plain text.
Many people treat an XSS vulnerability as a low to medium risk vulnerability, when in reality it is a
damaging attack that can lead to your users (and you) being compromised.
XSS attacks are becoming a big problem and are going to become an extremely big problem if
people do not educate them selves about XSS attacks and vulnerabilities, XSS vulnerabilities have
been found in all sorts of websites including fbi.gov, yahoo.com, ebay.com and many other popular
and important websites, a lot of administrators fail to pay attention to XSS attacks because they
either don't know much about them or they do not see them as a threat, an XSS vulnerability when
exploited by a skilled attacker or even a novice can be a very powerful attack. This paper details
XSS attacks and hopes to educate you on what they are, how attackers use them and of course
how you can prevent them from happening.
Overview:
Cross-site scripting (XSS) is a type of vulnerability commonly found in web applications. This
vulnerability makes it possible for attackers to inject malicious code (e.g. JavaScript programs) into
victim’s web browser. Using this malicious code, the attackers can steal the victim’s credentials,
such as cookies. The access control policies (i.e., the same origin policy) employed by the browser
to protect those credentials can be bypassed by exploiting the XSS vulnerability. Vulnerabilities of
this kind can potentially lead to large-scale attacks.
- HTML
HTML is sort of like a programming language. The distinctions between a programming language,
and HTML, are not too far apart. They are both languages, that are used to create attributes, and
events. HTML is a markup language, which is used mostly to create websites. HTML stands for
Hyper-Text Markup Language. You can use HTML to create forms, buttons, and other stuff that can
be used in a webpage. I highly doubt you will ever encounter a website that does not contain even a
slight amount of HTML.
- JavaScript
Now, first, let's get one thing straight. There is a HUGE difference between JAVA and JAVASCRIPT.
Java, is a language that ressembles to C++, it can be used in games, and applications. Javascript is
sort of similar to HTML, but definitely different in many ways. Javascript isn't used NEARLY as much
in Webpages than HTML is. Javascript is used, more in applications outside of webpages. Like
PDFs. Javascript can be an incredibly useful language along with HTML. They are both fairly simple
to learn, and are very dynamic.
The Cross Site Scripting Guide
The Cross Site scripting is one of the problem that has plagued a lot of websites. As a web
developer, it is important to understand what is cross site scripting and how can we safeguard our
site from such attacks.
Now the question would be how can a person inject scripts on a running page. This can easily be
done using all the various ways a website is collecting inputs. Cross site scripting can be performed
by passing scripts in form of:
*TextBox
*Cookies
*Query Strings
*Web application variables
*Session variables
What can you do with Xss Attacks?
*Attackers inject JavaScript, ActiveX, or HTML, into a vulnerable application, exploiting XSS holes.
*The browser processes the injected code as if it were legitimate content of the web page - with the
corresponding security permissions.
*Many attack could exploit flaws or vulnerabilities due to bad programming.
*Pillage of settings and user sensitive information.
Possible Attacks?
*Phishing: Criminal fraudulent process of attempting to acquire sensitive information such as
usernames, passwords and credit card details, by masque rading as a trustworthy entity in an
electronic communication or as a business or individual.
*Cookie Stealing: Cookie is used to manage sessions in browsers. Each person logged in gets a
unique cookie, it is like a key to the site.
*Account hijacking: Term used when malware infiltrates a system without the consent and performs
tasks set by its creator in addition to (or instead of) the system's normal duties.
*Changing of user settings: A scammer could take information about web sites administrator in order
to access to sensitive data or modifying user settings.
Basic types of XSS Attacks?
STORED XSS:
In the “STORED XSS” (persistent XSS),an attacker can inject the malicious code into the page
persistently and that means the code will be STORED in the server. And this code will be STORED
in the page which will show to the visitors later on. If the visitor goes to the page which is embedded
with XSS attacking code, the code will execute on the visitor‟s computer. Hackers usually post
these codes into the article in the forum or blog in order to let other users to read in the future and
attack more them.
Compared with “REFLECTED XSS”, this type of XSS does more serious harm. If the “STORED
XSS” vulnerability is successfully exploited by hackers, it will persistently attack the users until
administrator remove this vulnerability.
Example of Stored XSS: guestbook.php
Then page guestbook.php lists all entries returned by the previous function, without sanitizing the
content of the comments. It is only applied to the names (see function h() in the next section):
[---------------------------------------CODE---------------------------------------]
<?php
if ($guestbook)
{
foreach ($guestbook as $guest)
{
?>
<p class="comment"><?= $guest[" XSS SCRIPT "] ?></p>
<p> - by <?=h( $guest["name"] ) ?> </p>
<?php
} ?>
[---------------------------------------END CODE---------------------------------------]
REFLECTED XSS:
The “REFLECTED XSS” (non-persistent) is a temporary attack. Because the code cannot be
injected into the server, it just lets the server use the injected malicious code to immediately
generate a page and then, send this temporary page‟s URL to anyone that the attacker wants to
attack. If the user clicks this URL, the malicious code in this temporary page will execute. Because
this attack is based on user‟s trigging, this type of vulnerability was called REFLECTED XSS. There
fore, it is more difficult to be used unless the hacker can work hard on the URL and convince the
user to trigger the dangerous URL. So the hacker finds few methods to make the URL look like a
trusted Website‟s URL. First of all, hackers can encode the URL into Hex value or other type of
code in order that the URL looks more true and reliable. Therefore, the userthinks that there is no
virus command inside and clicks that. Google is a famous and reliable website. If Google has the
REFLECTED XSS, the hacker can inject malicious code into the URL and encode the URL. There
are many tools on the Internet which can provide the service of encoding the code from ASCII to
decimal ASCII, hexadecimal or other types. After finishing encoding the URL, the hacker will send
this URL to trick the user into clicking and also using some tricks which can attract the user to click.
In addition, later on, this thesis will give details of URL Encoding.
Example:
http://exploitsdownload.com/search?q="'">'">'"><script>alert('Daisuke_Dan')</script>
DOM-Based XSS:
The DOM-based XSS attack is another type of XSS vulnerability which is commonly used by
hackers as well. What is DOM-based XSS? First of all, we need to know what DOM is. DOM is
short for Document Object Model and it is a platform and language - neutral interface which is using
scripting or program to modify the content, update the date, structure and style of documents. It is
widely used in HTML and XML in Web 2.0. DOM in HTML can generate a tree - structure of HTML
documents. However, DOM allows the scripting or program to change the HTML or XML document,
the HTML or XML document can be modified by a hackers scripting or program. DOM-based XSS
uses DOM's vulnerability to make the XSS come true. This type of XSS vulnerability is totally
different from the REFLECTED or STORED XSS attack and it does not inject malicious code into a
page. So, it is the problem of the insecure DOM object which can be controlled by the client side in
the web page or application. For this reason, hackers can let the attack payload execute in the
DOM environment to attack the Victim side.
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of
different contexts.
Safe HTML Attributes include: align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color,
cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple,
nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary,
tabindex, title, usemap, valign, value, vlink, vspace, width.
Sanitize the input, all user submitted input anywhere in an application must be treated as hostile
and filtered. This should be done by the application code, but can also be performed by a web
application firewall (WAF) such as mod_security. The most effective way to prevent this is to do
both, use well coded applications and have a WAF or filtering as a second line of defense.
A common initial preventative to viral infection is a network level firewall. As HTTP/HTTPS protocols
are afforded unfettered access through common firewall configurations, these firewall barriers are
ineffectual. A potential remedy to this is an application firewall with the appropriate XSS virus
signatures. Whilst unlikely, the most obvious way to prevent XSS viruses is to remove XSS
vulnerabilities from web applications.
Conclusion?
Cross-site scripting (XSS) is one of the most frequent vulnerabilities found in modern web
applications. Never-theless, many service providers are either not willing or not able to provide
sufficient protection to their users. This paper proposes a novel, client-side solution to this problem.
By modifying the popular Firefox web browser, we are able to dynamically track the flow of sensitive
values (e.g., user cookies) on the client side. Whenever such a sensitive value is aboutto be
transferredto a third party(i.e., the adversary), the user is given the possibility to stop the
connection. To censure protection against more subtle types of XSS attacks that try to leak
information through non-dynamic control dependencies,we additionallyemploy an auxiliary, efficient
static analysis, where necessary. With this combination of dynamic and static techniques, we are
able to protect the user against XSS attacks in a reliable and efficient way. To validate our concepts,
we automatically tested the enhanced browser on more than one million web pages by means of a
crawler that is capable of interpreting JavaScript code. The results of this large-scale evaluation
demonstrate that only a small number of false positives is generated, and that our underlying
concepts are feasible in practice.

More Related Content

What's hot (20)

Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
n|u - The Open Security Community
 
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
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
Manish Kumar
 
XSS - Attacks & Defense
XSS - Attacks & DefenseXSS - Attacks & Defense
XSS - Attacks & Defense
Blueinfy Solutions
 
Xss attack
Xss attackXss attack
Xss attack
Manjushree Mashal
 
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
 
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 Request Forgery Vulnerabilities
Cross Site Request Forgery VulnerabilitiesCross Site Request Forgery Vulnerabilities
Cross Site Request Forgery Vulnerabilities
Marco Morana
 
Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)
Daniel Tumser
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
Amit Tyagi
 
Attacking thru HTTP Host header
Attacking thru HTTP Host headerAttacking thru HTTP Host header
Attacking thru HTTP Host header
Sergey Belov
 
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 ppt
Xss pptXss ppt
Xss ppt
penetration Tester
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
Daniel Miessler
 
Time based CAPTCHA protected SQL injection through SOAP-webservice
Time based CAPTCHA protected SQL injection through SOAP-webserviceTime based CAPTCHA protected SQL injection through SOAP-webservice
Time based CAPTCHA protected SQL injection through SOAP-webservice
Frans Rosén
 
CSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVCCSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVC
Suvash Shah
 
Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)
Aman Singh
 
Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert Box
Aaron Weaver
 
XSS
XSSXSS
XSS
Hrishikesh Mishra
 
Web Application Vulnerabilities
Web Application VulnerabilitiesWeb Application Vulnerabilities
Web Application Vulnerabilities
Preetish Panda
 
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
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
Manish Kumar
 
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
 
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 Request Forgery Vulnerabilities
Cross Site Request Forgery VulnerabilitiesCross Site Request Forgery Vulnerabilities
Cross Site Request Forgery Vulnerabilities
Marco Morana
 
Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)
Daniel Tumser
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
Amit Tyagi
 
Attacking thru HTTP Host header
Attacking thru HTTP Host headerAttacking thru HTTP Host header
Attacking thru HTTP Host header
Sergey Belov
 
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
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
Daniel Miessler
 
Time based CAPTCHA protected SQL injection through SOAP-webservice
Time based CAPTCHA protected SQL injection through SOAP-webserviceTime based CAPTCHA protected SQL injection through SOAP-webservice
Time based CAPTCHA protected SQL injection through SOAP-webservice
Frans Rosén
 
CSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVCCSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVC
Suvash Shah
 
Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)
Aman Singh
 
Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert Box
Aaron Weaver
 
Web Application Vulnerabilities
Web Application VulnerabilitiesWeb Application Vulnerabilities
Web Application Vulnerabilities
Preetish Panda
 

Viewers also liked (6)

Tracing out Cross Site Scripting Vulnerabilities in Modern Scripts
Tracing out Cross Site Scripting Vulnerabilities in Modern ScriptsTracing out Cross Site Scripting Vulnerabilities in Modern Scripts
Tracing out Cross Site Scripting Vulnerabilities in Modern Scripts
Eswar Publications
 
Cross site scripting XSS
Cross site scripting XSSCross site scripting XSS
Cross site scripting XSS
Ronan Dunne, CEH, SSCP
 
Inaugural Addresses
Inaugural AddressesInaugural Addresses
Inaugural Addresses
Booz Allen Hamilton
 
How to think like a startup
How to think like a startupHow to think like a startup
How to think like a startup
Loic Le Meur
 
Teaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & TextspeakTeaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & Textspeak
Shelly Sanchez Terrell
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
Luminary Labs
 
Tracing out Cross Site Scripting Vulnerabilities in Modern Scripts
Tracing out Cross Site Scripting Vulnerabilities in Modern ScriptsTracing out Cross Site Scripting Vulnerabilities in Modern Scripts
Tracing out Cross Site Scripting Vulnerabilities in Modern Scripts
Eswar Publications
 
How to think like a startup
How to think like a startupHow to think like a startup
How to think like a startup
Loic Le Meur
 
Teaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & TextspeakTeaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & Textspeak
Shelly Sanchez Terrell
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
Luminary Labs
 

Similar to The Cross Site Scripting Guide (20)

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
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
Okan YILDIZ
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
Okan YILDIZ
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
yashvirsingh48
 
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
 
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
 
Xss 101
Xss 101Xss 101
Xss 101
n|u - The Open Security Community
 
Xss 101 by-sai-shanthan
Xss 101 by-sai-shanthanXss 101 by-sai-shanthan
Xss 101 by-sai-shanthan
Raghunath G
 
Understanding dom based xss
Understanding dom based xssUnderstanding dom based xss
Understanding dom based xss
Potato
 
Complete xss walkthrough
Complete xss walkthroughComplete xss walkthrough
Complete xss walkthrough
Ahmed Elhady Mohamed
 
Rich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safeRich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safe
Jeremiah Grossman
 
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
 
.NET Security Topics
.NET Security Topics.NET Security Topics
.NET Security Topics
Shawn Gorrell
 
4.Xss
4.Xss4.Xss
4.Xss
phanleson
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
Eoin Keary
 
Web application attacks
Web application attacksWeb application attacks
Web application attacks
hruth
 
SeanRobertsThesis
SeanRobertsThesisSeanRobertsThesis
SeanRobertsThesis
Sean Roberts
 
Xssandcsrf
XssandcsrfXssandcsrf
Xssandcsrf
Prabhanshu Saraswat
 
Cm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xssCm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xss
dcervigni
 
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
 
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
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
yashvirsingh48
 
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
 
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
 
Xss 101 by-sai-shanthan
Xss 101 by-sai-shanthanXss 101 by-sai-shanthan
Xss 101 by-sai-shanthan
Raghunath G
 
Understanding dom based xss
Understanding dom based xssUnderstanding dom based xss
Understanding dom based xss
Potato
 
Rich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safeRich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safe
Jeremiah Grossman
 
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
 
.NET Security Topics
.NET Security Topics.NET Security Topics
.NET Security Topics
Shawn Gorrell
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
Eoin Keary
 
Web application attacks
Web application attacksWeb application attacks
Web application attacks
hruth
 
Cm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xssCm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xss
dcervigni
 
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
 

Recently uploaded (20)

The Evolution of Storytelling From Ancient Epics to Modern Novels.pdf
The Evolution of Storytelling From Ancient Epics to Modern Novels.pdfThe Evolution of Storytelling From Ancient Epics to Modern Novels.pdf
The Evolution of Storytelling From Ancient Epics to Modern Novels.pdf
Rohan Das
 
cuestionarios para evaluaciones del primer parcial (8).docx
cuestionarios para evaluaciones del primer parcial (8).docxcuestionarios para evaluaciones del primer parcial (8).docx
cuestionarios para evaluaciones del primer parcial (8).docx
DianaSanchez648038
 
Aquí, los colores del pueblo no son estridentes, sino sinceros y suaves. E.Vi...
Aquí, los colores del pueblo no son estridentes, sino sinceros y suaves. E.Vi...Aquí, los colores del pueblo no son estridentes, sino sinceros y suaves. E.Vi...
Aquí, los colores del pueblo no son estridentes, sino sinceros y suaves. E.Vi...
EusebioVidal1
 
Lightning in Paintings.ppsx
Lightning       in        Paintings.ppsxLightning       in        Paintings.ppsx
Lightning in Paintings.ppsx
guimera
 
Kris Kourtis Photo Book. Limited Edition
Kris Kourtis Photo Book. Limited EditionKris Kourtis Photo Book. Limited Edition
Kris Kourtis Photo Book. Limited Edition
kourtistv
 
BUKTI JP MEMBER KANCAH4D TANPA BASA-BASI LANGSUNG DIKASIH !
BUKTI JP MEMBER KANCAH4D TANPA BASA-BASI LANGSUNG DIKASIH !BUKTI JP MEMBER KANCAH4D TANPA BASA-BASI LANGSUNG DIKASIH !
BUKTI JP MEMBER KANCAH4D TANPA BASA-BASI LANGSUNG DIKASIH !
Kancah4d Jitu
 
Tiger Conservation provides many ecological, economic, social benefits
Tiger Conservation provides many ecological, economic, social benefitsTiger Conservation provides many ecological, economic, social benefits
Tiger Conservation provides many ecological, economic, social benefits
Leena N
 
ppt udahggfdgrdfjygtyctcdjkyyydcgnchsgrd
ppt udahggfdgrdfjygtyctcdjkyyydcgnchsgrdppt udahggfdgrdfjygtyctcdjkyyydcgnchsgrd
ppt udahggfdgrdfjygtyctcdjkyyydcgnchsgrd
UdayShah43
 
tabermaculox4hojasA4blockposter-154616.pdf
tabermaculox4hojasA4blockposter-154616.pdftabermaculox4hojasA4blockposter-154616.pdf
tabermaculox4hojasA4blockposter-154616.pdf
MartinAzamendi
 
一比一原版(PSU毕业证)普利茅斯大学毕业证如何办理
一比一原版(PSU毕业证)普利茅斯大学毕业证如何办理一比一原版(PSU毕业证)普利茅斯大学毕业证如何办理
一比一原版(PSU毕业证)普利茅斯大学毕业证如何办理
Taqyea
 
Don’t Miss Australia’s July Intake – Boost Your Career Mid-Year!
Don’t Miss Australia’s July Intake – Boost Your Career Mid-Year!Don’t Miss Australia’s July Intake – Boost Your Career Mid-Year!
Don’t Miss Australia’s July Intake – Boost Your Career Mid-Year!
Manish Jain
 
Strip Zagor VC 184 - Smrtonosna Formula.pdf
Strip Zagor VC 184 - Smrtonosna Formula.pdfStrip Zagor VC 184 - Smrtonosna Formula.pdf
Strip Zagor VC 184 - Smrtonosna Formula.pdf
Stripovizijacom
 
creating ppt with microsoft templates made easy
creating ppt with microsoft templates made easycreating ppt with microsoft templates made easy
creating ppt with microsoft templates made easy
RavindraNathTiwari1
 
Dastoor Presentation by Hina Kashif 15224.pptx
Dastoor Presentation by Hina Kashif 15224.pptxDastoor Presentation by Hina Kashif 15224.pptx
Dastoor Presentation by Hina Kashif 15224.pptx
hinakashif669
 
GRABAdd a heading (4).pdf
GRABAdd a heading                           (4).pdfGRABAdd a heading                           (4).pdf
GRABAdd a heading (4).pdf
shaswatsharma3
 
PPT on nature and environment.pptx it is best
PPT on nature and environment.pptx it is bestPPT on nature and environment.pptx it is best
PPT on nature and environment.pptx it is best
gurasissinghtaggar4
 
The Most popular female Syrian politicians
The Most popular female Syrian politiciansThe Most popular female Syrian politicians
The Most popular female Syrian politicians
mo820325
 
端午快樂 Happy Dragon-Boat Festival (May 31st)
端午快樂 Happy Dragon-Boat Festival (May 31st)端午快樂 Happy Dragon-Boat Festival (May 31st)
端午快樂 Happy Dragon-Boat Festival (May 31st)
Muchiu (Henry) Chang, PhD. Cantab
 
Storage devices COmputer NTETWORKING.ppt
Storage devices COmputer NTETWORKING.pptStorage devices COmputer NTETWORKING.ppt
Storage devices COmputer NTETWORKING.ppt
CamilleJoyVeniegas
 
Mock Model Portfolio - A Creative Direction Project
Mock Model Portfolio - A Creative Direction ProjectMock Model Portfolio - A Creative Direction Project
Mock Model Portfolio - A Creative Direction Project
Adeline Yeo
 
The Evolution of Storytelling From Ancient Epics to Modern Novels.pdf
The Evolution of Storytelling From Ancient Epics to Modern Novels.pdfThe Evolution of Storytelling From Ancient Epics to Modern Novels.pdf
The Evolution of Storytelling From Ancient Epics to Modern Novels.pdf
Rohan Das
 
cuestionarios para evaluaciones del primer parcial (8).docx
cuestionarios para evaluaciones del primer parcial (8).docxcuestionarios para evaluaciones del primer parcial (8).docx
cuestionarios para evaluaciones del primer parcial (8).docx
DianaSanchez648038
 
Aquí, los colores del pueblo no son estridentes, sino sinceros y suaves. E.Vi...
Aquí, los colores del pueblo no son estridentes, sino sinceros y suaves. E.Vi...Aquí, los colores del pueblo no son estridentes, sino sinceros y suaves. E.Vi...
Aquí, los colores del pueblo no son estridentes, sino sinceros y suaves. E.Vi...
EusebioVidal1
 
Lightning in Paintings.ppsx
Lightning       in        Paintings.ppsxLightning       in        Paintings.ppsx
Lightning in Paintings.ppsx
guimera
 
Kris Kourtis Photo Book. Limited Edition
Kris Kourtis Photo Book. Limited EditionKris Kourtis Photo Book. Limited Edition
Kris Kourtis Photo Book. Limited Edition
kourtistv
 
BUKTI JP MEMBER KANCAH4D TANPA BASA-BASI LANGSUNG DIKASIH !
BUKTI JP MEMBER KANCAH4D TANPA BASA-BASI LANGSUNG DIKASIH !BUKTI JP MEMBER KANCAH4D TANPA BASA-BASI LANGSUNG DIKASIH !
BUKTI JP MEMBER KANCAH4D TANPA BASA-BASI LANGSUNG DIKASIH !
Kancah4d Jitu
 
Tiger Conservation provides many ecological, economic, social benefits
Tiger Conservation provides many ecological, economic, social benefitsTiger Conservation provides many ecological, economic, social benefits
Tiger Conservation provides many ecological, economic, social benefits
Leena N
 
ppt udahggfdgrdfjygtyctcdjkyyydcgnchsgrd
ppt udahggfdgrdfjygtyctcdjkyyydcgnchsgrdppt udahggfdgrdfjygtyctcdjkyyydcgnchsgrd
ppt udahggfdgrdfjygtyctcdjkyyydcgnchsgrd
UdayShah43
 
tabermaculox4hojasA4blockposter-154616.pdf
tabermaculox4hojasA4blockposter-154616.pdftabermaculox4hojasA4blockposter-154616.pdf
tabermaculox4hojasA4blockposter-154616.pdf
MartinAzamendi
 
一比一原版(PSU毕业证)普利茅斯大学毕业证如何办理
一比一原版(PSU毕业证)普利茅斯大学毕业证如何办理一比一原版(PSU毕业证)普利茅斯大学毕业证如何办理
一比一原版(PSU毕业证)普利茅斯大学毕业证如何办理
Taqyea
 
Don’t Miss Australia’s July Intake – Boost Your Career Mid-Year!
Don’t Miss Australia’s July Intake – Boost Your Career Mid-Year!Don’t Miss Australia’s July Intake – Boost Your Career Mid-Year!
Don’t Miss Australia’s July Intake – Boost Your Career Mid-Year!
Manish Jain
 
Strip Zagor VC 184 - Smrtonosna Formula.pdf
Strip Zagor VC 184 - Smrtonosna Formula.pdfStrip Zagor VC 184 - Smrtonosna Formula.pdf
Strip Zagor VC 184 - Smrtonosna Formula.pdf
Stripovizijacom
 
creating ppt with microsoft templates made easy
creating ppt with microsoft templates made easycreating ppt with microsoft templates made easy
creating ppt with microsoft templates made easy
RavindraNathTiwari1
 
Dastoor Presentation by Hina Kashif 15224.pptx
Dastoor Presentation by Hina Kashif 15224.pptxDastoor Presentation by Hina Kashif 15224.pptx
Dastoor Presentation by Hina Kashif 15224.pptx
hinakashif669
 
GRABAdd a heading (4).pdf
GRABAdd a heading                           (4).pdfGRABAdd a heading                           (4).pdf
GRABAdd a heading (4).pdf
shaswatsharma3
 
PPT on nature and environment.pptx it is best
PPT on nature and environment.pptx it is bestPPT on nature and environment.pptx it is best
PPT on nature and environment.pptx it is best
gurasissinghtaggar4
 
The Most popular female Syrian politicians
The Most popular female Syrian politiciansThe Most popular female Syrian politicians
The Most popular female Syrian politicians
mo820325
 
Storage devices COmputer NTETWORKING.ppt
Storage devices COmputer NTETWORKING.pptStorage devices COmputer NTETWORKING.ppt
Storage devices COmputer NTETWORKING.ppt
CamilleJoyVeniegas
 
Mock Model Portfolio - A Creative Direction Project
Mock Model Portfolio - A Creative Direction ProjectMock Model Portfolio - A Creative Direction Project
Mock Model Portfolio - A Creative Direction Project
Adeline Yeo
 

The Cross Site Scripting Guide

  • 1. *Introduction........................................................................................................................................... *Cross Site Scripting Attacks................................................................................................................. *Prevention............................................................................................................................................ *Conclusion............................................................................................................................................ Name: Daisuke Dan Website:TheHackersBay.org Twitter: @TheHackersBay
  • 3. XSS stands for Cross-Site-Scripting. It is basically an attack, that is used to execute HTML and Javascript on the web-page. This attack can be done by submitting queries into text-boxes, or even into the URL. The results come back reading the text as HTML, so it executes the scripts instead of displaying them in plain text. Many people treat an XSS vulnerability as a low to medium risk vulnerability, when in reality it is a damaging attack that can lead to your users (and you) being compromised. XSS attacks are becoming a big problem and are going to become an extremely big problem if people do not educate them selves about XSS attacks and vulnerabilities, XSS vulnerabilities have been found in all sorts of websites including fbi.gov, yahoo.com, ebay.com and many other popular and important websites, a lot of administrators fail to pay attention to XSS attacks because they either don't know much about them or they do not see them as a threat, an XSS vulnerability when exploited by a skilled attacker or even a novice can be a very powerful attack. This paper details XSS attacks and hopes to educate you on what they are, how attackers use them and of course how you can prevent them from happening. Overview: Cross-site scripting (XSS) is a type of vulnerability commonly found in web applications. This vulnerability makes it possible for attackers to inject malicious code (e.g. JavaScript programs) into victim’s web browser. Using this malicious code, the attackers can steal the victim’s credentials, such as cookies. The access control policies (i.e., the same origin policy) employed by the browser to protect those credentials can be bypassed by exploiting the XSS vulnerability. Vulnerabilities of this kind can potentially lead to large-scale attacks. - HTML HTML is sort of like a programming language. The distinctions between a programming language, and HTML, are not too far apart. They are both languages, that are used to create attributes, and events. HTML is a markup language, which is used mostly to create websites. HTML stands for Hyper-Text Markup Language. You can use HTML to create forms, buttons, and other stuff that can be used in a webpage. I highly doubt you will ever encounter a website that does not contain even a slight amount of HTML. - JavaScript Now, first, let's get one thing straight. There is a HUGE difference between JAVA and JAVASCRIPT. Java, is a language that ressembles to C++, it can be used in games, and applications. Javascript is sort of similar to HTML, but definitely different in many ways. Javascript isn't used NEARLY as much in Webpages than HTML is. Javascript is used, more in applications outside of webpages. Like PDFs. Javascript can be an incredibly useful language along with HTML. They are both fairly simple to learn, and are very dynamic.
  • 5. The Cross Site scripting is one of the problem that has plagued a lot of websites. As a web developer, it is important to understand what is cross site scripting and how can we safeguard our site from such attacks. Now the question would be how can a person inject scripts on a running page. This can easily be done using all the various ways a website is collecting inputs. Cross site scripting can be performed by passing scripts in form of: *TextBox *Cookies *Query Strings *Web application variables *Session variables What can you do with Xss Attacks? *Attackers inject JavaScript, ActiveX, or HTML, into a vulnerable application, exploiting XSS holes. *The browser processes the injected code as if it were legitimate content of the web page - with the corresponding security permissions. *Many attack could exploit flaws or vulnerabilities due to bad programming. *Pillage of settings and user sensitive information. Possible Attacks? *Phishing: Criminal fraudulent process of attempting to acquire sensitive information such as usernames, passwords and credit card details, by masque rading as a trustworthy entity in an electronic communication or as a business or individual. *Cookie Stealing: Cookie is used to manage sessions in browsers. Each person logged in gets a unique cookie, it is like a key to the site. *Account hijacking: Term used when malware infiltrates a system without the consent and performs tasks set by its creator in addition to (or instead of) the system's normal duties. *Changing of user settings: A scammer could take information about web sites administrator in order to access to sensitive data or modifying user settings. Basic types of XSS Attacks? STORED XSS: In the “STORED XSS” (persistent XSS),an attacker can inject the malicious code into the page persistently and that means the code will be STORED in the server. And this code will be STORED in the page which will show to the visitors later on. If the visitor goes to the page which is embedded with XSS attacking code, the code will execute on the visitor‟s computer. Hackers usually post these codes into the article in the forum or blog in order to let other users to read in the future and attack more them. Compared with “REFLECTED XSS”, this type of XSS does more serious harm. If the “STORED XSS” vulnerability is successfully exploited by hackers, it will persistently attack the users until administrator remove this vulnerability.
  • 6. Example of Stored XSS: guestbook.php Then page guestbook.php lists all entries returned by the previous function, without sanitizing the content of the comments. It is only applied to the names (see function h() in the next section): [---------------------------------------CODE---------------------------------------] <?php if ($guestbook) { foreach ($guestbook as $guest) { ?> <p class="comment"><?= $guest[" XSS SCRIPT "] ?></p> <p> - by <?=h( $guest["name"] ) ?> </p> <?php } ?> [---------------------------------------END CODE---------------------------------------]
  • 7. REFLECTED XSS: The “REFLECTED XSS” (non-persistent) is a temporary attack. Because the code cannot be injected into the server, it just lets the server use the injected malicious code to immediately generate a page and then, send this temporary page‟s URL to anyone that the attacker wants to attack. If the user clicks this URL, the malicious code in this temporary page will execute. Because this attack is based on user‟s trigging, this type of vulnerability was called REFLECTED XSS. There fore, it is more difficult to be used unless the hacker can work hard on the URL and convince the user to trigger the dangerous URL. So the hacker finds few methods to make the URL look like a trusted Website‟s URL. First of all, hackers can encode the URL into Hex value or other type of code in order that the URL looks more true and reliable. Therefore, the userthinks that there is no virus command inside and clicks that. Google is a famous and reliable website. If Google has the REFLECTED XSS, the hacker can inject malicious code into the URL and encode the URL. There are many tools on the Internet which can provide the service of encoding the code from ASCII to decimal ASCII, hexadecimal or other types. After finishing encoding the URL, the hacker will send this URL to trick the user into clicking and also using some tricks which can attract the user to click. In addition, later on, this thesis will give details of URL Encoding. Example: http://exploitsdownload.com/search?q="'">'">'"><script>alert('Daisuke_Dan')</script>
  • 8. DOM-Based XSS: The DOM-based XSS attack is another type of XSS vulnerability which is commonly used by hackers as well. What is DOM-based XSS? First of all, we need to know what DOM is. DOM is short for Document Object Model and it is a platform and language - neutral interface which is using scripting or program to modify the content, update the date, structure and style of documents. It is widely used in HTML and XML in Web 2.0. DOM in HTML can generate a tree - structure of HTML documents. However, DOM allows the scripting or program to change the HTML or XML document, the HTML or XML document can be modified by a hackers scripting or program. DOM-based XSS uses DOM's vulnerability to make the XSS come true. This type of XSS vulnerability is totally different from the REFLECTED or STORED XSS attack and it does not inject malicious code into a page. So, it is the problem of the insecure DOM object which can be controlled by the client side in the web page or application. For this reason, hackers can let the attack payload execute in the DOM environment to attack the Victim side.
  • 9. The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts.
  • 10. Safe HTML Attributes include: align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width. Sanitize the input, all user submitted input anywhere in an application must be treated as hostile and filtered. This should be done by the application code, but can also be performed by a web application firewall (WAF) such as mod_security. The most effective way to prevent this is to do both, use well coded applications and have a WAF or filtering as a second line of defense. A common initial preventative to viral infection is a network level firewall. As HTTP/HTTPS protocols are afforded unfettered access through common firewall configurations, these firewall barriers are ineffectual. A potential remedy to this is an application firewall with the appropriate XSS virus signatures. Whilst unlikely, the most obvious way to prevent XSS viruses is to remove XSS vulnerabilities from web applications. Conclusion? Cross-site scripting (XSS) is one of the most frequent vulnerabilities found in modern web applications. Never-theless, many service providers are either not willing or not able to provide sufficient protection to their users. This paper proposes a novel, client-side solution to this problem. By modifying the popular Firefox web browser, we are able to dynamically track the flow of sensitive values (e.g., user cookies) on the client side. Whenever such a sensitive value is aboutto be transferredto a third party(i.e., the adversary), the user is given the possibility to stop the connection. To censure protection against more subtle types of XSS attacks that try to leak information through non-dynamic control dependencies,we additionallyemploy an auxiliary, efficient static analysis, where necessary. With this combination of dynamic and static techniques, we are able to protect the user against XSS attacks in a reliable and efficient way. To validate our concepts, we automatically tested the enhanced browser on more than one million web pages by means of a crawler that is capable of interpreting JavaScript code. The results of this large-scale evaluation demonstrate that only a small number of false positives is generated, and that our underlying concepts are feasible in practice.