This one is around the concept of an XSS attack. Let me define it first:
An XSS attack is when a user is capable of entering html code and then whatever webpage it is on will then process the code.
Example of a normal user:
Example of an XSS attack:
The script that the attacker inputted would mean that every page your user tried to browse, since his name was now registered as that script, when your page loads the newest account which is now him, it redirects the page to Google!
Obviously the registration form might not be the easiest place to use it, but if you created your own message board on your website by hand, it would definitely work when it posted the message because you have that script in there.
How to defend from it:
Well, as for the registration page, you should have a check that makes sure the username/password has no invalid characters in it. Mainly the only characters that should be allowed are Aa-Zz and 0-9.
As for your handmade message board or forums that don't yet have this protection implemented, you will need to write code that when the user submits his forum post, it turns the html tags (such as < and >) into what is called a character reference.
EDIT:
PHP Code:
mysql_real_escape_string();
//and
htmlspecialchars();
for getting these to hopefully start some of you in the right direction of what to use! (I know it even helped me, as my fix is a lot more code. >_<) Here's an example:
You could write code that would turn something like this "&" into this: "&" which would display the same thing either way. But yeah, your code would turn the html tag like
Code:
<script>
Note: That isn't the real character reference for < and >
I hope this helps in some sort of way, and I apologize if I made it harder to understand. Like my other posts tagged with [Website], I'll continue to work on this post and make it easier to understand!
-xSherufanir/xBlackPlagu3x; Please rate the helpfulness of this thread! ^^
Great Resource on XXS (Cross-site) attacks: Wikipedia Cross-site scripting






