From: Jason Uhlenkott <jpu31@uhlenkott.net>
To: pgsql-sql@postgresql.org
Subject: security: escaping user-supplied data
Date: Mon, 11 Oct 1999 16:31:04 -0800
Message-ID: <38028148.8066E930@uhlenkott.net> (raw)
I am writing a C program that will collect data from various untrusted
sources, and put it in a postgresql database by PQexec'ing an INSERT
INTO statement.
The statements I generate are usually of the form:
INSERT INTO foo (bar, bas) VALUES ('abc', 'def');
but the 'abc' and 'def' come from an untrusted source, so if they supply
a string like "def'); delete from foo; '" they can make me do this:
INSERT INTO foo (bar, bas) VALUES ('abc', 'def'); delete from foo; '');
What do I need to do to prevent this? My current plan is to prepend a
backslash to every single-quote, backslash, and semicolon in the
untrusted string. Are there any other special characters I should watch
out for? Is it possible to do something evil despite your special
characters being prepended with a backslash?
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-sql@postgresql.org
Cc: jpu31@uhlenkott.net
Subject: Re: security: escaping user-supplied data
In-Reply-To: <38028148.8066E930@uhlenkott.net>
References: <38028148.8066E930@uhlenkott.net>
* 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