<?xml version="1.0" encoding="UTF-8"?>

<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
>

  <channel rdf:about="http://lwn.net/headlines/185813/">
    <title>LWN: Comments on "SQL injection vulnerabilities in PostgreSQL"</title>
    <link>http://lwn.net/Articles/185813/</link>
    <description>
This is a special feed containing comments posted
to the individual LWN article titled &quot;SQL injection vulnerabilities in PostgreSQL&quot;.

    </description>

    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>2</syn:updateFrequency>
    <items>
      <rdf:Seq>
	<rdf:li resource="http://lwn.net/Articles/251933/rss" />
	<rdf:li resource="http://lwn.net/Articles/186899/rss" />
	<rdf:li resource="http://lwn.net/Articles/186897/rss" />
	<rdf:li resource="http://lwn.net/Articles/186699/rss" />
	<rdf:li resource="http://lwn.net/Articles/186184/rss" />
	<rdf:li resource="http://lwn.net/Articles/186141/rss" />
	<rdf:li resource="http://lwn.net/Articles/186119/rss" />
	<rdf:li resource="http://lwn.net/Articles/186092/rss" />
	<rdf:li resource="http://lwn.net/Articles/186080/rss" />
	<rdf:li resource="http://lwn.net/Articles/186040/rss" />
	<rdf:li resource="http://lwn.net/Articles/186011/rss" />
	<rdf:li resource="http://lwn.net/Articles/186003/rss" />
	<rdf:li resource="http://lwn.net/Articles/186002/rss" />
	<rdf:li resource="http://lwn.net/Articles/185999/rss" />
	<rdf:li resource="http://lwn.net/Articles/185957/rss" />
	<rdf:li resource="http://lwn.net/Articles/185954/rss" />
	<rdf:li resource="http://lwn.net/Articles/185951/rss" />
	<rdf:li resource="http://lwn.net/Articles/185919/rss" />
	<rdf:li resource="http://lwn.net/Articles/185917/rss" />
	<rdf:li resource="http://lwn.net/Articles/185914/rss" />
	<rdf:li resource="http://lwn.net/Articles/185911/rss" />
	<rdf:li resource="http://lwn.net/Articles/185890/rss" />
	<rdf:li resource="http://lwn.net/Articles/185888/rss" />
	<rdf:li resource="http://lwn.net/Articles/185880/rss" />
	<rdf:li resource="http://lwn.net/Articles/185851/rss" />
	<rdf:li resource="http://lwn.net/Articles/185850/rss" />
	<rdf:li resource="http://lwn.net/Articles/185846/rss" />
	<rdf:li resource="http://lwn.net/Articles/185841/rss" />
	<rdf:li resource="http://lwn.net/Articles/185832/rss" />
	<rdf:li resource="http://lwn.net/Articles/185827/rss" />
      
      </rdf:Seq>
    </items>

  </channel>
    <item rdf:about="http://lwn.net/Articles/251933/rss">
      <title>Preventing SQL injection with stored procedures</title>
      <link>http://lwn.net/Articles/251933/rss</link>
      <dc:date>2007-09-27T18:50:32+00:00</dc:date>
      <dc:creator>einhverfr</dc:creator>
      <description>
      I know this is an old post, but there is one area where this can make a difference.&lt;br&gt;
&lt;p&gt;
The stored procedure idea does not prevent sql injection.  However, in combination with appropriate db permissions it could be used to arbitrarily restrict what a user can do in the database.  If the db is locked down well enough, and all access is through stored procs, and if you use db native accounts, you may not have to worry about sql injection attacks in the application in the same way you would otherwise.&lt;br&gt;
&lt;p&gt;
There are, however, two big caveat to this issue.  If user-supplied input is used to create the stored procedure name, this could be exploitable as well.  The second is that not all queries are parameterizable inside stored procedures on all databases.  Hence you could have SQL injection *inside* your stored procedures.  In some cases, you have just moved the issues of SQL injection tracking back into the stored procs.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186899/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/186899/rss</link>
      <dc:date>2006-06-09T09:25:13+00:00</dc:date>
      <dc:creator>aquasync</dc:creator>
      <description>
      This shouldn't matter, the ö will be replaced with \ö, and then when evaluated as an part of an sql string, it should be turned back into ö (even if it was actually made up of multiple bytes).&lt;br&gt;
That is provided that the escape policy is to replace \[\a-z]|(0-9){3} or whatever with the relevant unescaped thing, and otherwise to just copy the character verbatim into the output string.&lt;br&gt;
&lt;p&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186897/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/186897/rss</link>
      <dc:date>2006-06-09T09:03:38+00:00</dc:date>
      <dc:creator>aquasync</dc:creator>
      <description>
      Exactly, this seems a lot safer to me.&lt;br&gt;
Perl's quotemeta function works in this way, (``all characters not matching &quot;/[A-Za-z_0-9]/&quot; will be preceded by a backslash...''), and provided SQL's string escapes work in a similar way, there should be no problems.&lt;br&gt;
&lt;p&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186699/rss">
      <title>SQL injection vulnerabilities in PostgreSQL</title>
      <link>http://lwn.net/Articles/186699/rss</link>
      <dc:date>2006-06-08T08:57:24+00:00</dc:date>
      <dc:creator>philips</dc:creator>
      <description>
      UTF-8 was specifically designed to avoid such problems: all non ASCII characters have byte representation using non-ASCII only characters. And convieniently, all standard control symbols - like single quote, double quote, slash, back slash, percent, space - are in ASCII range.&lt;br&gt;
&lt;p&gt;
From all my long experience, UTF-8 can be very inconvinient to handle/etc, but still it saved (and still saves) me from many internationalization headaches: I have to live permanently with three locales.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186184/rss">
      <title>Preared statement syntax... is database dependent</title>
      <link>http://lwn.net/Articles/186184/rss</link>
      <dc:date>2006-06-04T06:12:15+00:00</dc:date>
      <dc:creator>dps</dc:creator>
      <description>
      Assuming I read the psoitgresql documentations straight you should change that ? into $1 when using postgreSQL (or Oracle, which I beleive would also allows you to use $foo too).&lt;br&gt;
&lt;p&gt;
MySQL and ODBC want a ? as shown in the aticle.&lt;br&gt;
&lt;p&gt;
If you are targeting the same query at both MySQL and postreSQL either doing utf8-aware string escaping, not using a multibyte character set (e.g. latin1), or implementing per-backend query syntax conversion is required. My code converts $&amp;lt;number&amp;gt; to ? becuase it makes the string shorter and is therefore easier to implement.&lt;br&gt;
&lt;p&gt;
Of course the psotgreSQL fix will test your exception handling capabilites when that query containing invalid utf-8 gets rejected for this reason. &lt;br&gt;
&lt;p&gt;
Also note that the 2nd (and 3rd, 4th, 5th and 6th) bytes in UTF-8 must satisfy (v &amp;amp; 0xc0==0x80). 0xc8 0x81 is valid UTF 8. 0xc8 0x5c and 0xc8 0xff are not valid UTF-8. Incidently 0xfe and 0xff *never* appear in valid UTF-8.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186141/rss">
      <title>afterthought i18n and the conservative software culture</title>
      <link>http://lwn.net/Articles/186141/rss</link>
      <dc:date>2006-06-03T15:59:35+00:00</dc:date>
      <dc:creator>tjc</dc:creator>
      <description>
      Yeah, you're right about the security aspect.&lt;p&gt; I was referring to the big political war that has dogged Unicode.  It got ugly.  It probably still is, but I don't seem to care anymore.
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186119/rss">
      <title>afterthought i18n and the conservative software culture</title>
      <link>http://lwn.net/Articles/186119/rss</link>
      <dc:date>2006-06-03T08:50:08+00:00</dc:date>
      <dc:creator>nim-nim</dc:creator>
      <description>
      &lt;font class=&quot;QuotedText&quot;&gt;&amp;gt; Just wanting to be PC isn't very motivating for most people.&lt;/font&gt;&lt;br&gt;
