pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Obfuscated stored procedures (was Re: Oracle and Postgresql)
31+ messages / 14 participants
[nested] [flat]

* Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 00:29  Bill Moran <wmoran@collaborativefusion.com>
  0 siblings, 1 reply; 31+ messages in thread

From: Bill Moran @ 2008-09-16 00:29 UTC (permalink / raw)
  To: Greg Smith <gsmith@gregsmith.com>; +Cc: Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

Greg Smith <gsmith@gregsmith.com> wrote:
> 
> The problem here is that the PostgreSQL community is fully aware how bogus 
> any encryption method is and doesn't even bother, while Oracle is 
> perfectly happy selling a solution that is easily bypassed.  Don't get me 
> wrong--the work involved is just difficult enough that I'm sure most 
> PL/SQL procedures are quite safe from being reversed, and what you get 
> back again will be kind of crummy code, so that's good enough for your 
> typical ISV.  But the security doesn't stand up to simple scrutiny, and a 
> highly visible open-source project doing the same quality of 
> implementation would receive seriously bad press for releasing something 
> so shoddy.  PostgreSQL would be compelled to name it something like 
> "half-assed obfuscation" in order to make it clear just how limited the 
> protection actually is, and then you've kind of lost the sales pitch that 
> motivated the feature in the first place.

I don't understand why this is so bloody difficult to implement:
Extend SECURITY DEFINER to include allowing only the definer to read
the code.

What more than that needs to be done to have honest to goodness secure
procedures?

-- 
Bill Moran
Collaborative Fusion Inc.

wmoran@collaborativefusion.com
Phone: 412-422-3463x4023



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 00:50  David Fetter <david@fetter.org>
  parent: Bill Moran <wmoran@collaborativefusion.com>
  0 siblings, 2 replies; 31+ messages in thread

From: David Fetter @ 2008-09-16 00:50 UTC (permalink / raw)
  To: Bill Moran <wmoran@collaborativefusion.com>; +Cc: Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

On Mon, Sep 15, 2008 at 08:29:22PM -0400, Bill Moran wrote:
> Greg Smith <gsmith@gregsmith.com> wrote:
> > 
> > The problem here is that the PostgreSQL community is fully aware
> > how bogus any encryption method is and doesn't even bother, while
> > Oracle is perfectly happy selling a solution that is easily
> > bypassed.  Don't get me wrong--the work involved is just difficult
> > enough that I'm sure most PL/SQL procedures are quite safe from
> > being reversed, and what you get back again will be kind of crummy
> > code, so that's good enough for your typical ISV.  But the
> > security doesn't stand up to simple scrutiny, and a highly visible
> > open-source project doing the same quality of implementation would
> > receive seriously bad press for releasing something so shoddy.
> > PostgreSQL would be compelled to name it something like
> > "half-assed obfuscation" in order to make it clear just how
> > limited the protection actually is, and then you've kind of lost
> > the sales pitch that motivated the feature in the first place.
> 
> I don't understand why this is so bloody difficult to implement:

First, make a case for implementing PL obfuscation under any
circumstances.

While you are making your case, please bear in mind that security by
obscurity is in effect an attack launched from that nastiest of places
to have an attacker, the inside of your trust boundaries.

Cheers,
David.
-- 
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle andPostgresql)
@ 2008-09-16 01:17  Gregory Williamson <Gregory.Williamson@digitalglobe.com>
  parent: David Fetter <david@fetter.org>
  1 sibling, 0 replies; 31+ messages in thread

From: Gregory Williamson @ 2008-09-16 01:17 UTC (permalink / raw)
  To: David Fetter <david@fetter.org>; Bill Moran <wmoran@collaborativefusion.com>; +Cc: Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

David Fetter shaped the electron traffic to say:
<...snip...>
> 
> First, make a case for implementing PL obfuscation under any
> circumstances.
> 
> While you are making your case, please bear in mind that security by
> obscurity is in effect an attack launched from that nastiest of places
> to have an attacker, the inside of your trust boundaries.

Devil's advocate since I don't like any form of security by obscurity [or most any other o-word]. 

We can set permissions to prevent a user from seeing the data in a table (REVOKE SELECT FROM ...) but if they have access to the database it is hard (impossible ? I have never tried...) to prevent them from seeing the _existence_ of the table and even the structure. 

Isn't this analogous to not allowing users to see a procedure's innards, but allowing them to see the name, parameters and return type ?

Ditto for trust ... let me be root and I will be able to get around any security you have. Roles and users not withstanding.

Greg Williamson
Senior DBA
DigitalGlobe

Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information and must be protected in accordance with those provisions. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

(My corporate masters made me say this.)

^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 02:11  Bill Moran <wmoran@collaborativefusion.com>
  parent: David Fetter <david@fetter.org>
  1 sibling, 1 reply; 31+ messages in thread

From: Bill Moran @ 2008-09-16 02:11 UTC (permalink / raw)
  To: David Fetter <david@fetter.org>; +Cc: Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

David Fetter <david@fetter.org> wrote:
>
> On Mon, Sep 15, 2008 at 08:29:22PM -0400, Bill Moran wrote:
> > Greg Smith <gsmith@gregsmith.com> wrote:
> > > 
> > > The problem here is that the PostgreSQL community is fully aware
> > > how bogus any encryption method is and doesn't even bother, while
> > > Oracle is perfectly happy selling a solution that is easily
> > > bypassed.  Don't get me wrong--the work involved is just difficult
> > > enough that I'm sure most PL/SQL procedures are quite safe from
> > > being reversed, and what you get back again will be kind of crummy
> > > code, so that's good enough for your typical ISV.  But the
> > > security doesn't stand up to simple scrutiny, and a highly visible
> > > open-source project doing the same quality of implementation would
> > > receive seriously bad press for releasing something so shoddy.
> > > PostgreSQL would be compelled to name it something like
> > > "half-assed obfuscation" in order to make it clear just how
> > > limited the protection actually is, and then you've kind of lost
> > > the sales pitch that motivated the feature in the first place.
> > 
> > I don't understand why this is so bloody difficult to implement:
> 
> First, make a case for implementing PL obfuscation under any
> circumstances.

The fact that it comes up every now and again on this list and creates
a thread of discussion eight miles long ...

But that's not even important, I'm not asking anyone to _do_ it, I'm
asking why, every time this topic comes up, it provokes such a long,
painful thread of argument.

> While you are making your case, please bear in mind that security by
> obscurity is in effect an attack launched from that nastiest of places
> to have an attacker, the inside of your trust boundaries.

Since when am I asking for security through obscurity?  I'm not telling
you to move ssh to an unusual port in the hopes that nobody will notice
that your root password is "password1".

What I'm _asking_ is why would extending SECURITY DEFINER to include
preventing unauthorized users from viewing code _not_ be a valid method
of securing the code.  Whether or not enough people want it to justify
the manpower to do it is a different discussion altogether.

-- 
Bill Moran
Collaborative Fusion Inc.

wmoran@collaborativefusion.com
Phone: 412-422-3463x4023



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 02:19  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bill Moran <wmoran@collaborativefusion.com>
  0 siblings, 2 replies; 31+ messages in thread

From: Tom Lane @ 2008-09-16 02:19 UTC (permalink / raw)
  To: Bill Moran <wmoran@collaborativefusion.com>; +Cc: David Fetter <david@fetter.org>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

Bill Moran <wmoran@collaborativefusion.com> writes:
> What I'm _asking_ is why would extending SECURITY DEFINER to include
> preventing unauthorized users from viewing code _not_ be a valid method
> of securing the code.

Because it's so full of obvious loopholes.  Yes, it might slow down
someone who didn't have superuser access to the database or root access
to the machine it's on; but that doesn't count as secure really.  The
problem is that the people who ask for this type of feature are usually
imagining that they can put their code on customer-controlled machines
and it will be safe from the customer's eyes.  Well, it isn't, and
I don't think Postgres should encourage them to think it is.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 12:40  Bill Moran <wmoran@collaborativefusion.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 2 replies; 31+ messages in thread

From: Bill Moran @ 2008-09-16 12:40 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David Fetter <david@fetter.org>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

In response to Tom Lane <tgl@sss.pgh.pa.us>:

> Bill Moran <wmoran@collaborativefusion.com> writes:
> > What I'm _asking_ is why would extending SECURITY DEFINER to include
> > preventing unauthorized users from viewing code _not_ be a valid method
> > of securing the code.
> 
> Because it's so full of obvious loopholes.  Yes, it might slow down
> someone who didn't have superuser access to the database or root access
> to the machine it's on; but that doesn't count as secure really.  The
> problem is that the people who ask for this type of feature are usually
> imagining that they can put their code on customer-controlled machines
> and it will be safe from the customer's eyes.  Well, it isn't, and
> I don't think Postgres should encourage them to think it is.

Shame that.  I can imagine it being a useful feature in certain situations
(such as a hosted environment), although I understand the concern.

Code obfuscation is the norm, though.  The world at large still seems to
believe that compiling code make it secret, despite the fact that crooks
have demonstrated again and again that they're more than willing to read
through opcodes, and the fact that there are decompilers available for
just about every major compiled format.

-- 
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/

wmoran@collaborativefusion.com
Phone: 412-422-3463x4023



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 13:15  Glyn Astill <glynastill@yahoo.co.uk>
  parent: Bill Moran <wmoran@collaborativefusion.com>
  1 sibling, 1 reply; 31+ messages in thread

From: Glyn Astill @ 2008-09-16 13:15 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; +Cc: David Fetter <david@fetter.org>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

> Because it's so full of obvious loopholes.  Yes,
> it might slow down
> > someone who didn't have superuser access to the
> database or root access
> > to the machine it's on; but that doesn't count
> as secure really.  The
> > problem is that the people who ask for this type of
> feature are usually
> > imagining that they can put their code on
> customer-controlled machines
> > and it will be safe from the customer's eyes. 
> Well, it isn't, and
> > I don't think Postgres should encourage them to
> think it is.
> 

As much as I'm impressed with the "we do it properly or not at all" attitude, it'd be nice if there was an option to stop the casual user from viewing code.

I'll admit to obfusicating bits and pieces using C, even though the function and everything it acts on are tied down with permissions. I understand in reality it provides no real extra security but somehow users being able to easily view something they don't have access to execute beyond it's name just feels wrong.


      



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 13:31  Merlin Moncure <mmoncure@gmail.com>
  parent: Glyn Astill <glynastill@yahoo.co.uk>
  0 siblings, 3 replies; 31+ messages in thread

From: Merlin Moncure @ 2008-09-16 13:31 UTC (permalink / raw)
  To: glynastill@yahoo.co.uk; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; David Fetter <david@fetter.org>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

On Tue, Sep 16, 2008 at 9:15 AM, Glyn Astill <glynastill@yahoo.co.uk> wrote:
>
> As much as I'm impressed with the "we do it properly or not at all" attitude, it'd be nice if there was an option to stop the casual user from viewing code.
>
> I'll admit to obfusicating bits and pieces using C, even though the function and everything it acts on are tied down with permissions. I understand in reality it provides no real extra security but somehow users being able to easily view something they don't have access to execute beyond it's name just feels wrong.

This is one of those threads that reappears like magic every six
months or so.  The last round of discussion went longer than normal
including a couple of routes to implementation.

One big reason why nothing hasn't been done is that there is a decent
'low tech' obfuscation tactic already: remove select access from
pg_proc to the user accounts in question and 'public'.  This will
essentially disable casual browsing of procedure code from user
accounts.

Any real solution should focus on:
*) key management (any serious discussion with encryption starts here)
*) other things you can do with function source besides encryption

for example, take a look at one idea I had (not at all vetted, but a start):
http://archives.postgresql.org/pgsql-performance/2007-12/msg00337.php

merlin



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 13:38  Gregory Williamson <Gregory.Williamson@digitalglobe.com>
  parent: Merlin Moncure <mmoncure@gmail.com>
  2 siblings, 0 replies; 31+ messages in thread

From: Gregory Williamson @ 2008-09-16 13:38 UTC (permalink / raw)
  To: Merlin Moncure <mmoncure@gmail.com>; glynastill@yahoo.co.uk; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; David Fetter <david@fetter.org>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

Nice trick ... thanks!

> One big reason why nothing hasn't been done is that there is a decent
> 'low tech' obfuscation tactic already: remove select access from
> pg_proc to the user accounts in question and 'public'.  This will
> essentially disable casual browsing of procedure code from user
> accounts.
<....>
> merlin

^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 13:39  Jonathan Bond-Caron <jbondc@openmv.com>
  parent: Bill Moran <wmoran@collaborativefusion.com>
  1 sibling, 2 replies; 31+ messages in thread

From: Jonathan Bond-Caron @ 2008-09-16 13:39 UTC (permalink / raw)
  To: 'Bill Moran' <wmoran@collaborativefusion.com>; 'Tom Lane' <tgl@sss.pgh.pa.us>; +Cc: 'David Fetter' <david@fetter.org>; 'Greg Smith' <gsmith@gregsmith.com>; pgsql-general

On Tue Sep 16 08:40 AM, Bill Moran wrote:
> In response to Tom Lane <tgl@sss.pgh.pa.us>:
> 
>> Bill Moran <wmoran@collaborativefusion.com> writes:
>>> What I'm _asking_ is why would extending SECURITY DEFINER to include 
>>> preventing unauthorized users from viewing code _not_ be a valid 
>>> method of securing the code.
>> 
>> Because it's so full of obvious loopholes.  Yes, it might slow down 
>> someone who didn't have superuser access to the database or root 
>> access to the machine it's on; but that doesn't count as secure 
>> really.  The problem is that the people who ask for this type of 
>> feature are usually imagining that they can put their code on 
>> customer-controlled machines and it will be safe from the customer's 
>> eyes.  Well, it isn't, and I don't think Postgres should encourage
> them to think it is.
> 
> Shame that.  I can imagine it being a useful feature in certain 
> situations (such as a hosted environment), although I understand the 
> concern.
> 
> Code obfuscation is the norm, though.  The world at large still seems 
> to believe that compiling code make it secret, despite the fact that 
> crooks have demonstrated again and again that they're more than 
> willing to read through opcodes, and the fact that there are 
> decompilers available for just about every major compiled format.
> 

I agree here. I hope there's a consensus that it does offer some level of
protection. 

After some research, I found this article that I believe will make a
stronger use case: 
http://www.iosn.net/network/news/Managing%20the%20insider%20threat%20through
%20code%20obfuscation

Whether or not it belongs in PG I don't really have an opinion. 






^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 13:55  Glyn Astill <glynastill@yahoo.co.uk>
  parent: Merlin Moncure <mmoncure@gmail.com>
  2 siblings, 0 replies; 31+ messages in thread

From: Glyn Astill @ 2008-09-16 13:55 UTC (permalink / raw)
  To: Merlin Moncure <mmoncure@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; David Fetter <david@fetter.org>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

> One big reason why nothing hasn't been done is that
> there is a decent
> 'low tech' obfuscation tactic already: remove
> select access from
> pg_proc to the user accounts in question and
> 'public'.  This will
> essentially disable casual browsing of procedure code from
> user
> accounts.

Neat :-)


      



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-16 14:31  Andrew Sullivan <ajs@commandprompt.com>
  parent: Jonathan Bond-Caron <jbondc@openmv.com>
  1 sibling, 0 replies; 31+ messages in thread

From: Andrew Sullivan @ 2008-09-16 14:31 UTC (permalink / raw)
  To: pgsql-general

On Tue, Sep 16, 2008 at 09:39:03AM -0400, Jonathan Bond-Caron wrote:
> 
> I agree here. I hope there's a consensus that it does offer some level of
> protection. 

There is not, in fact, in the security community a consensus that it
offers some level of protection.  There are some security people who
think that obfuscation and secrets are one of the tools (and one of
the weakest) to protect the computing infrastructure.  There are
others who claim, as strongly and with as great authority, that
anything that cannot be secured even if the attacker knows all about
it (excluding the private key itself) cannot be secured at all.
 
> After some research, I found this article that I believe will make a
> stronger use case:
> http://www.iosn.net/network/news/Managing%20the%20insider%20threat%20through
> %20code%20obfuscation

That article is not evidence for your conclusion.  Obfuscated code in
the example cases in the article would not be a good investment.  

In the first example, an insider who is an expert in the system
deleted a key file: it would make no difference if the code were
obfuscated, because an expert operator doesn't need to understand the
innards in order to be able to know which files are critical.  (Your
expert operators _have_ to know which are critical, because they have
to pay more attention to those files.)  

In the second example, of Mallory the disgruntled employee, we don't
have any information about what Mallory knows; so either Mallory's
defeat of the access controls (which is the real problem) will give
Mallory access to a system she understands, or else she'll have to
comprehend a complex system on the fly while evading detection of the
access control failure.  Obfuscation isn't likely to provide
additional defence against a vandal, which is what the
disgruntled-employee scenario represents.

Finally, the bigger example of distributed code that is decompilable
doesn't prove much, either.  If you are analysing the code in order to
attack it for a given end, you can do this just as easily with opaque
bytes (if you couldn't, Windows wouldn't be plagued with the security
problems it is: there wasn't a remarkable rash of new exploits that
appeared after the apparently leaking of the Windows source).

Obfuscation is mostly useful against the casual attacker.  There are
better and less costly measures against such attackers.  In
particular, careful management of access controls is far more
important.  

The important thing to remember is that, if the secrecy of the system
is your main or only defence, you're going to be in trouble because
such systems are brittle.  When they fail, they fail spectacularly.

All of that said, I can in fact think of use cases where casual users
not being able to view the source of a function could be useful.
These cases have more to do with corporate governance and internal
"Chinese walls" than any real security.  They're the sort of thing
that would make auditors happy, and for that reason they might be
worth implementing.  So far, I don't believe anyone's had an itch of
this sort strong enough to scratch.  

A

-- 
Andrew Sullivan
ajs@commandprompt.com
+1 503 667 4564 x104
http://www.commandprompt.com/



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-23 19:52  Bruce Momjian <bruce@momjian.us>
  parent: Merlin Moncure <mmoncure@gmail.com>
  2 siblings, 1 reply; 31+ messages in thread

From: Bruce Momjian @ 2008-09-23 19:52 UTC (permalink / raw)
  To: Merlin Moncure <mmoncure@gmail.com>; +Cc: glynastill@yahoo.co.uk; Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; David Fetter <david@fetter.org>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general


Added to TODO under features not wanted:

	Incomplete itemObfuscated function source code (not wanted)
	
	    Obfuscating function source code has minimal protective benefits
	because anyone with super-user access can find a way to view the code.
	To prevent non-super-users from viewing function source code, remove
	SELECT permission on pg_proc. 


---------------------------------------------------------------------------

