Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

[PATCH] Re: Why READ ONLY transactions?: msg#00307

db.postgresql.advocacy

Subject: [PATCH] Re: Why READ ONLY transactions?

> >>>> - Read only transactions, bringing a greater level of
> >>>> security to web and enterprise applications by protecting
> >>>> data from modification.
>
> >> This should be removed. Even though I added it to the press
> >> release, I've just realised it's not really a security measure
> >> against SQL injection since injected code can just specify 'SET
> >> TRANSACTION READ WRITE'. We should still mention it, but not as a
> >> security measure.
>
> > Aside from spec compliance, whats the bonus for having it then? Or
> > put a better way, why/when would I want to use this?
>
> If I am writing a "report program" that isn't supposed to do any
> updates to anything, then I would be quite happy to set things to
> READ-ONLY as it means that I won't _accidentally_ do updates.
>
> It's like adding a pair of suspenders to your wardrobe. You can
> _always_, if you really try, get your pants to fall down, but this
> provides some protection.
>
> I would NOT call it a "security" provision, as it is fairly easily
> defeated using SET TRANSACTION.

Um, why not make it an actual full blown security feature by applying
the following patch? This gives PostgreSQL real read only
transactions that users can't escape from. Notes about the patch:

*) If the GUC transaction_force_read_only is set to FALSE, nothing
changes in PostgreSQL's behavior. The default is FALSE, letting
users change from READ ONLY to READ WRITE at will.

*) If transaction_force_read_only is TRUE, this sandboxes the
connection for the remainder of the connection if the session is
set to read only. The following bits apply:

a) if you're a super user, you can change transaction_read_only.

b) if you're not a super user, you can change transaction_read_only
to true.

c) if you're not a super user, you can always change
transaction_read_only from false to true. If
transaction_force_read_only is true, you can't change
transaction_read_only from true to false.

d) If transaction_force_read_only is TRUE, but
transaction_read_only is FALSE, the transaction is still READ
WRITE.

e) Only super users can change transaction_force_read_only.


Basically, if you want to permanently prevent a user from ever being
able to get in a non-read only transaction, do:

\c [dbname] [db_superuser]
BEGIN;
ALTER USER test SET default_transaction_read_only TO TRUE;
ALTER USER test SET transaction_force_read_only TO TRUE;
COMMIT;

-- To test:
regression=# \c regression test
regression=> SHOW transaction_read_only;
transaction_read_only
-----------------------
on
(1 row)

regression=> SHOW transaction_force_read_only;
transaction_force_read_only
-----------------------------
on
(1 row)

regression=> SET transaction_read_only TO FALSE;
ERROR: Insufficient privileges to SET transaction_read_only TO FALSE


It's also possible to set transaction_force_read_only in
postgresql.conf making it possible to create read only databases to
non-superusers by starting postgresql with
default_transaction_read_only and transaction_force_read_only set to
TRUE. If this patch is well received, I'll quickly bang out some
documentation for this new GUC. From a security stand point, this is
a nifty feature. -sc

--
Sean Chittenden

Attachment: patch
Description: Text document

Attachment: pgpvtKkDqWtOI.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qplus.devel/200...    network.jabber....    debian.qa-packa...    encryption.gpg....    python.dabo.dev...    uclinux.devel/2...    science.mathema...    recreation.pesc...    kernel.ck/2004-...    mozilla.devel.e...    tex.latex.prosp...    ietf.multi6/200...    bbc.cvs/2002-11...    xfree86.newbie/...    jakarta.taglibs...    altlinux.hardwa...    comedi/2002-05/...    horde.bugs/2004...    games.diplomacy...    finance.e-gold....    web.dom.test-su...    lang.ruby.rails...    os.netbsd.devel...    video.gstreamer...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation