Re: [SECURITY] DoS attack on backend possible - Mailing list pgsql-hackers

From ngpg@grymmjack.com
Subject Re: [SECURITY] DoS attack on backend possible
Date
Msg-id Xns92705D648F8D09wn7t0983uom3iu23n@64.49.215.80
Whole thread Raw
In response to Re: [SECURITY] DoS attack on backend possible  (Curt Sampson <cjs@cynic.net>)
List pgsql-hackers
cjs@cynic.net (Curt Sampson) wrote in
> On Mon, 19 Aug 2002 ngpg@grymmjack.com wrote:
> 
>> $input = "user'name";
>> INSERT INTO db (name) VALUES ('$input');
>>
>> will fail because the ' in the input needs to be escaped with a
>> backslash.
> 
> It will fail because you're doing this a very, very, very bad way.
> Why rewrite this kind of stuff when the vendor has already made
> correct code available?
> 
>     PreparedStatement stmt = connection.prepareStatement(
>      "INSERT INTO db (name) VALUES (?)");
>     stmt.setString("user'name");
>     stmt.execute();
> 
> cjs

Curt:
I am not doing it this way, I am trying to point out that doing it without 
"doing something" (whether it be using preparedstatement or WHATEVER), is, 
as you say, very very very bad (I am agreeing with you).  I am further 
saying that whatever it is you do, you should also be doing some other 
simple validation, like the length of the inputs, because most inputs wont 
be over 255 chars before being prepared.  This is just an example, but you 
should do whatever validation would apply to you (and this is probably true 
coding for any user input whether it involves a db or not).  I am just 
saying this is good practice in my opinion and had these people that 
brought up the issue in the first place were doing it, then pgsql's 
shortcomings would not have been as severe a problem.  Things I am not 
saying are:  its ok for pgsql to have this DoS problem;  its the frontends 
responsibility to maintain data integrity not the backend.


pgsql-hackers by date:

Previous
From: Jan Wieck
Date:
Subject: Re: @(#) Mordred Labs advisory 0x0001: Buffer overflow in
Next
From: Tom Lane
Date:
Subject: Re: @(#) Mordred Labs advisory 0x0001: Buffer overflow in