Merlin Moncure wrote:
> On Tue, Sep 16, 2008 at 9:15 AM, Glyn Astill <glynastill@yahoo.co.uk> wrote:
> >
> > As much as I'm impressed with the "we do it properly or not at all" attitude, it'd be nice if there was an option to stop the casual user from viewing code.
> >
> > I'll admit to obfusicating bits and pieces using C, even though the function and everything it acts on are tied down with permissions. I understand in reality it provides no real extra security but somehow users being able to easily view something they don't have access to execute beyond it's name just feels wrong.
> 
> This is one of those threads that reappears like magic every six
> months or so.  The last round of discussion went longer than normal
> including a couple of routes to implementation.
> 
> One big reason why nothing hasn't been done is that there is a decent
> 'low tech' obfuscation tactic already: remove select access from
> pg_proc to the user accounts in question and 'public'.  This will
> essentially disable casual browsing of procedure code from user
> accounts.
> 
> Any real solution should focus on:
> *) key management (any serious discussion with encryption starts here)
> *) other things you can do with function source besides encryption
> 
> for example, take a look at one idea I had (not at all vetted, but a start):
> http://archives.postgresql.org/pgsql-performance/2007-12/msg00337.php
> 
> merlin
> 
> -- 
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-24 14:12  Glyn Astill <glynastill@yahoo.co.uk>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 31+ messages in thread

From: Glyn Astill @ 2008-09-24 14:12 UTC (permalink / raw)
  To: Merlin Moncure <mmoncure@gmail.com>; Bruce Momjian <bruce@momjian.us>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; David Fetter <david@fetter.org>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

I'm not sure what the policy is on putting stuff in the docs, but how about putting that in the relevant place, as well as a note about the other option; using C and SPI.


> Added to TODO under features not wanted:
> 
> 	Incomplete itemObfuscated function source code (not
> wanted)
> 	
> 	    Obfuscating function source code has minimal
> protective benefits
> 	because anyone with super-user access can find a way to
> view the code.
> 	To prevent non-super-users from viewing function source
> code, remove
> 	SELECT permission on pg_proc. 



      



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-24 15:05  David Fetter <david@fetter.org>
  parent: Glyn Astill <glynastill@yahoo.co.uk>
  0 siblings, 4 replies; 31+ messages in thread

From: David Fetter @ 2008-09-24 15:05 UTC (permalink / raw)
  To: Glyn Astill <glynastill@yahoo.co.uk>; +Cc: Merlin Moncure <mmoncure@gmail.com>; Bruce Momjian <bruce@momjian.us>; Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

On Wed, Sep 24, 2008 at 02:12:19PM +0000, Glyn Astill wrote:
> I'm not sure what the policy is on putting stuff in the docs, but
> how about putting that in the relevant place, as well as a note
> about the other option; using C and SPI.

C is not magic obfuscation gear.  Anybody with a debugger can expose
what it's doing.  There have been math papers showing that it's
impossible to hide the functionality of a piece of software based only
on the ability to run it, so the entire prospect of obscuring the
software's functionality when people can send arbitrary inputs to it
is one of those "known-impossible" problems like the halting problem.

Cheers,
David.
-- 
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-24 15:19  Bruce Momjian <bruce@momjian.us>
  parent: David Fetter <david@fetter.org>
  3 siblings, 0 replies; 31+ messages in thread

From: Bruce Momjian @ 2008-09-24 15:19 UTC (permalink / raw)
  To: David Fetter <david@fetter.org>; +Cc: Glyn Astill <glynastill@yahoo.co.uk>; Merlin Moncure <mmoncure@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

David Fetter wrote:
> On Wed, Sep 24, 2008 at 02:12:19PM +0000, Glyn Astill wrote:
> > I'm not sure what the policy is on putting stuff in the docs, but
> > how about putting that in the relevant place, as well as a note
> > about the other option; using C and SPI.
> 
> C is not magic obfuscation gear.  Anybody with a debugger can expose
> what it's doing.  There have been math papers showing that it's

I bet 'strings' shows all the SQL queries in a C object file too.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-24 15:44  Andrew Sullivan <ajs@commandprompt.com>
  parent: David Fetter <david@fetter.org>
  3 siblings, 2 replies; 31+ messages in thread

From: Andrew Sullivan @ 2008-09-24 15:44 UTC (permalink / raw)
  To: pgsql-general

On Wed, Sep 24, 2008 at 08:05:18AM -0700, David Fetter wrote:

> C is not magic obfuscation gear.  Anybody with a debugger can expose
> what it's doing. There have been math papers showing that it's
> impossible to hide the functionality of a piece of software based only
> on the ability to run it, so the entire prospect of obscuring the
> software's functionality when people can send arbitrary inputs to it
> is one of those "known-impossible" problems like the halting problem.

To be fair, one of the points that others are trying to make is not
"secure this function for real" but "secure this function enough to
make it a little costly."  Sure, someone with a debugger and probably
not much work could figure out what the function is.  If all you're
trying to do is make it expensive for dodgy software shops to re-use
your code, however, this is probably enough: the sort of person who
thinks re-using someone else's undocumented code is easier than
writing it from scratch is probably not going to go to the trouble of
really learning the code via debugging tools.  As a defence against
criminally lazy developers, "compliled C code" is probably good
enough.  (Of course, clever non-C code is probably also enough, in my
opinion, but obviously others disagree.)

A

-- 
Andrew Sullivan
ajs@commandprompt.com
+1 503 667 4564 x104
http://www.commandprompt.com/



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-24 19:30  Glyn Astill <glynastill@yahoo.co.uk>
  parent: David Fetter <david@fetter.org>
  3 siblings, 0 replies; 31+ messages in thread

From: Glyn Astill @ 2008-09-24 19:30 UTC (permalink / raw)
  To: David Fetter <david@fetter.org>; +Cc: Merlin Moncure <mmoncure@gmail.com>; Bruce Momjian <bruce@momjian.us>; Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

> C is not magic obfuscation gear.  Anybody with a debugger
> can expose
> what it's doing.  There have been math papers showing
> that it's
> impossible to hide the functionality of a piece of software
> based only
> on the ability to run it, so the entire prospect of
> obscuring the
> software's functionality when people can send arbitrary
> inputs to it
> is one of those "known-impossible" problems like
> the halting problem.

And the first word in the title is "obfuscated", not encrypted, secured or anything else...


      



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-24 20:08  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Andrew Sullivan <ajs@commandprompt.com>
  1 sibling, 0 replies; 31+ messages in thread

From: Tom Lane @ 2008-09-24 20:08 UTC (permalink / raw)
  To: Andrew Sullivan <ajs@commandprompt.com>; +Cc: pgsql-general

Andrew Sullivan <ajs@commandprompt.com> writes:
> On Wed, Sep 24, 2008 at 08:05:18AM -0700, David Fetter wrote:
>> C is not magic obfuscation gear. ...

> To be fair, one of the points that others are trying to make is not
> "secure this function for real" but "secure this function enough to
> make it a little costly."

