Questions tagged [xss]

Cross-Site Scripting: An attack method that involves injection of code or markup into a webpage. There are three major types of XSS: Reflected XSS, Stored XSS (aka persistent XSS) and DOM-based XSS (aka client side XSS).

Cross-Site Scripting (XSS) is an injection attack. It is called XSS to avoid misunderstanding with CSS (Cascading Style Sheets). XSS is in OWASP top 10 list since 2004. There are three common XSS types: Stored, Reflected and DOM based. Here is the explanation for two common types of XSS:

  1. Stored (persistent): Everywhere in a web application that stores data from user and retrieves later could be vulnerable to this type. For example, malicious script is commented by attacker for a post in a blog, script is stored as a comment in database and then is retrieved and executed automatically on targeted user's browser when the post is visited.
  2. Reflected (non-persistent): In this type, malicious code is put in URL as a parameter and then URL is sent to the targeted user. When the URL is opened, malicious code will be executed automatically by the browser.

XSS attacks are prevented by user input validation and sanitization. Everywhere an input is taken must be validated and sanitized to avoid malicious script injection. Validation methods are based on whitelisting and blacklisting.

XSS attacks are common on the web and should be prevented. XSS vulnerability could be leveraged by attacker to hijack session and even trigger DOS attack. There is a good detailed explanation about XSS attacks in The Web Application Hacker's Handbook (Chapter 12).

There are some useful best practices in OWASP for XSS prevention:

  1. Cross Site Scripting Prevention Cheat Sheet
  2. DOM based XSS Prevention Cheat Sheet

Vulnerability scanners could be used to detect XSS in web applications, here are some useful links for such tools:

  1. Acunetix
  2. Tenable
  3. Rapid7
  4. NetSparker
1528 questions
37
votes
1 answer

Why do XSS strings often start with ">?

One of the ways, XSS can be exploited, is to use following tag: "> Here, What is the meaning of "> before script (">Click Me What I am trying to determine is, what is the chance that a browser, even an older one would execute…
Brettski
  • 531
  • 3
  • 8
  • 15
9
votes
2 answers

What is the difference between ordinary XSS and Dom XSS vulnerabilities?

I'm not a computer guy, but just out of curiosity I've recently started to learn PHP for programming my own website and I've read about some most common vulnerabilities that exist in web applications. I know the basics about Cross Site Scripting…
math.n00b
  • 193
  • 1
  • 1
  • 3
9
votes
1 answer

Do javascript: URLs starting with // allow XSS?

I found a markup processor that allows users to include arbitrary links, as long as they contain a "netloc" (// after the first :). Due to the myriad of exploitable protocol handlers, this is certainly a bad idea. But does it allow XSS on a system…
phihag
  • 279
  • 2
  • 10
9
votes
5 answers

How to protect a from XSS?

Most sites having a sign in form have the following html element: If I press F12 to open the debugger on chrome and type: document.getElementByName("password")[0].value this will retrieve the password. A hacker could…
Caio D.C.
  • 91
  • 1
  • 2
9
votes
3 answers

Can I simply search-replace < and >?

I'm running a comment system, and I want to accept regular, un-formatted text. I don't want anything too complicated, so I thought of just searching and replacing all < to space (through regex or a simple for loop), so
xss
  • 107
  • 2
8
votes
2 answers

How to break out of URL context

The OWASP XSS Prevention Worksheet recommends "URL escape before inserting untrusted data into HTML URL parameter values". I don't understand how someone could break out of a URL context or inject a new subcontext to perform a XSS attack in a URL.…
bwroga
  • 181
  • 1
  • 2
8
votes
1 answer

XSS inside HTML attribute where < and " are filtered

Is it possible to bypass an XSS filter where < and " are encoded as < and ", but > is not escaped? My data is injected into an HTML value attribute. However I can't get out of it since " is escaped. Characters that are…
Ogglas
  • 787
  • 4
  • 12
  • 28
7
votes
2 answers

How to prevent XSS from url

I found an XSS vulnerability which is exploited by appending attack in the URL parameters. For eg. the original URL site.com/?s=login&m=forgotten And the attack URL site.com/?s=login&m=forgotten" onload=alert(966) bad=" Now I would like to…
Vishal
  • 183
  • 1
  • 1
  • 4
7
votes
1 answer

Host Header Attacks

So reading this blog post, I know how the password reset works and how it's exploitable, but in a real case scenario, how would XSS be possible? Is there a way to send a victim to a page with the host header edited? Thank you!
Michael Blake
  • 751
  • 4
  • 12
  • 22
1
2 3
13 14