XSS attack prevention
Posted
by Colby77
on Stack Overflow
See other posts from Stack Overflow
or by Colby77
Published on 2010-05-06T13:38:53Z
Indexed on
2010/05/06
14:08 UTC
Read the original article
Hit count: 261
xss
|JavaScript
Hi,
I'm developing a web app where users can response to blog entries. This is a security problem because they can send dangerous data that will be rendered to other users (and executed by javascript).
They can't format the text they send. No "bold", no colors, no nothing. Just simple text. I came up with this regex to solve my problem:
[^\\w\\s.?!()]
So anything that is not a word character (a-Z, A-Z, 0-9), not a whitespace, ".", "?", "!", "(" or ")" will be replaced with an empty string. Than every quatation mark will be replaced with: """.
I check the data on the front end and I check it on my server.
Is there any way somebody could bypass this "solution"?
I'm wondering how StackOverflow does this thing? There are a lot of formatting here so they must do a good work with it.
© Stack Overflow or respective owner