Re: SQL injection - Mailing list pgsql-general

From Matthew D. Fuller
Subject Re: SQL injection
Date
Msg-id 20051101104513.GF1367@over-yonder.net
Whole thread Raw
In response to Re: SQL injection  (Ben <bench@silentmedia.com>)
Responses Re: SQL injection  (Kevin Murphy <murphy@genome.chop.edu>)
List pgsql-general
On Mon, Oct 31, 2005 at 10:12:45AM -0800 I heard the voice of
Ben, and lo! it spake thus:
> Maybe I'm not very creative, but it sure seems to me that if you
> escape your strings, make sure your numbers are numbers, and your
> booleans are actually booleans, then you're protected....

Once nice touch is that booleans and numbers will be accepted by Pg if
they're escaped and quoted like strings.  So, in PHP, I always run
EVERYTHING through a wrapper db_quote() function that returns
something like ("'" . pg_escape_string(foo) . "'") (or its equivalent
in MySQL, etc) and just call it fixed.  Of course, I do type checks
for user feedback and such as well, but in case something slips
through, it's all escaped.


--
Matthew Fuller     (MF4839)   |  fullermd@over-yonder.net
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: after insert or update or delete of col2
Next
From: Jan Wieck
Date:
Subject: Re: Oracle 10g Express - any danger for Postgres?