&lt;p&gt;
I don't see where the PC angle is when it ends up in security bugs (and this is not an isolated case). You're just confirming what I wrote.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186092/rss">
      <title>afterthought i18n and the conservative software culture</title>
      <link>http://lwn.net/Articles/186092/rss</link>
      <dc:date>2006-06-02T21:16:24+00:00</dc:date>
      <dc:creator>tjc</dc:creator>
      <description>
      &lt;blockquote type=&quot;cite&quot;&gt;The problem is 100% cultural, and I don't mean cultural in the sense americans don't speak other langages, I mean cultural in the sense the software community collectively decided not to tackle some problems.&lt;/blockquote&gt;
It's mostly a motivation problem. The people to whom it matters most are apparently not motivated enough, or insufficient in number, to do something about it.  The reason that most free/open source software only supports the ISO-Latin-1 character set is because that's what most developer's use themselves.&lt;p&gt; Just wanting to be PC isn't very motivating for most people.  The same goes for listening to other people bitch about what one ought to be doing with one's free time.
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186080/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/186080/rss</link>
      <dc:date>2006-06-02T19:02:31+00:00</dc:date>
      <dc:creator>mrshiny</dc:creator>
      <description>
      The only advantage, that I can think of, is that you can generate complete SQL statements ahead of time in one place, and later on execute them.  However, if that is the pattern you wish to accomplish, it's trivial to wrap the generated string and the arguments to bind together in one object.  Otherwise, I still don't see the problem... you can generate dynamic sql statements for prepared queries, and bind the parameters afterwards.  Where I work we do this all the time; also another poster in this thread has even gone to the lengths of creating an SQL statement abstraction that generates the SQL and stores the parameters to bind in one step.  It's easy and foolproof.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186040/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/186040/rss</link>
      <dc:date>2006-06-02T12:05:47+00:00</dc:date>
      <dc:creator>smitty_one_each</dc:creator>
      <description>
      &lt;font class=&quot;QuotedText&quot;&gt;&amp;gt;Frankly I'm confused as to why you WOULDN'T use prepared queries.&lt;/font&gt;&lt;br&gt;
