Re: sql injection and php

From: Lincoln Yeoh (lyeoh@pop.jaring.my)
Date: 05/29/02


Date: Thu, 30 May 2002 04:25:19 +0800
To: Jacek Lach <jlach@utopia.pl.eu.org>, vuln-dev@securityfocus.com
From: Lincoln Yeoh <lyeoh@pop.jaring.my>

At 11:56 PM 5/28/02 +0000, Jacek Lach wrote:
>Hi,
>
>I hope the list is right :-)

You might get more help from the webappsec list.

>Does the magic_quotes in php's configuration resolves the problem of sql
>injection? Is this technique still a risk when the option is enabled?
>Most documentation I found was presenting ASP examples, but simple entering '
>character doesn't work when this option is enabled (which is set in default
>configuration).
>Thanks for any answers and/or references on the subject.

AFAIK magic_quotes is a bad[1] idea and design.

It is a bad idea to combine input filtering with output filtering.

You risk ending up with corrupted and inappropriately filtered data.

For example if your app ever submits quoted data to itself (or other
applications that don't require quoting) you end up misquoting. You start
seeing stuff like \' in all the wrong places.

Filters should be kept separate where possible. The various inputs to your
app should be filtered so your app can cope, output to browsers should be
filtered accordingly, output to different databases should be filtered
accordingly and so on.

If you find a program using magic_quotes, it's likely to have bad problems
elsewhere. If the programmer forgets to put certain variables between
single quotes, magic_quotes won't protect them.

Cheerio,
Link.

[1] I'm strongly tempted to use much harsher words, thus this footnote ;).



Relevant Pages

  • Re: C#Builder Or Delphi 8?
    ... > what they're filtering on, or what the values for the filters are. ... I worked on an app. ... query where he really did want all of the results. ... MD Anderson Dept. of Biostatistics & Applied Mathematics ...
    (borland.public.delphi.non-technical)
  • Re: Semi OT: get rid of the troll with nfilter/newsproxy
    ... That app hasn't been updated in newly five years, ... Filtering out any crossposted messages will ...
    (rec.photo.equipment.35mm)
  • Re: Stored Procedure - Dynamic Select
    ... I think you are right -- having the app do the 'filtering' is the best. ... I was hoping to save some bandwidth, but I don't think it worth the contortions to work around the rights issues. ...
    (microsoft.public.sqlserver.programming)
  • Re: Semi OT: get rid of the troll with nfilter/newsproxy
    ... That app hasn't been updated in newly five years, ... Whether of not it has been updated is totally irrelevant. ... it could already do what Matt recommends it for: filtering on ... cross-posted threads. ...
    (rec.photo.equipment.35mm)
  • DPGS allows any file to be overwritten
    ... Taken from the scripts website: ... This is the reasoning to why I did not contact the author prior to this email. ... This is an example of how bad input filtering and openbased on user input make a nasty combo. ...
    (Bugtraq)