Agreed, but there seems no particular need to have such a feature in
core Postgres.  An add-on PL could accomplish that task just as well;
perhaps more so, if you don't make the add-on available to all and
sundry.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 01:12  Scott Ribe <scott_ribe@killerbytes.com>
  parent: Andrew Sullivan <ajs@commandprompt.com>
  1 sibling, 1 reply; 31+ messages in thread

From: Scott Ribe @ 2008-09-25 01:12 UTC (permalink / raw)
  To: Andrew Sullivan <ajs@commandprompt.com>; pgsql-general

> the sort of person who
> thinks re-using someone else's undocumented code is easier than
> writing it from scratch is probably not going to go to the trouble of
> really learning the code via debugging tools.

Fixed that for you:

the sort of person who
thinks re-using someone else's undocumented code is easier than
writing it from scratch is probably not going to be able to learn the code
via debugging tools.


-- 
Scott Ribe
scott_ribe@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice





^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 20:05  Casey Allen Shobe <cshobe@bepress.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 2 replies; 31+ messages in thread

From: Casey Allen Shobe @ 2008-09-25 20:05 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Bill Moran <wmoran@collaborativefusion.com>; David Fetter <david@fetter.org>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

On Sep 15, 2008, at 7:19 PM, Tom Lane wrote:
> The problem is that the people who ask for this type of feature are  
> usually
> imagining that they can put their code on customer-controlled machines
> and it will be safe from the customer's eyes.

That's a broken expectation.  All that can realistically be expected  
is database/catalog-level constraints.

> Well, it isn't, and I don't think Postgres should encourage them to  
> think it is.

Adding such a feature would NOT be encouraging them to think this -  
the documentation could be very explicit about this fact.  Maybe  
that's what Oracle is selling, and that's crappy of them, but that  
doesn't mean we should use that as justification to not add a more  
appropriate implementation.

As for the expectation above - could pl/pgsql be made compilable?  It  
would seem easy to translate pl/pgsql code into C and compile a C  
function.  That *could* go onto customer-controlled machines and be  
safe from the customer's eyes.


FWIW, I think most people who want to hide code aren't concerned about  
IP, they're concerned about clients seeing embarrassingly bad/sloppy  
code.  But there *are* some very real and legitimate needs for this,  
though it's a small minority of those who think they do.


Cheers,
-- 
Casey Allen Shobe
Database Architect, The Berkeley Electronic Press



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 20:14  David Fetter <david@fetter.org>
  parent: Casey Allen Shobe <cshobe@bepress.com>
  1 sibling, 1 reply; 31+ messages in thread

From: David Fetter @ 2008-09-25 20:14 UTC (permalink / raw)
  To: Casey Allen Shobe <cshobe@bepress.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

On Thu, Sep 25, 2008 at 01:05:26PM -0700, Casey Allen Shobe wrote:
> On Sep 15, 2008, at 7:19 PM, Tom Lane wrote:
>> The problem is that the people who ask for this type of feature are
>> usually imagining that they can put their code on
>> customer-controlled machines and it will be safe from the
>> customer's eyes.
>
> That's a broken expectation.  All that can realistically be expected
> is database/catalog-level constraints.

It's far from clear that those offer protection of any reasonable kind.

>> Well, it isn't, and I don't think Postgres should encourage them to  
>> think it is.
>
> Adding such a feature would NOT be encouraging them to think this - the 
> documentation could be very explicit about this fact.  Maybe that's what 
> Oracle is selling, and that's crappy of them, but that doesn't mean we 
> should use that as justification to not add a more appropriate 
> implementation.

You've got the burden of proof exactly backwards there.  It's on you
or anyone who cares to to explain why it might be a good idea to add
this "feature," understanding that every feature has a maintenance
cost and is a potential source of bugs.

> As for the expectation above - could pl/pgsql be made compilable?
> It  would seem easy to translate pl/pgsql code into C and compile a
> C  function.  That *could* go onto customer-controlled machines and
> be safe from the customer's eyes.

No, it would not.  As many others have mentioned, "strings" does a
pretty good job on such stuff, let alone the impossibility even in
theory of hiding what a program does from someone with access to run
it using arbitrary inputs, even when they have no binary to examine.

> FWIW, I think most people who want to hide code aren't concerned about  
> IP, they're concerned about clients seeing embarrassingly bad/sloppy  
> code.  But there *are* some very real and legitimate needs for this,  
> though it's a small minority of those who think they do.

Please elucidate those needs in detail, then explain why it might be
PostgreSQL's job to meet them.

Cheers,
David.
-- 
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 20:16  Christophe <xof@thebuild.com>
  parent: Casey Allen Shobe <cshobe@bepress.com>
  1 sibling, 2 replies; 31+ messages in thread

From: Christophe @ 2008-09-25 20:16 UTC (permalink / raw)
  To: pgsql-general


On Sep 25, 2008, at 1:05 PM, Casey Allen Shobe wrote:
> As for the expectation above - could pl/pgsql be made compilable?

Without getting into the argument as to the level of security  
provided, it strikes me that a reasonable approach would be a non- 
core pluggable language which accepts encrypted strings as functions,  
decrypts them (using a key compiled into the language module), and  
passes them on to PL/pgSQL for execution.  This would keep the  
functionality out of core, allow the developer who distributes the  
code to plop in their own key and distribute the code as a compiled  
module, and minimizes reimplementation.

This would, of course, be easily hacked with someone who can step  
through the language module with a debugger, but I don't see any  
reasonable way of preventing someone with that level of access from  
breaking the code without OS-level support.



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 20:25  Casey Allen Shobe <cshobe@bepress.com>
  parent: Jonathan Bond-Caron <jbondc@openmv.com>
  1 sibling, 1 reply; 31+ messages in thread

From: Casey Allen Shobe @ 2008-09-25 20:25 UTC (permalink / raw)
  To: Jonathan Bond-Caron <jbondc@openmv.com>; +Cc: 'Bill Moran' <wmoran@collaborativefusion.com>; 'Tom Lane' <tgl@sss.pgh.pa.us>; 'David Fetter' <david@fetter.org>; 'Greg Smith' <gsmith@gregsmith.com>; pgsql-general

On Sep 16, 2008, at 6:39 AM, Jonathan Bond-Caron wrote:
> After some research, I found this article that I believe will make a
> stronger use case:
> http://www.iosn.net/network/news/Managing%20the%20insider%20threat%20through
> %20code%20obfuscation

I can tell without even clicking the link that it would be a waste of  
time to read.

The only way to manage internal threats are to have a good security  
policy that limits what each person can do to what they need to do,  
and having backups.

If I work as a developer or DBA and cannot immediately go looking at  
code when there's a problem, it's very detrimental to productivity.   
Gee, I wonder why companies that support these antics grow to insane  
sizes of employees?  Having access to a copy of the code should not be  
a security threat in any way.  If it is, then the underlying  
infrastructure/security policy is broken.  Not having visibility into  
what unrelated code does leads to crappy, bloated code.  For instance,  
I was updating the SQL in a class method the other day.  Technically,  
I don't require any visibility into the calling code, and the above  
page probably advocates that it would be hidden from me.  But I noted  
that the database results were coming back in an ordered fashion, and  
being returned as an unordered hash.  I did some grepping through the  
rest of the codebase, and found that the callers then did their own  
sort in perl to reproduce the lost database sorting.  So I was able to  
easily fix more than required and improve overall efficiency.  With a  
code obfuscation approach, this would be impossible and the current  
code would be more bloated and slow.

My previous employer has some ~100 PostgreSQL servers serving up one  
of the most popular websites in the world.  The only thing standing  
between me and complete destruction of all that data is a wifi  
password (WEP even, because that's more convenient than requiring  
folks to have WPA2 support) because convenience is the first priority  
and any security architects are lazy or nonexistent (in the latter  
case, the responsibility lands on sysadmins, which does not work out  
well in most cases).  In than environment, they give postgres user  
trust access to anyone on the production network, and then make the  
office a part of the production network via a permanent VPN link (it's  
a VPN, so it must be secure, right?) to enable the developers to work  
easier (like many places, they don't have a completely isolated dev  
environment).

I've seen a lot of PostgreSQL environments in the last few years, and  
every single one of them connects to the database as the "postgres"  
user or another superuser, requires ability to execute DDL, and all  
sorts of other gaping security issues, and I cannot think of the last  
time I heard somebody else in a work setting speak of a GRANT that was  
not a GRANT ALL, even when all that is needed is select access, for  
example.

Companies need to fix their security architecture and keep production  
isolated from development, not go down the obfuscation rathole.  If  
they do that and still have a threat that they think code obfuscation  
would help manage, I'd love to see it.

Cheers,
-- 
Casey Allen Shobe
Database Architect, The Berkeley Electronic Press



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 20:38  Casey Allen Shobe <cshobe@bepress.com>
  parent: David Fetter <david@fetter.org>
  3 siblings, 0 replies; 31+ messages in thread

From: Casey Allen Shobe @ 2008-09-25 20:38 UTC (permalink / raw)
  To: David Fetter <david@fetter.org>; +Cc: Glyn Astill <glynastill@yahoo.co.uk>; Merlin Moncure <mmoncure@gmail.com>; Bruce Momjian <bruce@momjian.us>; Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

On Sep 24, 2008, at 8:05 AM, David Fetter wrote:
> C is not magic obfuscation gear.  Anybody with a debugger can expose
> what it's doing.

Yes, but you don't get original code, comments, etc. and it takes a  
lot of effort to refine it back down into something maintainable.   
People looking to protect IP are often not looking to prevent the same  
functionality from being executed elsewhere, but to prevent somebody  
from taking the results of their hard work with minimal effort (think  
of Microsoft and the FreeBSD TCP/IP stack).  If it costs the  
competition a lot of time to decompile code and then rebuild  
maintainable code out of it that probably doesn't take all the same  
things into consideration and will lead to difficulties keeping up  
with new features, that's adequate protection.

Of course, there are idiots out there who think that not making pl/ 
pgsql code visible should protect even against root-level access and  
that compilation equals irreversible encryption, but not everyone  
using these techniques is one of those idiots, and a few do have  
pretty good reasons.  Consider for example chipmakers, who compete  
against each other selling to a very small number of clients.  A board  
maker will buy whatever does the job well at lowest cost, and the cost  
associated with creating these is purely development time.  If you put  
months into making a really fast/efficient chip to do a specific task,  
protecting this is very important, or you go out of business.  This is  
much the opposite of a business that provides a service.

Cheers,
-- 
Casey Allen Shobe
Database Architect, The Berkeley Electronic Press



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 20:45  Casey Allen Shobe <cshobe@bepress.com>
  parent: Scott Ribe <scott_ribe@killerbytes.com>
  0 siblings, 0 replies; 31+ messages in thread

From: Casey Allen Shobe @ 2008-09-25 20:45 UTC (permalink / raw)
  To: Scott Ribe <scott_ribe@killerbytes.com>; +Cc: Andrew Sullivan <ajs@commandprompt.com>; pgsql-general

On Sep 24, 2008, at 6:12 PM, Scott Ribe wrote:
> the sort of person who
> thinks re-using someone else's undocumented code is easier than
> writing it from scratch is probably not going to be able to learn  
> the code
> via debugging tools.

There are two distinct extremes here, and I think most people on the  
list are more familiar with the former.

The first is where you build a big system/application, and any code  
you do go out and get from the OSS community or by stealing or  
whatever just does some small function within your overall  
architecture.  Maintainability of any acquired code is important here.

The second is where you release a product that is never updated, and  
designed for a specific purpose.  If somebody else can produce an  
equivalent product without the associated development time, even  
without any understanding, through use of theft, it can bring down the  
original business.  Maintainability does NOT matter here because the  
dodgy competitor only cares to produce something functionally  
equivalent, not to have something maintainable.

Realistically, it's a pretty stupid long-term decision to use acquired  
code and screw over the original business, because then once you've  
killed the competitor or lost the ability to steal more, you no longer  
have the ability to keep up with customer demand, but many businesses  
don't care about the long-term so much as a quick buck, unfortunately.

Cheers,
-- 
Casey Allen Shobe
Database Architect, The Berkeley Electronic Press



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 21:03  Casey Allen Shobe <cshobe@bepress.com>
  parent: David Fetter <david@fetter.org>
  0 siblings, 0 replies; 31+ messages in thread

From: Casey Allen Shobe @ 2008-09-25 21:03 UTC (permalink / raw)
  To: David Fetter <david@fetter.org>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Bill Moran <wmoran@collaborativefusion.com>; Greg Smith <gsmith@gregsmith.com>; Jonathan Bond-Caron <jbondc@openmv.com>; pgsql-general

On Sep 25, 2008, at 1:14 PM, David Fetter wrote:
> On Thu, Sep 25, 2008 at 01:05:26PM -0700, Casey Allen Shobe wrote:
>> On Sep 15, 2008, at 7:19 PM, Tom Lane wrote:
>>> The problem is that the people who ask for this type of feature are
>>> usually imagining that they can put their code on
>>> customer-controlled machines and it will be safe from the
>>> customer's eyes.
>>
>> That's a broken expectation.  All that can realistically be expected
>> is database/catalog-level constraints.
>
> It's far from clear that those offer protection of any reasonable  
> kind.

