Re: [PHP] Malicious SQL

2004-07-08 Thread John W. Holmes
Philip Olson wrote: on the contrary: sql = mysql_query("select * from users where name='".$name."'"); will simply look for a user with a name of "Jim; delete from users;" and return no results found. But I can also enter: jim'; delete from users You need to catch if there's a quote in the $name too

Re: [PHP] Malicious SQL

2004-07-08 Thread Matthew Sims
> In article <[EMAIL PROTECTED]>, > Philip Olson wrote: >> One thing to remember is mysql_query() will execute just one (the first) >> query so use of ; won't do anything in the above except break the >> query. > > If i'm not mistaken, newer versions of mysql do allow multiple queries. I've heard

Re: [PHP] Malicious SQL

2004-07-08 Thread Tim Van Wassenhove
In article <[EMAIL PROTECTED]>, Philip Olson wrote: > One thing to remember is mysql_query() will execute just one (the first) > query so use of ; won't do anything in the above except break the > query. If i'm not mistaken, newer versions of mysql do allow multiple queries. > (once) and put s

Re: [PHP] Malicious SQL

2004-07-08 Thread Philip Olson
> > on the contrary: > > sql = mysql_query("select * from users where name='".$name."'"); > > > > will simply look for a user with a name of "Jim; delete from users;" and > > return no results found. > > But I can also enter: > jim'; delete from users > > You need to catch if there's a quote in

Re: [PHP] Malicious SQL

2004-07-08 Thread Reuben D. Budiardja
On Wednesday 07 July 2004 12:05, Keith Greene wrote: > on the contrary: > sql = mysql_query("select * from users where name='".$name."'"); > > will simply look for a user with a name of "Jim; delete from users;" and > return no results found. But I can also enter: jim'; delete from users You nee

Re: [PHP] Malicious SQL

2004-07-07 Thread Jason Wong
On Thursday 08 July 2004 00:05, Keith Greene wrote: Here's a simple (and probably quite common) example of how not checking user input will lead to disaster: DELETE FROM users WHERE userid = $userid userid is an integer column. If you didn't check your inputs and someone injected $userid

Re: [PHP] Malicious SQL

2004-07-07 Thread John W. Holmes
Matthew Sims wrote: I think a good programming habit it to treat it as if it were off. With regards to magic_quotes_gpc, you can't just "treat it as if it were off" otherwise you may end up escaping data twice if it's not really off on a server that runs your code. Detect it's value with get_mag

Re: [PHP] Malicious SQL

2004-07-07 Thread John W. Holmes
Justin Patrin wrote: On Wed, 7 Jul 2004 10:31:17 -0700, Brian Dunning <[EMAIL PROTECTED]> wrote: The PHP directive magic_quotes_gpc is on by default, and it essentially runs addslashes() on all GET, POST, and COOKIE data. Why doesn't this automatically prevent injections, since it escapes out an

Re: [PHP] Malicious SQL

2004-07-07 Thread John W. Holmes
Brian Dunning wrote: I have a question about this. Here is from the documentation: The PHP directive magic_quotes_gpc is on by default, and it essentially runs addslashes() on all GET, POST, and COOKIE data. Why doesn't this automatically prevent injections, since it escapes out any single qu

Re: [PHP] Malicious SQL

2004-07-07 Thread Matthew Sims
> On Wed, 7 Jul 2004 10:31:17 -0700, Brian Dunning <[EMAIL PROTECTED]> > wrote: >> I have a question about this. Here is from the documentation: >> >> The PHP directive magic_quotes_gpc is on by default, and it >> essentially runs addslashes() on all GET, POST, and COOKIE data. >> >> Why doesn'

Re: [PHP] Malicious SQL

2004-07-07 Thread Justin Patrin
On Wed, 7 Jul 2004 10:31:17 -0700, Brian Dunning <[EMAIL PROTECTED]> wrote: > I have a question about this. Here is from the documentation: > > The PHP directive magic_quotes_gpc is on by default, and it > essentially runs addslashes() on all GET, POST, and COOKIE data. > > Why doesn't this a

Re: [PHP] Malicious SQL

2004-07-07 Thread Josh Close
It may escape a quote, but injections would still be possible in other ways. It gets passed in as \' but then used normally as ' when it's the the variable. -Josh On Wed, 7 Jul 2004 10:31:17 -0700, Brian Dunning <[EMAIL PROTECTED]> wrote: > I have a question about this. Here is from the document

Re: [PHP] Malicious SQL

2004-07-07 Thread Brian Dunning
I have a question about this. Here is from the documentation: The PHP directive magic_quotes_gpc is on by default, and it essentially runs addslashes() on all GET, POST, and COOKIE data. Why doesn't this automatically prevent injections, since it escapes out any single quotes they try to subm

Re: [PHP] Malicious SQL

2004-07-07 Thread Matt M.
> SELECT autoQuesID, fldQuesTitle, fldBody FROM tblFAQ_Question WHERE > (blnHidden = FALSE AND ((fldBody LIKE '%$strCriteria%') OR (fldQuesTitle > LIKE '%$strCriteria%'))); Say $strCriteria comes from one of the values in the $_REQUEST array, a user change is coming through in that variable. so

Re: [PHP] Malicious SQL

2004-07-07 Thread Keith Greene
For example, if you are not quoting your criteria: sql = mysql_query("select * from users where name=".$name); if someone enters the following in the name field, you're toast: "Jim; delete from users;" on the contrary: sql = mysql_query("select * from users where name='".$name."'"); will simply loo

RE: [PHP] Malicious SQL

2004-07-07 Thread Jay Blanchard
[snip] Can someone help me understand how people are able to use SQL maliciously if you don't protect against it in PHP? [/snip] This is a complex subject, but let us say that you didn't do checking at all, someone might be able to pass a delete statement in a form box like "DELETE FROM `table` WH