Jump to content

problems with contact forms that are only protected against SQL injections


jayjaz

Recommended Posts

XSS attacks.  if somebody is able to insert markup into your db which is then later displayed on your site, this can be disastrous.  imagine somebody did something so simple as to insert:

 

<script>window.location="http://www.my-super-bad-viagra-spam-gonna-take-all-your-money.com";</script>

 

through one of your forms.  and now, any time that is displayed on the site, the user will be redirected there.  and that's the least people can do with javascript.  cookie manipulation is another.  can embed iframes.  etc., etc.

 

all mysql_real_escape_string will do is make sure that malicious code gets into your database safe and sound.

 

you need to strip all unwanted tags, and change the rest using htmlentities, and then html_entity_decode on the output.

 

simple regex to strip all other unwanted characters (*^#@!,`~./?'";:\}{][-_=+) and so on.

Link to comment
Share on other sites

you need to strip all unwanted tags, and change the rest using htmlentities, and then html_entity_decode on the output.

simple regex to strip all other unwanted characters (*^#@!,`~./?'";:\}{][-_=+) and so on.

 

Yes, If you want to filter client code (Not dealing serverside protection) Than you should apply those methods. Another reasonable method is strip_tags which will strip ALL html tags such as <script> etc without the need to nullify them.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.