Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL
Author Message
Darrell3831
Worker
Worker



Joined: Feb 18, 2004
Posts: 244

PostPosted: Fri Feb 20, 2004 10:00 pm Reply with quote

I saw in someone elses code that they were reading a value from a database and immediately screening/validating it's value with intval().

Code:
$varname=intval($varname);


At first I thought nothing of it, but later while looking in the actual database the person was using I saw that the field was an intiger.

Is it necessary to see if the value read is an intiger when the only thing the field holds is an intiger?

I had assumed that you could not stick values that werent intigers into intiger fields...

Or perhaps this is some sort of back door insertion that he's trying to prevent?

Thanks,
Darrell

_________________
http://www.psy-center.com 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri Feb 20, 2004 10:11 pm Reply with quote

Darrell3831 wrote:
Or perhaps this is some sort of back door insertion that he's trying to prevent?
Thanks,
Darrell
BINGO!
 
View user's profile Send private message
Darrell3831







PostPosted: Fri Feb 20, 2004 10:18 pm Reply with quote

That's a bit discouraging.
 
Raven







PostPosted: Fri Feb 20, 2004 11:22 pm Reply with quote

Most of the sql injections piggy-back off of poorly written queries that all you to do something like add a union statement or AND'ing to the query variable. If you're passing, say sid=1 in the url (&sid=1), the query can often be hijacked by modifying it to &sid=1 or 1=1. Or &sid=1 Union select from .... So, depending on how your code processes the form literals, sql injection is often the result.
 
chatserv
Member Emeritus



Joined: May 02, 2003
Posts: 1389
Location: Puerto Rico

PostPosted: Sat Feb 21, 2004 11:56 am Reply with quote

Many times a value is extracted from a database table to be used in a url to another option in the module/file by adding a check to that value one attempts to make sure nothing else is passed through the variable in the url.
 
View user's profile Send private message Visit poster's website
Darrell3831







PostPosted: Sat Feb 21, 2004 5:13 pm Reply with quote

Oh boy,

Raven, you said often time poorly written querries can be hijacked.. Can you teach me the difference between well written ones and poorly written ones?

In the administrative part of the application I'm creating I do that a lot....

Code:
op=listLessons&cid=30


It's the only way I know how to do it.

Is there another safer way?

Thanks,
Darrell
 
Darrell3831







PostPosted: Sat Feb 21, 2004 5:24 pm Reply with quote

Chatserv,

Alright so input validators on all input, be it from user, function to function, or database......

I've had my nose in the nuke code now for a month and a lot of the functions just assume the values are as expected...

Darrell
 
chatserv







PostPosted: Sat Feb 21, 2004 5:49 pm Reply with quote

What a script kiddie attepts to pass through might not be saved to the db for the same reasons you state but that doesn't mean their injected code won't return the results they expect like grabbing your passwords.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©