Reputation: 48
I'm testing a project I'm working on. Here I've put a filter on server side(Java) to redirect the page to Error page whenever I encounter any HTML tag like regex(URL Encoded is also checked) in query string. As per my skill set, it's working fine. But I'm very much sure it's not the end. There must be a way to still enter the vector to execute XSS script.
Examples : <hello> redirects to error page
%3Chello%3E
converts to <hello> and redirected to error page
%253Chello%253E
converts to %3Chello%3E
& page works fine as no HTML tag is found.
Upvotes: 0
Views: 635
Reputation: 846
^[a-zA-Z0-9]*$
or ^[\s\w]*$
. Adding both client validation and server validation would keep you safe and error-free (unless a hacker tries to bypass the client validation in which in this case the server validation would stop him).
If you try to guess the attacker's method you are destined to fail.%3Chello%3E
, but >hello<
).Having said that, here is an example of XSS without < and >: Let's say a page receives a picture file name and displays it, and does not encode the quote character:
https://contoso.com/displaypic?source=111.jpg
<img src="111.jpg"></img>
If you access this URL, you have yourself XSS:
https://contoso.com/displaypic?source=a"+onerror="alert('XSS')
<img src="a" onerror="alert('XSS')"></img>
Upvotes: 1