pen-test
[Top] [All Lists]

Re: Magic Quotes question

To: Justin Ferguson <jnferguson@gmail.com>
Subject: Re: Magic Quotes question
From: Tim <tim-pentest@sentinelchicken.org>
Date: Sat, 20 Jan 2007 10:05:32 -0500
Cc: pen-test@securityfocus.com
Delivered-to: sp-com-lists@consult.net
Delivered-to: pentest-list2@consult.net
Delivered-to: mailing list pen-test@securityfocus.com
Delivered-to: moderator for pen-test@securityfocus.com
In-reply-to: <705543260701191153o4cbd85c8i6b5dcd11b22c5164@mail.gmail.com>
List-help: <mailto:pen-test-help@securityfocus.com>
List-id: <pen-test.list-id.securityfocus.com>
List-post: <mailto:pen-test@securityfocus.com>
List-subscribe: <mailto:pen-test-subscribe@securityfocus.com>
List-unsubscribe: <mailto:pen-test-unsubscribe@securityfocus.com>
Mailing-list: contact pen-test-help@securityfocus.com; run by ezmlm
References: <20070116165531.92543.qmail@cgisecurity.net> <00a301c73a06$92806010$650fa8c0@labtop> <E9E5210E-3713-4972-A585-B288F4686F01@opus1.com> <705543260701191153o4cbd85c8i6b5dcd11b22c5164@mail.gmail.com>
Resent-date: Mon, 22 Jan 2007 12:09:27 -0700 (MST)
Resent-from: pen-test-return-1078483449@securityfocus.com
Resent-message-id: <20070122190927.EA0A5182070@outgoing2.securityfocus.com>
Resent-sender: listbounce@securityfocus.com
Sender: listbounce@securityfocus.com
User-agent: Mutt/1.5.13 (2006-08-11)
> Why wouldnt you just put the escape function inside of the database
> query et al API function and then make a run-time configuration where
> it could be turned off? So that only strings passed to the database
> are escaped, they are always escaped unless you specifically turn it
> off and its use is transparent to the end user? i.e.
> 
> EXPORTED_API_T
> database_query(query, ...)
> {
>        if (getconfig->add_slashes)
>                add_slashes(query);
> 
>       db_query(query, ...);
> }


That's the whole idea behind perpared statements, and you should always
use them.  For a while PHP didn't even have this kind of API (does it
even have that now?), which is quite alarming, but more sensible
languages (e.g. Perl, Python, etc) have had them for a long time.

For those not familiar, a prepared statement in Python might look like:

 query = "SELECT * FROM foo WHERE firstname=?"
 cursor->execute(query, "Joe")


Notice how nice it is to have a decent API?  No work on your part and no
foolish hacks like addslashes() or magic quotes.

tim

------------------------------------------------------------------------
This List Sponsored by: Cenzic

Need to secure your web apps?
Cenzic Hailstorm finds vulnerabilities fast.
Click the link to buy it, try it or download Hailstorm for FREE.

http://www.cenzic.com/products_services/download_hailstorm.php?camp=701600000008bOW
------------------------------------------------------------------------


<Prev in Thread] Current Thread [Next in Thread>