Define "protection".  If there is no effective way to query the  
catalog and see function code at the SQL level, this is a complete and  
effective form of protection - it's just not protection from somebody  
with server-level access.

> You've got the burden of proof exactly backwards there.  It's on you
> or anyone who cares to to explain why it might be a good idea to add
> this "feature," understanding that every feature has a maintenance
> cost and is a potential source of bugs.

I don't personally want this feature.  But I can see where it's  
valuable in some contexts, and if the understanding is correct, it can  
be used responsibly.  People misuse basic SQL all the time, but that  
doesn't mean the basic SQL should be nonexistent or stupider.

You do have a very valid point in indicating the added maintenance  
cost of any new feature, but protecting stuff at the SQL level is not  
a complicated thing to do, and well, people concerned with this  
feature can be the ones maintaining it - there seems to be a good many  
already and existence of the feature would attract more.  Could this  
be implemented via a contrib/ module?

>> As for the expectation above - could pl/pgsql be made compilable?
>> It  would seem easy to translate pl/pgsql code into C and compile a
>> C  function.  That *could* go onto customer-controlled machines and
>> be safe from the customer's eyes.
>
> No, it would not.  As many others have mentioned, "strings" does a
> pretty good job on such stuff, let alone the impossibility even in
> theory of hiding what a program does from someone with access to run
> it using arbitrary inputs, even when they have no binary to examine.

I am not saying that C is an encryption technique.  It does however  
protect code from customer eyes.  People are often not trying to truly  
encrypt a protected algorithm, but removing maintainability, adding  
cost to theft, and hiding code that's badly done.

>> FWIW, I think most people who want to hide code aren't concerned  
>> about
>> IP, they're concerned about clients seeing embarrassingly bad/sloppy
>> code.  But there *are* some very real and legitimate needs for this,
>> though it's a small minority of those who think they do.
>
> Please elucidate those needs in detail, then explain why it might be
> PostgreSQL's job to meet them.

See my other posts talking about chipmakers.  We should NOT add this  
feature /for/ idiots, but the fact that idiots will inevitably end up  
misusing any feature should not be a justification for not  
implementing it.

Cheers,
-- 
Casey Allen Shobe
Database Architect, The Berkeley Electronic Press
cshobe@bepress.com (email/jabber/aim/msn)
http://www.bepress.com | +1 (510) 665-1200 x163




^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 21:14  Andrew Sullivan <ajs@commandprompt.com>
  parent: Casey Allen Shobe <cshobe@bepress.com>
  0 siblings, 0 replies; 31+ messages in thread

From: Andrew Sullivan @ 2008-09-25 21:14 UTC (permalink / raw)
  To: pgsql-general

On Thu, Sep 25, 2008 at 01:25:25PM -0700, Casey Allen Shobe wrote:

> Gee, I wonder why companies that support these antics grow to insane
> sizes of employees?

Meetings.  Lots and lots of meetings.

A

-- 
Andrew Sullivan
ajs@commandprompt.com
+1 503 667 4564 x104
http://www.commandprompt.com/



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 22:08  Greg Smith <gsmith@gregsmith.com>
  parent: Christophe <xof@thebuild.com>
  1 sibling, 0 replies; 31+ messages in thread

From: Greg Smith @ 2008-09-25 22:08 UTC (permalink / raw)
  To: Christophe <xof@thebuild.com>; +Cc: pgsql-general

On Thu, 25 Sep 2008, Christophe wrote:

> it strikes me that a reasonable approach would be a non-core pluggable 
> language which accepts encrypted strings as functions, decrypts them 
> (using a key compiled into the language module), and passes them on to 
> PL/pgSQL for execution...This would, of course, be easily hacked with 
> someone who can step through the language module with a debugger

If we presume that the module doing the encryption/decryption is itself is 
a common open-source implementation, all I have to do is read in the 
de-obfuscator code byte at a time, stopping every time I have a key length 
worth of bytes to see if they unlock something that looks like plaintext. 
You have to move to at least another layer of relatively serious security 
before you need debugger-level skills to crack it.

People routinely tear through protection like this even on closed-source 
systems that benefit some from security by obscurity, and if you can know 
the method used that usually allows an even easier approach.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-25 23:38  Casey Allen Shobe <cshobe@bepress.com>
  parent: Christophe <xof@thebuild.com>
  1 sibling, 1 reply; 31+ messages in thread

From: Casey Allen Shobe @ 2008-09-25 23:38 UTC (permalink / raw)
  To: Christophe <xof@thebuild.com>; +Cc: pgsql-general

On Sep 25, 2008, at 1:16 PM, Christophe wrote:
> Without getting into the argument as to the level of security  
> provided, it strikes me that a reasonable approach would be a non- 
> core pluggable language which accepts encrypted strings as  
> functions, decrypts them (using a key compiled into the language  
> module), and passes them on to PL/pgSQL for execution.

The only way this could work is if the key is set at compile time.   
Using a single key is impossible in an open source product as Greg  
pointed out, and very stupid in any other.  Now I'll ignore the fact  
that you can reverse engineer the key out of compiled code, as you  
already acknowledged that - this is still problematic for another  
reason.

Let's consider the original goal of "I want to keep customers, with  
full control of the server machine, from being able to see clearly  
what a function does".  In cases where you just want to keep database  
users from seeing a function code, the implementation should be easy,  
and that's the only form I see any value in adding, really.

You could add encryption properly by storing the key in an external  
file with very restrictive permissions, and that would solve the goal  
of "I don't want people to be able to read function code in pg_dump  
output", etc., so it takes things a step farther.  But of course on  
customer-controlled boxes, they can read any file they want, defeating  
the encryption.

So you think "ah I'll just compile it in by requiring ./configure -- 
key=whatever to compile the thing.  Well, now you suddenly have to  
build every release of PostgreSQL for every single one of those  
customers - they cannot upgrade or rebuild themselves, without losing  
all the encrypted functions.  Maybe that's something you can accept,  
but I would say that most people who want to hide code from customers  
want nothing to do with setting up the database for the customer.  In  
cases where you fully dictate the PostgreSQL build and upgrade policy  
and mandate it for your clients, this could work, but I'm guessing  
that's a pretty esoteric corner case.

