|
-
Sep 21st, 2006, 07:05 PM
#1
Thread Starter
Hyperactive Member
What is cross-site scripting and how to avoid it?
I haven't been able to find much about this topic so I thought I would ask.
-
Sep 21st, 2006, 07:36 PM
#2
Re: What is cross-site scripting and how to avoid it?
Basically it's when any visitor to your site can add some content (be it a guest book, message board, wiki, whatever) and JavaScript in that content gets executed. It allows the user to pretend to be your site while doing something malicious. The end user, trusting your site, may for example write credit card information, and the attacker, through the injected script, can intercept this information.
To avoid it, you must make absolutely sure that you've properly validated and sanitized all user input.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 21st, 2006, 08:06 PM
#3
Thread Starter
Hyperactive Member
Re: What is cross-site scripting and how to avoid it?
How would you go about validating user input and striping out any potential malicious code?
-
Sep 21st, 2006, 08:25 PM
#4
Re: What is cross-site scripting and how to avoid it?
Depends on what the user input is. The simplest form is to just push it through htmlentities().
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 22nd, 2006, 01:53 AM
#5
Re: What is cross-site scripting and how to avoid it?
A basic rule of thumb is to never directly reflect any input. Always process it first.
-
Sep 23rd, 2006, 12:47 AM
#6
Thread Starter
Hyperactive Member
Re: What is cross-site scripting and how to avoid it?
Thanks guys for your responses is there any code out there that you guys think is good for stripping out html and javascript?
-
Sep 23rd, 2006, 03:23 AM
#7
Re: What is cross-site scripting and how to avoid it?
You shouldn't try to strip out HTML and JS like that, it's too troublesome. Just use htmlentities() like CB suggested and angle brackets (among other things) will be converted to < and > so that they are not parsed as code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|