pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_query_params and SQL injection
2+ messages / 2 participants
[nested] [flat]
* pg_query_params and SQL injection
@ 2008-09-01 13:50 Kevin Golding <tearinghairout@yahoo.com>
2008-09-02 00:16 ` Re: pg_query_params and SQL injection ljb <ljb1813@pobox.com>
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Golding @ 2008-09-01 13:50 UTC (permalink / raw)
To: pgsql-php
Hi all
I am just doing some playing around with PHP to learn how to avoid SQL injection attacks.
It has been mentioned in a few places that pg_query_params is supposed to protect from sql injection without needing to mess around escaping quotes and things.
However, I was still able to get it to drop a table by feeding in this input "1; drop table results" to the following statement:
$r = pg_query_params($p, 'select * from results where res_id = $1', array($input));
Everyone keeps repeating the same "pg_query_params is safe from SQL injection", but surely someone else must have actually tried it? Where am I going wrong?
I am using Postgresql 8.3 for OS X on 10.5.2, and MAMP which has PHP Version 5.2.5.
Thanks
Kevin
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: pg_query_params and SQL injection
2008-09-01 13:50 pg_query_params and SQL injection Kevin Golding <tearinghairout@yahoo.com>
@ 2008-09-02 00:16 ` ljb <ljb1813@pobox.com>
0 siblings, 0 replies; 2+ messages in thread
From: ljb @ 2008-09-02 00:16 UTC (permalink / raw)
To: pgsql-php
tearinghairout@yahoo.com wrote:
> Hi all
> I am just doing some playing around with PHP to learn how to avoid SQL injection attacks.
> It has been mentioned in a few places that pg_query_params is supposed to protect from sql injection without needing to mess around escaping quotes and things.
>
> However, I was still able to get it to drop a table by feeding in this input "1; drop table results" to the following statement:
> $r = pg_query_params($p, 'select * from results where res_id = $1', array($input));
>
> Everyone keeps repeating the same "pg_query_params is safe from SQL injection", but surely someone else must have actually tried it? Where am I going wrong?
>
> I am using Postgresql 8.3 for OS X on 10.5.2, and MAMP which has PHP Version 5.2.5.
I can't duplicate it and don't think it is possible. I get this error:
PHP Warning: pg_query_params()
Query failed: ERROR: invalid input syntax for integer: "1; drop table results"
Take another look or post more of the code you tried.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2008-09-02 00:16 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-09-01 13:50 pg_query_params and SQL injection Kevin Golding <tearinghairout@yahoo.com>
2008-09-02 00:16 ` ljb <ljb1813@pobox.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