PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Darrell3831
Worker
Worker


Joined: Feb 18, 2004
Posts: 244

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

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
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

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

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 Visit poster's website AIM Address Yahoo Messenger
Darrell3831
Worker
Worker


Joined: Feb 18, 2004
Posts: 244

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

That's a bit discouraging.
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

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

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.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
chatserv
The Mouse Is Extension Of Arm


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

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

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
Worker
Worker


Joined: Feb 18, 2004
Posts: 244

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

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
View user's profile Send private message Visit poster's website
Darrell3831
Worker
Worker


Joined: Feb 18, 2004
Posts: 244

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

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
View user's profile Send private message Visit poster's website
chatserv
The Mouse Is Extension Of Arm


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

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

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.
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum