Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jHUKV-0007fI-B4 for pgsql-docs@arkaria.postgresql.org; Thu, 26 Mar 2020 15:21:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jHUKU-0006wS-5J for pgsql-docs@arkaria.postgresql.org; Thu, 26 Mar 2020 15:21:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jHUKT-0006wK-Qn for pgsql-docs@lists.postgresql.org; Thu, 26 Mar 2020 15:21:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jHUKQ-0003b6-6R for pgsql-docs@lists.postgresql.org; Thu, 26 Mar 2020 15:21:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 02QFLqvK014012; Thu, 26 Mar 2020 11:21:52 -0400 From: Tom Lane To: Brett Okken cc: pgsql-docs@lists.postgresql.org, Dave Cramer Subject: Re: char 0x00 In-reply-to: References: <11841.1585232526@sss.pgh.pa.us> Comments: In-reply-to Brett Okken message dated "Thu, 26 Mar 2020 09:28:54 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14010.1585236112.1@sss.pgh.pa.us> Date: Thu, 26 Mar 2020 11:21:52 -0400 Message-ID: <14011.1585236112@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Brett Okken writes: > Using a client and server encoding of SQL_ASCII makes it possible to get > 0x00 into a text value column when using a bind variable. Having looked at the code again, I flat out don't believe you. textin is certainly not going to read past a nul character, and textrecv goes through pg_client_to_server (via pq_getmsgtext), which AFAICS is careful in all code paths to reject nuls. If I'm missing something, I'd really like to see a concrete example, because this would be a bug, and it'd suggest that somebody's managed to reopen CVE-2006-2313. If we're missing nul rejection in some code path, then we're probably not doing encoding validation at all. regards, tom lane