TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-18-2007, 03:23 PM   #21 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 836
Thanks: 31
sketchMedia is on a distinguished road
Default

Good article, made for interesting reading.

A generic rule to apply (the very basic attack prevention) is "filter input, escape output" just be paranoid about everything that is inputted into your system, start now if you dont so you dont have to learn the hard way :(

There is also another quite common session security issue with php, if your site is its on a shared host ie its not on its own dedicated server.

An good article explaining what it is and how to prevent it: http://phpsec.org/projects/guide/5.html

There are some other interesting security articles on that site too

peace out
sketchMedia is offline  
Reply With Quote
Old 11-23-2007, 08:16 PM   #22 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Very awesome article. I've read it completely and I must say, bravo.

My system is protected against querystring attacks. Every command MySQL uses, every designated die or exit function is blocked an I left nothing to coincidence there.

Refering back to the mysql_real_escape_string and the sprintf command. I still don't quite understand those. What's up with them. Are they handy to use, easy to filter out and do they provide a safe security and a easy handle?

Next to that, my cookies are stored ... well, of course on a users PC, but stored quite safely.

I used part of a method mr. buddha 'invented'. So to speak anyways. I retrieve the ID from the user, the username, the sha1 (4x) md5 (4x) password, the IP, the browser (incl language) and the time. Next, I am pushing it all into a once again formatted sha1 (4x) md5 (4x) string, which I call the cookies validationkey. For short, unforgeable as I know it. Since you cannot copy the login SECOND, IP, Language, Browser, username and 8 times encrypted password. Next, I push it, when succesfuly logged in, into the users database, where it's stored as user_validationkey. That is the key which will be refreshed every time. The NEXT thing I do, is of course update the userrecords and give the cookie an ID of it's own. It's almost logical that the $_SESSION[ID] and user_id still stored the user's ID, but sessions don't last as long as 30day cookies, or more.

Well, I am quite amazed by the topic but as you can see and if I am correct, my system is at least a little bit foolproof. Tho I bet some of your handy people could still get in.

What do you guys think?
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 11-23-2007, 10:17 PM   #23 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,053
Thanks: 115
Tanax is on a distinguished road
Default

FILTER is a thing I've never heard before, but it's quite handy for forms.

This is a bit long, but you'll get the point:
php Code:
$arguements = array(
           
                'user_name' => array(
                               
                                'filter' => FILTER_SANITIZE_STRING,
                                'flags' => FILTER_NULL_ON_FAILURE
                               
                                ),
                               
                'user_pass' => array(
                               
                                'filter' => FILTER_SANITIZE_STRING,
                                'flags' => FILTER_NULL_ON_FAILURE
                               
                                ),
                               
                'user_pass_re' => array(
                               
                                'filter' => FILTER_SANITIZE_STRING,
                                'flags' => FILTER_NULL_ON_FAILURE
                               
                                ),
                               
                'user_email' => array(
                               
                                'filter' => FILTER_VALIDATE_EMAIL,
                                'flags' => FILTER_NULL_ON_FAILURE
                               
                                ),
                               
                'user_firstname' => array(
                               
                                'filter' => FILTER_SANITIZE_STRING,
                                'flags' => FILTER_NULL_ON_FAILURE
                               
                                ),
                               
                'user_surname' => array(
                               
                                'filter' => FILTER_SANITIZE_STRING,
                                'flags' => FILTER_NULL_ON_FAILURE
                               
                                ),
                               
                'user_age' => array(
                               
                                'filter' => FILTER_VALIDATE_INT,
                                'flags' => FILTER_NULL_ON_FAILURE
                               
                                ),
                               
                'user_country' => array(
                               
                                'filter' => FILTER_SANITIZE_STRING,
                                'flags' => FILTER_NULL_ON_FAILURE
                               
                                ),
                               
                'user_location' => array(
                               
                                'filter' => FILTER_SANITIZE_STRING,
                                'flags' => FILTER_NULL_ON_FAILURE
                               
                                )
           
                );
           
            $data = filter_input_array(INPUT_POST, $arguements);

This would be pretty safe(notice that this is not completely safe, but it's still a good way to start - or add to - your security).

The FILTER_NULL_ON_FAILURE works like it returns NULL if the field isn't filled. And it returns FALSE when the FILTER fails.

And also, how to then get to your cleaned data, would be like this(pretty obvious, but meh.. :P):
php Code:
$data['user_name'], $data['user_pass'], $data['user_email'], $data['user_firstname'], $data['user_surname'], $data['user_country'], $data['user_location'], $data['user_age']
Tanax is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 02:55 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design