pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedquery checking
5+ messages / 5 participants
[nested] [flat]
* query checking
@ 2001-01-22 00:44 s <stefang@bundabergcity.qld.gov.au>
2001-01-22 13:44 ` Re: query checking Chris Ryan <chris@greatbridge.com>
0 siblings, 1 reply; 5+ messages in thread
From: s @ 2001-01-22 00:44 UTC (permalink / raw)
To: pgsql-php
I am writing a site that
does select/insert SQL commands with users input.
There is a potential hazard if some one tries to execute there
own commands in an input box
eg. the user types into the input box on a form - [ "; delete *
from table; ]
I'm after a regular expression (that'd be nice) or an algorithm to
tell that only one query is being passed to psql at a time.
The query string will be processed if
Either - one SELECT command only
- one INSERT command only
- one UPDATE command only
ELSE - dont process query
Any input would be much appreciated.
thanks,
stef
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: query checking
2001-01-22 00:44 query checking s <stefang@bundabergcity.qld.gov.au>
@ 2001-01-22 13:44 ` Chris Ryan <chris@greatbridge.com>
0 siblings, 0 replies; 5+ messages in thread
From: Chris Ryan @ 2001-01-22 13:44 UTC (permalink / raw)
To: s <stefang@bundabergcity.qld.gov.au>; +Cc: pgsql-php
Probably the most direct way to look for and catch such attempts would
be to search for the semi-colon ';' and if it exists just give an error.
Chris Ryan
chris@greatbridge.com
s wrote:
>
> I am writing a site that
> does select/insert SQL commands with users input.
>
> There is a potential hazard if some one tries to execute there
> own commands in an input box
> eg. the user types into the input box on a form - [ "; delete *
> from table; ]
>
> I'm after a regular expression (that'd be nice) or an algorithm to
> tell that only one query is being passed to psql at a time.
>
> The query string will be processed if
> Either - one SELECT command only
> - one INSERT command only
> - one UPDATE command only
> ELSE - dont process query
>
> Any input would be much appreciated.
> thanks,
> stef
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: query checking
@ 2001-01-22 14:45 Timothy_Maguire@hartehanks.com
0 siblings, 0 replies; 5+ messages in thread
From: Timothy_Maguire@hartehanks.com @ 2001-01-22 14:45 UTC (permalink / raw)
To: s <stefang@bundabergcity.qld.gov.au>; +Cc: pgsql-php
You can try using the ereg() or eregi() functions and check for what the user
inputed. For example:
if (eregi("delete", $query)
{
echo " you can not delete from table";
}
elseif ( (eregi("select", $query) || (eregi("update", $query) ||
(eregi("insert", $query) )
{
execute $query;.....
}
Hope this helps.
Tim.
s <stefang@bundabergcity.qld.gov.au> on 01/21/2001 07:44:20 PM
To: pgsql-php@postgresql.org
cc: (bcc: Timothy Maguire/Data-Technologies/Harte-Hanks)
Subject: query checking
I am writing a site that
does select/insert SQL commands with users input.
There is a potential hazard if some one tries to execute there
own commands in an input box
eg. the user types into the input box on a form - [ "; delete *
from table; ]
I'm after a regular expression (that'd be nice) or an algorithm to
tell that only one query is being passed to psql at a time.
The query string will be processed if
Either - one SELECT command only
- one INSERT command only
- one UPDATE command only
ELSE - dont process query
Any input would be much appreciated.
thanks,
stef
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: query checking
@ 2001-01-23 20:37 Brent R. Matzelle <bmatzelle@yahoo.com>
2001-01-24 14:49 ` Re: Re: query checking Adam Lang <aalang@rutgersinsurance.com>
0 siblings, 1 reply; 5+ messages in thread
From: Brent R. Matzelle @ 2001-01-23 20:37 UTC (permalink / raw)
To: pgsql-php
You might also try giving the client user different rights to
the database. Only allow select, insert, and update but
disallowing any deletes. That way you won't need to build it
into your PHP code.
Brent
--- s <stefang@bundabergcity.qld.gov.au> wrote:
> I am writing a site that
> does select/insert SQL commands with users input.
>
> There is a potential hazard if some one tries to execute there
> own commands in an input box
> eg. the user types into the input box on a form - [ ";
> delete *
> from table; ]
>
> I'm after a regular expression (that'd be nice) or an
> algorithm to
> tell that only one query is being passed to psql at a time.
>
> The query string will be processed if
> Either - one SELECT command only
> - one INSERT command only
> - one UPDATE command only
> ELSE - dont process query
>
> Any input would be much appreciated.
> thanks,
> stef
>
=====
"The instructions said install windows 98 or better, so I installed Linux"
http://www.matzelle.net
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Re: query checking
2001-01-23 20:37 Re: query checking Brent R. Matzelle <bmatzelle@yahoo.com>
@ 2001-01-24 14:49 ` Adam Lang <aalang@rutgersinsurance.com>
0 siblings, 0 replies; 5+ messages in thread
From: Adam Lang @ 2001-01-24 14:49 UTC (permalink / raw)
To: pgsql-php
Even safer if yuo don't let users type in actual SQL at all.
Have a set of check boxes so they can pick which type of query they
want.(update, delete, select, etc.) Have them fill in fields and have them
fill in tables. Then, in your php code, construct the sql code yourself,
while checking the fields for ilelgal characters like ";"
Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
http://www.rutgersinsurance.com
----- Original Message -----
From: "Brent R. Matzelle" <bmatzelle@yahoo.com>
To: <pgsql-php@postgresql.org>
Sent: Tuesday, January 23, 2001 3:37 PM
Subject: [PHP] Re: query checking
> You might also try giving the client user different rights to
> the database. Only allow select, insert, and update but
> disallowing any deletes. That way you won't need to build it
> into your PHP code.
>
> Brent
>
> --- s <stefang@bundabergcity.qld.gov.au> wrote:
> > I am writing a site that
> > does select/insert SQL commands with users input.
> >
> > There is a potential hazard if some one tries to execute there
> > own commands in an input box
> > eg. the user types into the input box on a form - [ ";
> > delete *
> > from table; ]
> >
> > I'm after a regular expression (that'd be nice) or an
> > algorithm to
> > tell that only one query is being passed to psql at a time.
> >
> > The query string will be processed if
> > Either - one SELECT command only
> > - one INSERT command only
> > - one UPDATE command only
> > ELSE - dont process query
> >
> > Any input would be much appreciated.
> > thanks,
> > stef
> >
>
>
> =====
> "The instructions said install windows 98 or better, so I installed Linux"
>
> http://www.matzelle.net
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices.
> http://auctions.yahoo.com/
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2001-01-24 14:49 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-22 00:44 query checking s <stefang@bundabergcity.qld.gov.au>
2001-01-22 13:44 ` Chris Ryan <chris@greatbridge.com>
2001-01-22 14:45 Re: query checking Timothy_Maguire@hartehanks.com
2001-01-23 20:37 Re: query checking Brent R. Matzelle <bmatzelle@yahoo.com>
2001-01-24 14:49 ` Adam Lang <aalang@rutgersinsurance.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox