Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 10th, 2008, 9:32 PM   #1
Logical1
Programmer
 
Logical1's Avatar
 
Join Date: Apr 2008
Posts: 47
Rep Power: 0 Logical1 is on a distinguished road
Question Security

I have started a project of my own -non for profit- databased web site to help students who are looking for summer job. (as you might have guessed from my previous questions). I am very worried about hacking and malicious attempts at deleting the database or causing problem.
What expereinces do you have and what measures do you find necessary when working with MySQL, PHP and JS in developing such interactive web sites?
Altough no one will be paying for anything and it is an experiment of my own still I feel it has to be secure as a professional job (in real life yours truly is not a professional programmer as you might have correctly figured out. But I find this type of programmng very interesting hobby, very much like clock makers of a few centuries ago).
Yours
Logical 1
PS In case anyone is interested in participating in such a project let me know. But meanwhile please suggest measures to make the thing secure for the users.
__________________
^c^
Logical1 is offline   Reply With Quote
Old Jun 10th, 2008, 10:44 PM   #2
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 754
Rep Power: 3 Jimbo is on a distinguished road
Re: Security

Validate all and any user input - this is key. Use mysql_real_escape_string() for any and all input that goes into a query. Consider using parameterized queries or stored procedures (not sure what PHP/MySQL supports in this regard, you'll have to look around). Also learning about SQL Injection attacks (the biggest exploit you're trying to prevent) and how to prevent them might yield other ideas.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is online now   Reply With Quote
Old Jun 10th, 2008, 11:25 PM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Re: Security

The first thing that came to my mind was SQL Injection, which Jimbo has already mentioned. Best bet, for starters, is to read up on that and determine the most efficient way to block such an attack. May as well block all of China and Taiwan while your at it.. j/k
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Jun 11th, 2008, 1:53 AM   #4
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3 kruptof is on a distinguished road
Re: Security

Also look into sanitizing all your user generated content to protect against cross site scripting.
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Jun 14th, 2008, 12:03 PM   #5
Logical1
Programmer
 
Logical1's Avatar
 
Join Date: Apr 2008
Posts: 47
Rep Power: 0 Logical1 is on a distinguished road
Thanks and ..

Thank you for your answers but I am still in the dark.
1. My server runs PHP 4.0.3 and I can not run mysql_real_escape_string() on it. Altough this does not much more then addslashes() or other similar stuff.
2. If a hacker would try to gain access he has to pass arguments into the forms. What specific examples do you know and if my forms are simple such as
Name:
Email:
Phone:
Job title:
Job description:

and the entries go to specific columns in specific tables how can they hack?
3. Does anyone know a good PHP encryption function somehwere?
4. How do you sanitize your entires against SQL code entered instead of nomal entries?
5. This issue sounds so vague that one doesn't know what to prevent. I can write code against what I know might happen, problem is that in this case I do not know what else can be tried.
thanks
__________________
^c^
Logical1 is offline   Reply With Quote
Old Jun 15th, 2008, 5:07 AM   #6
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 754
Rep Power: 3 Jimbo is on a distinguished road
Re: Security

1. It escapes any values which might affect a SQL query, IIRC. You can certainly use alternates or build your own.
2. If you don't validate the input going into the database, someone might try to read the data in it, or even just delete it (if you don't understand the comic, ask). They might also try to change arbitrary values or insert data.
4. Validate the data, or find an alternative to creating the SQL query in the webpage (e.g. stored procedures).
5. SQL Injection is a pretty well understood attack; understanding how it works hinges a lot (IMHO) on finding a description which is worded along the same lines your brain operates.
Cross-site scripting (XSS), which kruptof brought up, is an attack largely brought about by the rise of AJAX, and it usually involves a malicious script which sends data contained in your website to whoever injected the script. Information about how the attack works and how to prevent it should still be plenty of data available, if you look hard enough.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is online now   Reply With Quote
Old Jun 16th, 2008, 8:23 PM   #7
Logical1
Programmer
 
Logical1's Avatar
 
Join Date: Apr 2008
Posts: 47
Rep Power: 0 Logical1 is on a distinguished road
thank you

Thanks Jimbo and eveybody else.
1. Silly as it seems, I think I have to write a function similar to mysql_real_escape_string() so it would run on my old version.
2. I have searched and did not find any way in PHP to read or recognize history (last page viewed , etc.) . Does any one have a solution for it?
I am trying to find the last page before any form gets processed and limit it only to my own ligitimate form (to avoid XSS).
3. If any one knows of a good book in this topic it is highly apreciated

When I started this project I though t I would be happy to see it work, apparently that's only half the problem.
L1
__________________
^c^
Logical1 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Local Security Policy..CAN'T FIND IT!! csrocker101 Coder's Corner Lounge 1 Feb 22nd, 2008 5:40 PM
Directory Security PhilBon Visual Basic .NET 4 Jul 12th, 2007 10:52 AM
Security Alert! Heba PHP 2 Mar 11th, 2006 11:29 PM
Tutorial - PHP Security Darkhack PHP 17 Dec 12th, 2005 4:23 PM
Is Hotmail Or The Email Server Becoming Low In Security? pr0gm3r Coder's Corner Lounge 13 Oct 14th, 2005 7:00 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:38 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC