Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id CB7CA1259185 for ; Fri, 27 Jan 2012 14:10:51 -0400 (AST) Received: from madness.at ([217.196.146.217] helo=cronos.madness.at) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RqqG7-00050b-Hb for pgsql-bugs@postgresql.org; Fri, 27 Jan 2012 18:10:51 +0000 Received: from gatekeeper.kaltenbrunner.cc ([83.215.243.9] helo=[192.168.8.22]) by cronos.madness.at with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1RqqFq-0000iK-IP; Fri, 27 Jan 2012 19:10:32 +0100 Message-ID: <4F22E88C.1050507@kaltenbrunner.cc> Date: Fri, 27 Jan 2012 19:10:20 +0100 From: Stefan Kaltenbrunner User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Marko Kreen CC: Magnus Hagander , Tom Lane , Postgres-Bugs Subject: Re: pgcrypto decrypt_iv() issue References: <4F1DB7BF.60304@kaltenbrunner.cc> <4F1F23E8.80100@kaltenbrunner.cc> <23889.1327646231@sss.pgh.pa.us> <20120127152056.GA4107@gmail.com> <4F22E028.8040708@kaltenbrunner.cc> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/199 X-Sequence-Number: 32266 On 01/27/2012 07:06 PM, Marko Kreen wrote: > On Fri, Jan 27, 2012 at 8:00 PM, Magnus Hagander wrote: >> On Fri, Jan 27, 2012 at 18:54, Marko Kreen wrote: >>> On Fri, Jan 27, 2012 at 7:34 PM, Stefan Kaltenbrunner >>> wrote: >>>> On 01/27/2012 04:20 PM, Marko Kreen wrote: >>>>> On Fri, Jan 27, 2012 at 01:37:11AM -0500, Tom Lane wrote: >>>>> Yeah, it should be fixed. But note that "random data" is part of >>>>> decrypt() spec - the validation it can do is a joke. >>>>> >>>>> Its more important to do proper checks in encrypt() to avoid invalid >>>>> stored data, but there the recommended modes (CBC, CFB) can work >>>>> with any length data, so even there the impact is low. >>>> >>>> I agree - but in my case the input to those functions is actually coming >>>> from external untrusted systems - so if the data is (completely) invalid >>>> really want to get a proper error message instead of random memory content. >>> >>> You *will* get random memory content. If your app is exploitable with >>> invalid data, you *will* get exploited. The decrypt() checks are >>> more for developer convenience than anything more serious. >> >> Hold on. I hope there's some misunderstanding here. >> >> I hope you are you saying that feeding random data to the decrypt >> functions should be expected to return random data out of previously >> free()d areas? Surely you're not? >> >> Obviouly, if you send in invalid data or an invalid key, it will >> decrypt into incorrect data, that goes without saying. But it should >> still be the same block size and not contain random unrelated memory >> blocks, shouldn' it? > > Yes, it should not contain unrelated data. hmm - see the last example I had in my original report - not sure i consider the path to pgcrypto.so "related" data and I most definitly do not expect to get that back from sending invalid data to the database... Stefan