pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Rick Roman <rick@cotse.net>
Cc: pgsql-admin@postgresql.org
Subject: Re: Preventing sql injection
Date: Wed, 10 Aug 2005 13:11:08 -0400
Message-ID: <20050810171108.GF7871@alvh.no-ip.org> (raw)
In-Reply-To: <42FA330D.7020908@cotse.net>
References: <42FA330D.7020908@cotse.net>

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)



view thread (3+ messages)  latest in thread

Message-ID: <20050810171108.GF7871@alvh.no-ip.org>
Permalink:  ../20050810171108.GF7871@alvh.no-ip.org/
Also on:    postgresql.org/message-id/20050810171108.GF7871@alvh.no-ip.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: alvherre@alvh.no-ip.org, rick@cotse.net
  Subject: Re: Preventing sql injection
  In-Reply-To: <20050810171108.GF7871@alvh.no-ip.org>
  References: <42FA330D.7020908@cotse.net> <20050810171108.GF7871@alvh.no-ip.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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