Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-19-2008, 01:45 AM Form Security
Truly's Avatar
Ultra Talker

Posts: 321
Trades: 0
What tricks do you guys use to make sure that users dont user input boxes to compromise the security of your website?
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-19-2008, 02:07 AM Re: Form Security
NullPointer's Avatar
Will Code for Food

Posts: 2,783
Name: Matt
Location: Irvine, CA
Trades: 0
mysql_real_escape_string prevents most kinds of sql injections, you should also validate any data a user submits.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-19-2008, 06:43 PM Re: Form Security
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
I'm a big fan of sterilisation. The functions are serialize($var) and unserialize($var) it's quite useful. I would also reccomend you try md5/base64 something then compare it.

For forms, take a look at:
- Timestamps
- CAPACHA (sp?) - that thing where you type the words in the image.
- Checking how long a stamp takes to submit, if it's too quick ignore it.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 03-20-2008, 10:30 PM Re: Form Security
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
Here is (hopefully) a helpful resource to give you some basic cleaning tools for your users input. This type of input cleaning forces the input into specific types. Would be best to used written in functions, and also allow the recursive cleaning within arrays.

PHP Code:
<?php
  
  
//  Signed Integer
  //  Can be any whole number pos or neg
  
$int intval($_REQUEST['int']);
  
  
//  Unsigned Integer
  //  Can be any whole number pos only
  
$uint = ($uint intval($_REQUEST['uint'])) < $uint;
  
  
//  Signed Floating Number
  //  Can be any floating (decimal) number pos or neg
  
$float floatval($_REQUEST['float']);
  
  
//  Unsigned Floating Number
  //  Can be any floating (decimal) number pos only
  
$ufloat = ($ufloat intval($_REQUEST['ufloat'])) < $ufloat;
  
  
//  Boolean
  //  Will set to True or False
  
$bool = (bool)$_REQUEST['bool'];
  
  
//  String for possible SQL
  //  This only cleans the string, still needs to be
  //  properly escaped before submitting SQL query
  
$string trim(stripslashes($_REQUEST['string']));
  
  
//  String for HTML Display
  //  Allows strings to be safely displayed on HTML pages
  //  second line helps prevent RSS attacks
  
$html htmlentities(trim(stripslashes($_REQUEST['html'])));
  
$html preg_replace(array('#javascript#i''#vbscript#i'), array('java script''vb script'), $html);
__________________

<mgraphic /> - I don't have a solution but I admire the problem.

Last edited by mgraphic; 03-21-2008 at 10:57 AM.. Reason: Strings don't neccessary need htmlentities()
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 03-21-2008, 05:02 AM Re: Form Security
Ultra Talker

Posts: 310
Trades: 0
Quote:
Originally Posted by rogem002 View Post
I'm a big fan of sterilisation. The functions are serialize($var) and unserialize($var) it's quite useful.
How will serialize and unserialize function will help with form security? I think you've misunderstood the purpose of those functions.

To the OP, validate user input, use mysql_real_escape or similar function for storing data in your db and use htmlentities function for displaying user generated content.
dman_2007 is offline
Reply With Quote
View Public Profile
 
Old 03-21-2008, 06:36 AM Re: Form Security
NullPointer's Avatar
Will Code for Food

Posts: 2,783
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by dman_2007 View Post
How will serialize and unserialize function will help with form security? I think you've misunderstood the purpose of those functions.

To the OP, validate user input, use mysql_real_escape or similar function for storing data in your db and use htmlentities function for displaying user generated content.
I don't think serialize and unseiralize were intended for this, but it has the same effect, any intended mysql injection once serialized would be to no avail.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-21-2008, 05:44 PM Re: Form Security
Truly's Avatar
Ultra Talker

Posts: 321
Trades: 0
If Im already encrypting a password with md5 I guess I dont really need this for the password but I supposed for anything SELECTED from a database I would need to and not just for inserting.

None of you guys mentioned strip_tags or w/e it is. Is that not necessary because Im using mysql_real_escape_string?
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Form Security
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26326 seconds with 12 queries