Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-07-2007, 10:31 PM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 99
Default How to filter Input Parameters

Hi,

When we are working with GET, POST or COOKIE data at least myself i am wondering "what if someone is trying to hijack the code". So, i am trying to convert all params i get from those sources using various techniques.

Let me show you one simple case (before using Zend Framework, now trying to upgrade this side to ZF too):

if(isset($_GET["page"]))
$page = $_GET["page"] = intval($_GET["page"]);
else
$page = "1";

In this case the param is a number, but anyway, can be a small text even (not necessary without any other characters: maybe is a product name: Metal-Pieces or similar).

So, which would be the best technique to ensure someone not trying to force your code. Could be even an attempt to SQL inject you database ?

Of course Zend_DB provides mechanisms (->quote() or others) to defend against such things, but maybe is better to try stopping all since beginning... On GET, POST, aso...

So, any opinions ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-08-2007, 11:41 PM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 121
Default

personally, I would use $page= int $value; instead...

As for input parameters, the only way to keep yourself safe is to validate everything. Zend_Filter and Zend_Validate do make this alot easier because you can write your own 'filters' and 'validators'.

And of course we are in a ZF forums so I am baised here
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-09-2007, 05:30 AM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 99
Default

Ok, i think best idea is to write my own filters and validators then.

Because the same situation is over most of the sites i guess the best is to make some filters and validators and reuse for each project.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-28-2007, 05:45 PM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 99
Default

< Comment after 0.9.0 was released >

Zend_Input_Filter is no longer on ZF, so i guess that's a bad thing, applications would be less secure then...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-28-2007, 09:34 PM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 121
Default

not necessarily, security is only as good as the programmer makes it (or doesnt make it)
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-29-2007, 04:57 AM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 99
Default

Yes, but an easier API for securing side would help...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-23-2007, 02:38 PM
tdm tdm is offline
Junior Member
 
Join Date: May 2007
Posts: 1
Default

Quote:
Originally Posted by Cristian View Post
< Comment after 0.9.0 was released >

Zend_Input_Filter is no longer on ZF, so i guess that's a bad thing, applications would be less secure then...
Yes, Zend_Input_Filter is no longer in ZF, but there's Zend_Filter instead
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-23-2007, 09:33 PM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 121
Default

actually, I think it is coming back in 1.0 as Zend_Filter_Input
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

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



All times are GMT. The time now is 04:44 AM.