Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Hackers > Re: Protection ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 47 of 56 Topic 9274 of 10114
Post > Topic >>

Re: Protection from SQL injection

by singh.gurjeet@[EMAIL PROTECTED] ("Gurjeet Singh") Apr 30, 2008 at 11:07 PM

------=_Part_3000_22716252.1209577075251
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Wed, Apr 30, 2008 at 10:58 PM, Tom Lane <tgl@[EMAIL PROTECTED]
> wrote:

> "Gurjeet Singh" <singh.gurjeet@[EMAIL PROTECTED]
> writes:
> > Maybe we can extend the SQL's WITH clause do declare the constant
along
> with
> > the query, and not separate from the query.
>
> > WITH CONSTANT c_jobrole = 'clerk', CONSTANT c_dept = 10
> > SELECT * FROM emp WHERE jobrole = c_jobrole and deptno = c_dept;
>
> [ scratches head... ]  And that will provide SQL injection protection
how?


Well, if the the query was:

WITH CONSTANT c_jobrole = <value from a FORM text field>, CONSTANT c_dept
=
10
SELECT * FROM emp WHERE jobrole = c_jobrole and deptno = c_dept;

And if the attack supplied a value 'clerk OR 1=1' the final query (after
replacing constants) would look like this:

SELECT * FROM emp WHERE jobrole = 'clerk OR 1=1' and deptno = 10;

The attacker was not able to inject any new code there.

(reiterates: and let postgres allow literals only in the WITH clause)


>
> Anyway, you hardly need new syntax to do that, I'd expect
>
>        WITH SELECT 'clerk' AS c_jobrole ...
>
> to accomplish it just fine.
>

I am not sure I understood this example.

Best regards,

-- 
gurjeet[.singh]@[EMAIL PROTECTED]
 gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device

------=_Part_3000_22716252.1209577075251
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Wed, Apr 30, 2008 at 10:58 PM, Tom Lane &lt;<a
href="mailto:tgl@[EMAIL PROTECTED]
">tgl@[EMAIL PROTECTED]
>&gt; wrote:<br><div
class="gmail_quote"><blockquote class="gmail_quote" style="border-left:
1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;">
<div class="Ih2E3d">&quot;Gurjeet Singh&quot; &lt;<a
href="mailto:singh.gurjeet@[EMAIL PROTECTED]
">singh.gurjeet@[EMAIL PROTECTED]
>&gt;
writes:<br>
&gt; Maybe we can extend the SQL&#39;s WITH clause do declare the constant
along with<br>
&gt; the query, and not separate from the query.<br>
<br>
&gt; WITH CONSTANT c_jobrole = &#39;clerk&#39;, CONSTANT c_dept = 10<br>
&gt; SELECT * FROM emp WHERE jobrole = c_jobrole and deptno = c_dept;<br>
<br>
</div>[ scratches head... ] &nbsp;And that will provide SQL injection
protection how?</blockquote><div><br>Well, if the the query
was:<br><br>WITH CONSTANT c_jobrole = &lt;value from a FORM text
field&gt;, CONSTANT c_dept = 10<br>

SELECT * FROM emp WHERE jobrole = c_jobrole and deptno =
c_dept;<br><br>And if the attack supplied a value &#39;clerk OR 1=1&#39;
the final query (after replacing constants) would look like this:<br><br>
SELECT * FROM emp WHERE jobrole = &#39;clerk OR 1=1&#39; and deptno =
10;<br><br>The attacker was not able to inject any new code
there.<br><br>(reiterates: and let postgres allow literals only in the
WITH clause) <br><br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid
rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
Anyway, you hardly need new syntax to do that, I&#39;d expect<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;WITH SELECT &#39;clerk&#39; AS c_jobrole
...<br>
<br>
to accomplish it just fine.<br></blockquote><div><br>I am not sure I
understood this example.<br><br>Best regards,
<br></div><div>&nbsp;<br></div></div>--
<br>gurjeet[.singh]@[EMAIL PROTECTED]
>singh.gurjeet@[EMAIL PROTECTED]
 gmail | hotmail |
indiatimes | yahoo }.com<br>
<br>EnterpriseDB <a
href="http://www.enterprisedb.com">http://www.enterprisedb.com</a><br><br>Mail
sent from my BlackLaptop device

------=_Part_3000_22716252.1209577075251--
 




 56 Posts in Topic:
Protection from SQL injection
thomas.tom.mueller@[EMAIL  2008-04-28 20:55:34 
Re: Protection from SQL injection
josh@[EMAIL PROTECTED] (  2008-04-28 12:09:29 
Re: Protection from SQL injection
sfrost@[EMAIL PROTECTED]   2008-04-28 15:17:35 
Re: Protection from SQL injection
lists@[EMAIL PROTECTED]   2008-04-28 23:00:18 
Re: Protection from SQL injection
direvus@[EMAIL PROTECTED]  2008-04-29 09:03:33 
Re: Protection from SQL injection
lists@[EMAIL PROTECTED]   2008-04-29 09:26:24 
Re: Protection from SQL injection
sam@[EMAIL PROTECTED] (S  2008-04-29 00:15:44 
Re: Protection from SQL injection
thomas.tom.mueller@[EMAIL  2008-04-29 13:37:37 
Re: Protection from SQL injection
kleptog@[EMAIL PROTECTED]  2008-04-29 15:16:12 
Re: Protection from SQL injection
lists@[EMAIL PROTECTED]   2008-04-29 15:29:44 
Re: Protection from SQL injection
tino@[EMAIL PROTECTED] (  2008-04-29 16:35:41 
Re: Protection from SQL injection
andrew@[EMAIL PROTECTED]   2008-04-29 11:05:54 
Re: Protection from SQL injection
tino@[EMAIL PROTECTED] (  2008-04-30 16:47:56 
Re: Protection from SQL injection
stark@[EMAIL PROTECTED]   2008-04-29 09:36:02 
Re: Protection from SQL injection
pgsql@[EMAIL PROTECTED]   2008-04-29 19:44:29 
Re: Protection from SQL injection
tgl@[EMAIL PROTECTED] (T  2008-04-29 10:58:17 
Re: Protection from SQL injection
aidan@[EMAIL PROTECTED]   2008-04-29 11:23:04 
Re: Protection from SQL injection
josh@[EMAIL PROTECTED] (  2008-04-29 11:39:09 
Re: Protection from SQL injection
lists@[EMAIL PROTECTED]   2008-04-29 21:06:18 
Re: Protection from SQL injection
stark@[EMAIL PROTECTED]   2008-04-29 14:19:51 
Re: Protection from SQL injection
aidan@[EMAIL PROTECTED]   2008-04-29 16:01:44 
Re: Protection from SQL injection
thomas.tom.mueller@[EMAIL  2008-04-29 21:29:41 
Re: Protection from SQL injection
thomas.tom.mueller@[EMAIL  2008-04-29 22:18:48 
Re: Protection from SQL injection
andrew@[EMAIL PROTECTED]   2008-04-29 16:33:01 
Re: Protection from SQL injection
ajs@[EMAIL PROTECTED] (A  2008-04-29 16:55:21 
Re: Protection from SQL injection
ajs@[EMAIL PROTECTED] (A  2008-04-29 17:23:39 
Re: Protection from SQL injection
josh@[EMAIL PROTECTED] (  2008-04-29 15:24:10 
Re: Protection from SQL injection
thomas.tom.mueller@[EMAIL  2008-05-01 19:00:25 
Re: Protection from SQL injection
andrew@[EMAIL PROTECTED]   2008-05-01 13:09:38 
Re: Protection from SQL injection
tgl@[EMAIL PROTECTED] (T  2008-05-01 13:25:07 
Re: Protection from SQL injection
josh@[EMAIL PROTECTED] (  2008-04-29 14:10:20 
Re: Protection from SQL injection
adsmail@[EMAIL PROTECTED]  2008-04-30 02:19:21 
Re: Protection from SQL injection
singh.gurjeet@[EMAIL PROT  2008-04-30 06:17:03 
Re: Protection from SQL injection
stark@[EMAIL PROTECTED]   2008-04-29 21:02:30 
Re: Protection from SQL injection
josh@[EMAIL PROTECTED] (  2008-04-29 18:20:36 
Re: Protection from SQL injection
ajs@[EMAIL PROTECTED] (A  2008-04-30 10:20:09 
Re: Protection from SQL injection
kleptog@[EMAIL PROTECTED]  2008-04-30 22:58:34 
Re: Protection from SQL injection
tgl@[EMAIL PROTECTED] (T  2008-04-30 17:33:38 
Re: Protection from SQL injection
ajs@[EMAIL PROTECTED] (A  2008-05-01 09:13:27 
Re: Protection from SQL injection
hannu@[EMAIL PROTECTED]   2008-04-29 23:21:10 
Re: Protection from SQL injection
lists@[EMAIL PROTECTED]   2008-04-30 12:55:06 
Re: Protection from SQL injection
books@[EMAIL PROTECTED]   2008-04-30 10:08:25 
Re: Protection from SQL injection
thomas.tom.mueller@[EMAIL  2008-04-30 14:42:51 
Re: Protection from SQL injection
thomas.tom.mueller@[EMAIL  2008-04-30 17:22:50 
Re: Protection from SQL injection
singh.gurjeet@[EMAIL PROT  2008-04-30 22:41:08 
Re: Protection from SQL injection
tgl@[EMAIL PROTECTED] (T  2008-04-30 13:28:19 
Re: Protection from SQL injection
singh.gurjeet@[EMAIL PROT  2008-04-30 23:07:55 
Re: Protection from SQL injection
aidan@[EMAIL PROTECTED]   2008-04-30 13:50:25 
Re: Protection from SQL injection
stark@[EMAIL PROTECTED]   2008-05-01 11:07:08 
Re: Protection from SQL injection
tgl@[EMAIL PROTECTED] (T  2008-05-01 11:26:21 
Re: Protection from SQL injection
ajs@[EMAIL PROTECTED] (A  2008-05-01 11:47:04 
Re: Protection from SQL injection
lists@[EMAIL PROTECTED]   2008-05-01 18:33:07 
Re: Protection from SQL injection
ajs@[EMAIL PROTECTED] (A  2008-05-01 15:17:37 
Re: Protection from SQL injection
fw@[EMAIL PROTECTED] (Fl  2008-05-04 19:38:45 
Re: Protection from SQL injection
Chris Browne <cbbrowne  2008-05-05 10:28:12 
Re: Protection from SQL injection
andrew@[EMAIL PROTECTED]   2008-05-05 14:00:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 2:21:40 CDT 2008.