<div class="gmail_quote">On Wed, Aug 12, 2009 at 12:51 PM,  <span dir="ltr">&lt;<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

I did recently learn that pyPgSQL doesn&#39;t support bind parameters,<br>
apparently resulting in almost any use of it insecure and vulnerable to<br>
SQL injection attacks.  You may want to investigate this further before<br>
deciding if it&#39;s worth figuring out how unicode works.<br>
</blockquote><div><br>I believe exarkun is referring to this article:<br><br>&lt;<a href="http://www.cerias.purdue.edu/site/blog/post/beware_sql_injections_due_to_missing_prepared_statement_support/">http://www.cerias.purdue.edu/site/blog/post/beware_sql_injections_due_to_missing_prepared_statement_support/</a>&gt;<br>
<br>I had a private discussion with the author to clarify.  In order to avoid spreading FUD, I&#39;d like to draw your attention to this note he added to the bottom of the post as a result of that discussion:<br><br><div style="margin-left: 40px;">
P.P.S.: To clarify, I haven&#39;t demonstrated an SQL injection
vulnerability in pyPGSQL. It&#39;s not about the performance penalty
either. It&#39;s about escaping done by the client library (the basic
implementation of bind parameters without using the database&#39;s support)
being a second-rate security solution to explicitly telling the
database &quot;here is the code. Now here&#39;s the data&quot; (prepared statements).
It&#39;s about decreasing code complexity and reducing chances for
&quot;misunderstandings&quot; (and configuration, e.g., encoding, discrepancies).
It&#39;s about assurance and choosing safer technologies and architectures.<br></div><br>So, to be clear, I don&#39;t believe there are any <i>demonstrated</i> injection vulnerabilities (although if someone has a reference to a current one, that would be helpful); it&#39;s just that pyPgSQL goes with an unnecessarily risky and poorly-performing implementation strategy for quoting parameters.  This dates back to Postgres itself having poor client-library support for bind parameters in versions previous to 7; unfortunately this means that most of the other database bindings for postgres use a similarly bad strategy (and as Mr. Meunier mentions in his post, the ones which do support bind parameters have other issues).<br>
<br></div></div>