Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 15619 invoked from network); 6 May 2010 12:21:11 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 May 2010 12:21:11 -0000 Received: (qmail 40679 invoked by uid 500); 6 May 2010 12:21:11 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 40622 invoked by uid 500); 6 May 2010 12:21:10 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 40614 invoked by uid 99); 6 May 2010 12:21:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 12:21:10 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bchesneau@gmail.com designates 74.125.83.180 as permitted sender) Received: from [74.125.83.180] (HELO mail-pv0-f180.google.com) (74.125.83.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 12:21:02 +0000 Received: by pvc22 with SMTP id 22so1791578pvc.11 for ; Thu, 06 May 2010 05:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=MIiv9O9AJOYtxCkJ5/G3MgIXTkTWRSpTLavAK6LbDbU=; b=HpeEcFwLQfKOyBwWoFsQkBaexYnOWI3ZOqBTk127B67DeGqgrfZv/9OmeRp5AArzbV rM6v7ZzIGiJHAbs1xRjXIMefn9CnBvpSupsRh44gStBw1mc31Gc5nvALjcZFmi/Cg9bo tC0zKu6y34D1DLDbbXYCxdAwNM19cNPpIFoVQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=ZTwND28dlUaydeTCvKi9RcnkU5piG+6m5PYixHpOhm8zMmldHeb3lHnyH8RYLza9lt gwzMKzkI5djVMwiQBCkPB/uOIulWiUbp6pLyapXUtAKf7v+wVdd2Lp9IPlDAVwIlX9gD XuX2w0OAVwSHQiILuzY2W/Ss9N+T3crAzdFyE= MIME-Version: 1.0 Received: by 10.140.252.6 with SMTP id z6mr6868518rvh.229.1273148441203; Thu, 06 May 2010 05:20:41 -0700 (PDT) Received: by 10.140.225.21 with HTTP; Thu, 6 May 2010 05:20:41 -0700 (PDT) In-Reply-To: References: Date: Thu, 6 May 2010 14:20:41 +0200 Message-ID: Subject: Re: rewrite security From: Benoit Chesneau To: dev@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Thu, May 6, 2010 at 12:35 AM, J Chris Anderson wrote: > Devs, > > Today I wrote a patch and backported to 0.11.x, concerning the security g= uarantees made by the rewriter. > > Previously we'd allowed the rewriter to include as many ".." segments in = the target path as the developer wanted. This is great for flexibility, and= allows you to create a vhost which doesn't provide the full couchdb api bu= t also can access more than one database. > > I've changed the default behavior so that you can only have a maximum of = 2 ".." segments in your rewrite paths, so eg you can rewrite from /db/_desi= gn/foo/_rewrite to /db/ or /db/somedoc or /db/_design/foo/_show/bar but you= CAN'T rewrite to /otherdb/anything > > This allows databases to be "jailed" inside vhosts, which is very importa= nt for security as we move forward. Prior to this patch, there was no way t= o run untrusted apps on the same CouchDB VM as each other. Now, using vhost= s and by putting apps/dbs on different domains, we can protect the applicat= ions from each other. > > My patch maintains the previous functionality (unlimited rewriting), but = it is configured to be off by default. By default secure_rewrites=3Dtrue. S= o if you are currently relying on cross-db rewrites, you'll need to edit yo= ur local.ini file to set secure_rewrites=3Dfalse > > There are some missing parts in my implementation. I plan to finish this = change by making a configurable whitelist of global_httpd handlers that *ca= n* be accessed within vhosts. The ones I can think of are: > > _utils > _uuids > _session > _oauth > _users > > And some installations might want to turn on others (_replicate, _stats, = etc), hence the list should be configurable. > > My plan is to implement this as a whitelist that is checked by the vhost = engine, so that these global handlers are available on all vhosts. This way= you can easily add a database that needs to be available to all your vhost= s using a single configuration directive. > > I think this plan is sane, but please let me know if you see issues that = I'm missing. > > Chris > > > Well vhost don't stop someone to access to the whole db currently if so remove the Host info or such. But I'm not sure this path worth it since we can limit security per database for readers & such. In fact, I would do in the other way, ie secure the resource that need to be secured: _replicate, _all_dbs, _users, ... . And maybe secure by default all resource to admin or a default group of user. Using this way would allow other users of couchdb (those who aren't using couchapps) to have a way to secure these accesses to between untrusted users. In your case, for hosting multiple non trusted couchapps, you would just have to set default permissions to a couchdb node and it would do the trick too. What do you think about it ? - benoit