&lt;p&gt;
Oh, the motives might break down along the traditional compiled/dynamic lines.&lt;br&gt;
I like to have a single function that can transform a the Request.Form into an arbitrary array of SQL statements, particularly for INSERT/UPDATE situations.&lt;br&gt;
For generic text fields, I just replace ' with `, and I'm on my merry way.  O`Neal never noticed, though I admit this could simply be &quot;moving the problem&quot;.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186011/rss">
      <title>SQL injection vulnerabilities in PostgreSQL</title>
      <link>http://lwn.net/Articles/186011/rss</link>
      <dc:date>2006-06-02T07:45:00+00:00</dc:date>
      <dc:creator>nim-nim</dc:creator>
      <description>
      You would be right but for the internet.&lt;br&gt;
&lt;p&gt;
When systems were not interconnected, or the interconnect was slow and limited, local encodings worked fine. Nowadays with dataflows all over the world local-encoding-only systems are the exception not the norm (show me an ascii-only system and I'm almost sure any serious investigation will find users frustrated by its encoding limitations)&lt;br&gt;
&lt;p&gt;
And anyway optimising for the ascii case when you end up turning i18n anyway is wrong on so many levels (speed, security) I won't expand on it.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186003/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/186003/rss</link>
      <dc:date>2006-06-02T02:45:13+00:00</dc:date>
      <dc:creator>xoddam</dc:creator>
      <description>
      &lt;font class=&quot;QuotedText&quot;&gt;&amp;gt; The same holds surely for folks from China or Japan. &lt;/font&gt;&lt;br&gt;
 &lt;br&gt;
Not to mention Iceland :-) &lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/186002/rss">
      <title>internationalisation</title>
      <link>http://lwn.net/Articles/186002/rss</link>
      <dc:date>2006-06-02T02:33:06+00:00</dc:date>
      <dc:creator>xoddam</dc:creator>
      <description>
      &lt;font class=&quot;QuotedText&quot;&gt;&amp;gt; frankly I want software that doesn't require i18n to be turned on.    &lt;/font&gt;&lt;br&gt;
    &lt;br&gt;
If the software supports internationalisation at all, then 'just ASCII   &lt;br&gt;
thanks' is one particular localisation, and there's nothing to switch   &lt;br&gt;
off.  A little extra optimisation for this case wouldn't be a bad idea   &lt;br&gt;
though.  &lt;br&gt;
  &lt;br&gt;
&lt;font class=&quot;QuotedText&quot;&gt;&amp;gt; processing multi-byte characters is slower then processing     &lt;/font&gt;&lt;br&gt;
&lt;font class=&quot;QuotedText&quot;&gt;&amp;gt; single byte characters (for a number of reasons).     &lt;/font&gt;&lt;br&gt;
   &lt;br&gt;
UTF8 helps with this as long as the vast majority of your characters are   &lt;br&gt;
in the ASCII range.  But UTF8 has its own minor performance headaches,   &lt;br&gt;
particularly in Eastern Asian locales where a 16-bit character is much   &lt;br&gt;
more convenient.   &lt;br&gt;
   &lt;br&gt;
A significant annoyance and performance issue is when such things as   &lt;br&gt;
font-measuring have per-character primitive methods that take a UCS32   &lt;br&gt;
parameter, and the string must be expanded repeatedly to its individual  &lt;br&gt;
characters (or cached as an array of 32-bit values).  Bringing the whole  &lt;br&gt;
UTF (8 or 16) string right down to the lowest level might eliminate some  &lt;br&gt;
of that overhead.  &lt;br&gt;
  &lt;br&gt;
&lt;font class=&quot;QuotedText&quot;&gt;&amp;gt; that's why the world survived with ascii for so long   &lt;/font&gt;&lt;br&gt;
  &lt;br&gt;
The world?  For 'so long'?  For how long exactly was the *American*   &lt;br&gt;
Standard the sole character set encoding in *any* non-English-language   &lt;br&gt;
environment?  The earliest Japanese derivatives of ASCII began to be  &lt;br&gt;
*standardised* in 1969 (JIS C 6220), while the US computing community was &lt;br&gt;
still worrying about converting between ASCII and ECBDIC. &lt;br&gt;
 &lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185999/rss">
      <title>SQL injection vulnerabilities in PostgreSQL</title>
      <link>http://lwn.net/Articles/185999/rss</link>
      <dc:date>2006-06-02T00:41:01+00:00</dc:date>
      <dc:creator>dlang</dc:creator>
      <description>
      frankly I want software that doesn't require i18n to be turned on. processing multi-byte characters is slower then processing single byte characters (for a number of reasons). I don't want to pay that overhead for systems that don't need it (and face it, most systems really don't need it, that's why the world survived with ascii for so long)&lt;br&gt;
&lt;p&gt;
as for the gui folks, it's not the pixles that are the issue, but the assumption that the gui software has the right to take the entire screen. if they didn't assume that they had the entire screen then the shape of that screen wouldn't matter&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185957/rss">
      <title>afterthought i18n and the conservative software culture</title>
      <link>http://lwn.net/Articles/185957/rss</link>
      <dc:date>2006-06-01T18:21:46+00:00</dc:date>
      <dc:creator>nim-nim</dc:creator>
      <description>
      So what ? You don't need to speak other langages to make the effort to learn and understand their technical requirements. Developpers have their software interact with hardware and software with much stranger and complex needs.&lt;br&gt;
&lt;p&gt;
The problem is 100% cultural, and I don't mean cultural in the sense americans don't speak other langages, I mean cultural in the sense the software community collectively decided not to tackle some problems. The nationality of the software writer matters very little - they all code from the same textbooks which all present computers as manipulating strings of mono-byte characters. Likewise GUI writers all use the same reference material which assumes screen pixel density is a known stable variable. (Of course the fact a lot of these textbooks are written by people immersed in the american english-only worldview does not help.)&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185954/rss">
      <title>backslashes</title>
      <link>http://lwn.net/Articles/185954/rss</link>
      <dc:date>2006-06-01T17:51:22+00:00</dc:date>
      <dc:creator>rfunk</dc:creator>
      <description>
      The article mentions that using backslashes as escape characters &lt;br&gt;
exacerpates the problem.  Unfortunately a major web-development language &lt;br&gt;
(PHP) encourages using backslashes as escape characters, with its &lt;br&gt;
addslashes() function and magic_quotes_gpc=on default. &lt;br&gt;
 &lt;br&gt;
The fact that these misfeatures may be deprecated or disrecommended now &lt;br&gt;
doesn't help much, since there's so much old documentation and advice out &lt;br&gt;
there, and so many PHP programmers who barely even understand what &lt;br&gt;
they're copying let alone the concept of SQL injection or multibyte &lt;br&gt;
characters. &lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185951/rss">
      <title>afterthought i18n and the conservative software culture</title>
      <link>http://lwn.net/Articles/185951/rss</link>
      <dc:date>2006-06-01T17:43:20+00:00</dc:date>
      <dc:creator>rfunk</dc:creator>
      <description>
      The problem is that the vast majority of Americans don't deal with  &lt;br&gt;
anything but English (and Anglicized spellings) in their everyday lives,  &lt;br&gt;
so i18n truly is an afterthought.  Worse, most of them can't read or  &lt;br&gt;
write any other languages either.  &lt;br&gt;
  &lt;br&gt;
As for a conservative software culture, part of it is developers who  &lt;br&gt;
don't (have time to?) keep up with current issues, but there's also a  &lt;br&gt;
strong culture of backward-compatibility.  Enough people have old stuff  &lt;br&gt;
that developing for the latest and greatest isn't necessarily a good  &lt;br&gt;
idea. The trick is to be able to develop for both old and new at once, &lt;br&gt;
and that's often difficult (requiring even more learning than for just &lt;br&gt;
the new) or impossible. &lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185919/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/185919/rss</link>
      <dc:date>2006-06-01T15:12:09+00:00</dc:date>
      <dc:creator>iabervon</dc:creator>
      <description>
      My version is using a prepared statement. My SQLBuffer contains a StringBuffer and a List, and SQLBuffer.add() appends a &quot;?&quot; to the buffer, and adds the argument to its list, which it goes through in fill() using the loop that you omitted from the end of your example. My version is really identical to yours, except that my SQLBuffer methods abstract the pattern that you're open-coding (and, therefore, it's harder to screw up).&lt;br&gt;
&lt;p&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185917/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/185917/rss</link>
      <dc:date>2006-06-01T14:50:15+00:00</dc:date>
      <dc:creator>mrshiny</dc:creator>
      <description>
      &lt;p&gt;I'd still feel better using a prepared statement, even if there are optional clauses in the statement.  In such cases I normally do something like this:&lt;/p&gt;

&lt;pre&gt;
List args = new ArrayList();
String sql = &quot;select * from daily_revenue where transaction type = ? &quot;;
args.add(transType);
if (sinceLastLogin) {
  sql += &quot; and trans_date &gt;= ? &quot;; // for lots of optional clauses, use StringBuffer
  args.add(lastLoginDate);
}
&lt;/pre&gt;

&lt;p&gt;Then later on you just bind all the variables in the order they appeared in the list.  Also you can use a var-args function (in Java 1.5 and other languages that support var-args) to automate things like date converstion; if the type of one of the objects in the args list is Date or Calendar or some other non-SQL-friendly type, you can convert it automatically.&lt;/p&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185914/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/185914/rss</link>
      <dc:date>2006-06-01T14:42:15+00:00</dc:date>
      <dc:creator>jschrod</dc:creator>
      <description>
      But this approach immediately leads to problems in an international context -- because most often it leads to the ban of all non-ASCII characters in names or addresses, as we have experienced so often in the past. But I live in Rödermark, and not in Rodermark or Roedermark, and I want to input that properly. The same holds surely for folks from China or Japan.&lt;br&gt;
&lt;p&gt;
Nah, IMNSHO prepared queries with parameters are the only proper way to go.&lt;br&gt;
&lt;p&gt;
Cheers, Joachim&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185911/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/185911/rss</link>
      <dc:date>2006-06-01T14:31:49+00:00</dc:date>
      <dc:creator>iabervon</dc:creator>
      <description>
      &lt;p&gt;The thing I find even stranger is that it's pretty simple to write an equivalent for StringBuffer that has different methods for appending SQL text and constants, and automatically handles formatting for PreparedStatements. So:
&lt;pre&gt;
SQLBuffer buffer = new SQLBuffer();
buffer.append(&quot;select * from user_acct where username = &quot;).
       add(username).append(&quot; and password = &quot;).
       add(password);
PreparedStatement stmt = connection.prepareStatement(buffer.getSQL());
buffer.fill(stmt);
stmt.executeQuery();
&lt;/pre&gt;
&lt;p&gt;
That way, you don't have to worry about getting the variables mixed up, or dealing with the fact that you can't really trust the database driver to handle a java.util.Date.
&lt;p&gt;
The example you gave isn't as compact in this form, but that difference goes away if you've got queries where some clause is optional.
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185890/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/185890/rss</link>
      <dc:date>2006-06-01T13:27:42+00:00</dc:date>
      <dc:creator>mrshiny</dc:creator>
      <description>
      &lt;p&gt;The thing is, SQL injection is trivial to prevent; simply use prepared statements with placeholders that are bound using an API.  This improves the performance of the system AND increases security... Frankly I'm confused as to why you WOULDN'T use prepared queries.&lt;p&gt;

&lt;p&gt;Consider this example:&lt;p&gt;

&lt;pre&gt;
String sql = &quot;select * from user_acct where username = '&quot; + username + &quot;' and password = '&quot; + password + &quot;'&quot;;
Statement stmt = connection.createStatement(sql);
stmt.executeQuery();
&lt;/pre&gt;
&lt;p&gt;In this case the database will get a new statement every time a new user tries to log in to the system.  The database usually caches compiled statements and execution plans to increase performance, but here each statement will look different.  Also, it's vulnerable to the SQL injection where the password is &lt;code&gt;' or 1 = 1--&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now consider the following example:&lt;p&gt;
&lt;code&gt;
String sql = &quot;select * from user_acct where username = ? and password = ?&quot;;
PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, username);
stmt.setString(2, password);
stme.executeQuery();
&lt;/code&gt;
&lt;p&gt;In this case, there is no chance for SQL injection, and furthermore the database can cache the SQL and execution plan on the server to increase performance, because for each user it is the same.  Clearly anyone who DOESN'T use prepared statements is in need of some job training or a new career path.&lt;/p&gt;

      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185888/rss">
      <title>Preventing SQL injection with stored procedures</title>
      <link>http://lwn.net/Articles/185888/rss</link>
      <dc:date>2006-06-01T13:18:35+00:00</dc:date>
      <dc:creator>mrshiny</dc:creator>
      <description>
      Right, place-holders in the prepared query will prevent injection attacks.  But the same functionality is available for normal queries, so I guess I'm not seeing how &quot;using stored procedures&quot; is advisable.  Really it comes down to &quot;use prepared queries/procedure-calls&quot;.  A developer who doesn't understand &quot;use prepared queries&quot; can't be trusted to make the leap to prepared queries for procedure calls.&lt;br&gt;
&lt;p&gt;
&lt;p&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185880/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/185880/rss</link>
      <dc:date>2006-06-01T12:39:39+00:00</dc:date>
      <dc:creator>jzbiciak</dc:creator>
      <description>
      We can't even get people to agree on strlcpy....  I can't imagine a more complex function getting traction easily.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185851/rss">
      <title>Preventing SQL injection with stored procedures</title>
      <link>http://lwn.net/Articles/185851/rss</link>
      <dc:date>2006-06-01T09:39:39+00:00</dc:date>
      <dc:creator>nix</dc:creator>
      <description>
      It's also more efficient to use prepared queries and (I think) easier to read.&lt;br&gt;
&lt;p&gt;
So you win on all fronts.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185850/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/185850/rss</link>
      <dc:date>2006-06-01T09:24:51+00:00</dc:date>
      <dc:creator>smitty_one_each</dc:creator>
      <description>
      Certainly the problem exists for multiple applications across arbitrary platforms.  Could something like the LSB champion an unbork_string( some_string ) function that Does The Right Thing, and then just gently ridicule everyone to get on board?&lt;br&gt;
The only winners in a piecemeal approach are the bad guys and the security consultants.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185846/rss">
      <title>Eliminating the problem</title>
      <link>http://lwn.net/Articles/185846/rss</link>
      <dc:date>2006-06-01T08:28:51+00:00</dc:date>
      <dc:creator>ncm</dc:creator>
      <description>
      Most injection holes are a result of trying to scrub user input by trying to escape characters from a list of troublemakers (or, worse, not bothering).  If, instead, programs would discard (or, if necessary, escape) all characters *except* those in a known-good list, most of the subtleties would vanish.  It's much better to eliminate a problem than to patch around it.&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185841/rss">
      <title>SQL injection vulnerabilities in PostgreSQL</title>
      <link>http://lwn.net/Articles/185841/rss</link>
      <dc:date>2006-06-01T08:15:43+00:00</dc:date>
      <dc:creator>nim-nim</dc:creator>
      <description>
      Both of these problems would have been avoided if there was a development  culture where i18n is not an afterthought and software writers validated their code with something else that english ASCII.&lt;br&gt;
&lt;p&gt;
The year-2000 bug was a joke, the we've-developped-in-english-ascii-then-turned-i18n-on bug will continue striking for years.&lt;br&gt;
&lt;p&gt;
And the worst part people are writing code *today* which assumes one char=one byte, and language=english. Even with a clear example of the consequences of this attitude your article manages to completely skip over this aspect.&lt;br&gt;
&lt;p&gt;
i18n is *not* a translator problem.&lt;br&gt;
&lt;p&gt;
(Another example of the way our software culture is profoundly conservative is the way GUI writers still think in terms of pixels and 75/96 dpi screens, while Dell and friends are maddly shipping whidescreen LCDs.)&lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185832/rss">
      <title>Preventing SQL injection with stored procedures</title>
      <link>http://lwn.net/Articles/185832/rss</link>
      <dc:date>2006-06-01T04:29:13+00:00</dc:date>
      <dc:creator>xoddam</dc:creator>
      <description>
      Your example prepares the procedure using untrusted input, so the &lt;br&gt;
prepared query itself is untrustworthy.  &lt;br&gt;
 &lt;br&gt;
Preparing stored queries without using untrusted input requires the use &lt;br&gt;
of placeholders for the arguments, and passing the input *later* when the &lt;br&gt;
query is executed.  Then no untrusted input will ever be parsed as SQL so &lt;br&gt;
there is no injection vulnerability. &lt;br&gt;
      
      </description>
    </item>
    <item rdf:about="http://lwn.net/Articles/185827/rss">
      <title>Preventing SQL injection with stored procedures</title>
      <link>http://lwn.net/Articles/185827/rss</link>
      <dc:date>2006-06-01T03:53:36+00:00</dc:date>
      <dc:creator>mrshiny</dc:creator>
      <description>
      I'm curious as to how using stored procedures prevents SQL injection?  In my experience you can create a call to a stored procedures just like a call to SQL:
&lt;pre&gt;
String query = &quot;{ call some_package.somefunc('&quot; + arg + &quot;'); }&quot;;
CallableStatement cs = connection.prepareCall(query);
cs.execute();
&lt;/pre&gt;

The above is just as vulnerable to sql injection as any normal SQL statement.  Am I missing something?
      
      </description>
    </item>
</rdf:RDF>