Cheers,
-- 
Casey Allen Shobe
Database Architect, The Berkeley Electronic Press



^ permalink  raw  reply  [nested|flat] 31+ messages in thread

* Re: Obfuscated stored procedures (was Re: Oracle and Postgresql)
@ 2008-09-26 01:49  Martin Gainty <mgainty@hotmail.com>
  parent: Casey Allen Shobe <cshobe@bepress.com>
  0 siblings, 0 replies; 31+ messages in thread

From: Martin Gainty @ 2008-09-26 01:49 UTC (permalink / raw)
  To: Casey Allen Shobe <cshobe@bepress.com>; Christophe <xof@thebuild.com>; +Cc: pgsql-general


i would recommend
dont publish in HTML/JS as with a simple View Page Source any browser client can figure out what is doing what
also i would shy from Scripting macro languages as they are not compiled modules and anyone with a text editor can easily see your code
Functions and procedure are another story as one would need DB access to view..so someone who is doing 
a simple query with Toad or sqlplus suddenly sees this interesting procedure hmm..

can the more proprietary routines be placed in a compiled language like Java and then use PL/Java packaging to pull in the packages you need?
?
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 


> CC: pgsql-general@postgresql.org
> From: cshobe@bepress.com
> To: xof@thebuild.com
> Subject: Re: Obfuscated stored procedures (was Re: [GENERAL] Oracle and Postgresql) 
> Date: Thu, 25 Sep 2008 16:38:18 -0700
> 
> On Sep 25, 2008, at 1:16 PM, Christophe wrote:
> > Without getting into the argument as to the level of security  
> > provided, it strikes me that a reasonable approach would be a non- 
> > core pluggable language which accepts encrypted strings as  
> > functions, decrypts them (using a key compiled into the language  
> > module), and passes them on to PL/pgSQL for execution.
> 
> The only way this could work is if the key is set at compile time.   
> Using a single key is impossible in an open source product as Greg  
> pointed out, and very stupid in any other.  Now I'll ignore the fact  
> that you can reverse engineer the key out of compiled code, as you  
> already acknowledged that - this is still problematic for another  
> reason.
> 
> Let's consider the original goal of "I want to keep customers, with  
> full control of the server machine, from being able to see clearly  
> what a function does".  In cases where you just want to keep database  
> users from seeing a function code, the implementation should be easy,  
> and that's the only form I see any value in adding, really.
> 
> You could add encryption properly by storing the key in an external  
> file with very restrictive permissions, and that would solve the goal  
> of "I don't want people to be able to read function code in pg_dump  
> output", etc., so it takes things a step farther.  But of course on  
> customer-controlled boxes, they can read any file they want, defeating  
> the encryption.
> 
> So you think "ah I'll just compile it in by requiring ./configure -- 
> key=whatever to compile the thing.  Well, now you suddenly have to  
> build every release of PostgreSQL for every single one of those  
> customers - they cannot upgrade or rebuild themselves, without losing  
> all the encrypted functions.  Maybe that's something you can accept,  
> but I would say that most people who want to hide code from customers  
> want nothing to do with setting up the database for the customer.  In  
> cases where you fully dictate the PostgreSQL build and upgrade policy  
> and mandate it for your clients, this could work, but I'm guessing  
> that's a pretty esoteric corner case.
> 
> Cheers,
> -- 
> Casey Allen Shobe
> Database Architect, The Berkeley Electronic Press
> 
> -- 
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

_________________________________________________________________
Want to do more with Windows Live? Learn “10 hidden secrets” from Jamie.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entr...

^ permalink  raw  reply  [nested|flat] 31+ messages in thread


end of thread, other threads:[~2008-09-26 01:49 UTC | newest]

Thread overview: 31+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-09-16 00:29 Obfuscated stored procedures (was Re: Oracle and Postgresql) Bill Moran <wmoran@collaborativefusion.com>
2008-09-16 00:50 ` David Fetter <david@fetter.org>
2008-09-16 01:17   ` Re: Obfuscated stored procedures (was Re: Oracle andPostgresql) Gregory Williamson <Gregory.Williamson@digitalglobe.com>
2008-09-16 02:11   ` Bill Moran <wmoran@collaborativefusion.com>
2008-09-16 02:19     ` Tom Lane <tgl@sss.pgh.pa.us>
2008-09-16 12:40       ` Bill Moran <wmoran@collaborativefusion.com>
2008-09-16 13:15         ` Glyn Astill <glynastill@yahoo.co.uk>
2008-09-16 13:31           ` Merlin Moncure <mmoncure@gmail.com>
2008-09-16 13:38             ` Gregory Williamson <Gregory.Williamson@digitalglobe.com>
2008-09-16 13:55             ` Glyn Astill <glynastill@yahoo.co.uk>
2008-09-23 19:52             ` Bruce Momjian <bruce@momjian.us>
2008-09-24 14:12               ` Glyn Astill <glynastill@yahoo.co.uk>
2008-09-24 15:05                 ` David Fetter <david@fetter.org>
2008-09-24 15:19                   ` Bruce Momjian <bruce@momjian.us>
2008-09-24 15:44                   ` Andrew Sullivan <ajs@commandprompt.com>
2008-09-24 20:08                     ` Tom Lane <tgl@sss.pgh.pa.us>
2008-09-25 01:12                     ` Scott Ribe <scott_ribe@killerbytes.com>
2008-09-25 20:45                       ` Casey Allen Shobe <cshobe@bepress.com>
2008-09-24 19:30                   ` Glyn Astill <glynastill@yahoo.co.uk>
2008-09-25 20:38                   ` Casey Allen Shobe <cshobe@bepress.com>
2008-09-16 13:39         ` Jonathan Bond-Caron <jbondc@openmv.com>
2008-09-16 14:31           ` Andrew Sullivan <ajs@commandprompt.com>
2008-09-25 20:25           ` Casey Allen Shobe <cshobe@bepress.com>
2008-09-25 21:14             ` Andrew Sullivan <ajs@commandprompt.com>
2008-09-25 20:05       ` Casey Allen Shobe <cshobe@bepress.com>
2008-09-25 20:14         ` David Fetter <david@fetter.org>
2008-09-25 21:03           ` Casey Allen Shobe <cshobe@bepress.com>
2008-09-25 20:16         ` Christophe <xof@thebuild.com>
2008-09-25 22:08           ` Greg Smith <gsmith@gregsmith.com>
2008-09-25 23:38           ` Casey Allen Shobe <cshobe@bepress.com>
2008-09-26 01:49             ` Martin Gainty <mgainty@hotmail.com>

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