pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Preventing sql injection
3+ messages / 2 participants
[nested] [flat]

* Preventing sql injection
@ 2005-08-10 17:02  Rick Roman <rick@cotse.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Rick Roman @ 2005-08-10 17:02 UTC (permalink / raw)
  To: pgsql-admin

I have a web application that will allow users to submit comments. The 
database activity consists of a single insert statement into a comments 
table. I want to lock down this operation against sql injection attacks. 
Can someone point me to a discussion of general principles? I've seen 
reference to V3 extended-query protocol. Where is this invoked? Other 
suggestions?



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Preventing sql injection
@ 2005-08-10 17:11  Alvaro Herrera <alvherre@alvh.no-ip.org>
  parent: Rick Roman <rick@cotse.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Alvaro Herrera @ 2005-08-10 17:11 UTC (permalink / raw)
  To: Rick Roman <rick@cotse.net>; +Cc: pgsql-admin

On Wed, Aug 10, 2005 at 10:02:05AM -0700, Rick Roman wrote:
> I have a web application that will allow users to submit comments. The 
> database activity consists of a single insert statement into a comments 
> table. I want to lock down this operation against sql injection attacks. 
> Can someone point me to a discussion of general principles? I've seen 
> reference to V3 extended-query protocol. Where is this invoked? Other 
> suggestions?

What language are you using?

The general principle is that you have to look user input for certain
chars, such as ' and \, and escape them somehow.

There's another way, which is using new features of the v3 protocol.
One easy way to do that is using PQexecParams() instead of PQexec(), if
you are dealing with C programs.

-- 
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"In a specialized industrial society, it would be a disaster
to have kids running around loose." (Paul Graham)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Preventing sql injection
@ 2005-08-10 17:14  Rick Roman <rick@cotse.net>
  parent: Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Rick Roman @ 2005-08-10 17:14 UTC (permalink / raw)
  To: pgsql-admin

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Alvaro Herrera wrote:
<blockquote cite="mid20050810171108.GF7871@alvh.no-ip.org" type="cite">
  <pre wrap="">On Wed, Aug 10, 2005 at 10:02:05AM -0700, Rick Roman wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">I have a web application that will allow users to submit comments. The 
database activity consists of a single insert statement into a comments 
table. I want to lock down this operation against sql injection attacks. 
Can someone point me to a discussion of general principles? I've seen 
reference to V3 extended-query protocol. Where is this invoked? Other 
suggestions?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
What language are you using?

The general principle is that you have to look user input for certain
chars, such as ' and \, and escape them somehow.

There's another way, which is using new features of the v3 protocol.
One easy way to do that is using PQexecParams() instead of PQexec(), if
you are dealing with C programs.

  </pre>
</blockquote>
I am using PG 7.3, Java through the OBJ Object/relational bridge.<br>
</body>
</html>



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-08-10 17:14 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-10 17:02 Preventing sql injection Rick Roman <rick@cotse.net>
2005-08-10 17:11 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
2005-08-10 17:14   ` Rick Roman <rick@cotse.net>

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