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 1lPgzy-00077A-BM for pgsql-general@arkaria.postgresql.org; Fri, 26 Mar 2021 07:35:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lPgzw-0003js-AE for pgsql-general@arkaria.postgresql.org; Fri, 26 Mar 2021 07:35:12 +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 1lPgzw-0003iD-0V for pgsql-general@lists.postgresql.org; Fri, 26 Mar 2021 07:35:12 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lPgzo-0001UX-Mb for pgsql-general@lists.postgresql.org; Fri, 26 Mar 2021 07:35:11 +0000 Received: by mail-pj1-x1032.google.com with SMTP id s21so2168339pjq.1 for ; Fri, 26 Mar 2021 00:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:date:in-reply-to:message-id :mime-version; bh=mnIOHKjF0Jw5fgmfKUsLgxXOePxvaM0nb3lpMYLux3A=; b=AgrjoD7+2uy4lv1CBPoSNMCJlutzIFRCUbBjxk/40Tu1p/Hc25geadhTVvLJ3kEiem i0qZ4Bo8YPrJuvH0WvzpqQHPBBfiXKkRUmlAVt1h0GbhIUR2pvA5tOQxVYfMUQyz2Owg HuGGP3OpOEJFMiXthAAkILZHN1sCIl5z6YMLpLbpycg06AMfYKPivNE8Xp6m20OaPofH lu06dLA5LMbIRZ4AWPsArGhRHS3ezVZOQw5Ui96YAjZ9YSlGDxcKRMDHb/us6YiRSTcL xwJXstzuuBtzFifNwJK6jzAdoJss4hEqtJDUkDSaNZ1N+CX7mAvMkz0SaPnBTf1DpOC+ vylw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject:date :in-reply-to:message-id:mime-version; bh=mnIOHKjF0Jw5fgmfKUsLgxXOePxvaM0nb3lpMYLux3A=; b=LV+tU9J1bJVhjchXU3DfMheyYVZxUfpiDDcz/EYwS2TDx9zYmqBzxWWdkPefijrkuI MbDF1/UZFaMff2iX35vL97q+5QDHPyOG/2/JAbeXRw7lnhB0oU4EMn0PUdifzHIes/N7 VnsFEWT12n9MPwBENX44PFZXF0ipT2aOK/nzLkO4DPvp8oIk29Z3+YZWUGnBdMI90MFo 9mmKefGDOFdIdJafEAsm1bQvj+BnA687wVzi2rj1o+R6YDGDtxIPoxQOPnJdanzTh95m JVnEK1SK37KHnP4DIGpa78bQgrD2TeSXJXSlNBphoE1mocgvqVF2b1wkdkSCSfbh8O/v CLPQ== X-Gm-Message-State: AOAM531CZHUPHYGsPFvYw7b3ChA+Cpir4h/uz4n1QYTh+vtIFKetlDTU q9oEzfyumGFIGtKNZ2GnZX6wOMg0rb0= X-Google-Smtp-Source: ABdhPJxcNKxk6+hsl06jK0zYsxOJ02h2zjiI1rL7ACB129SMUwbY1JpCoSg8OWTA3LEIWHMsCLdorw== X-Received: by 2002:a17:90b:a01:: with SMTP id gg1mr12580239pjb.22.1616744102035; Fri, 26 Mar 2021 00:35:02 -0700 (PDT) Received: from tim-desktop (220-235-11-61.dyn.iinet.net.au. [220.235.11.61]) by smtp.gmail.com with ESMTPSA id p11sm7539490pjo.48.2021.03.26.00.34.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Mar 2021 00:35:01 -0700 (PDT) References: <2140b1e1f02a4c309e276837758db68c@huawei.com> User-agent: mu4e 1.5.11; emacs 27.2.50 From: Tim Cross To: pgsql-general@lists.postgresql.org Subject: Re: About CVE-2018-1058 Date: Fri, 26 Mar 2021 17:41:32 +1100 In-reply-to: <2140b1e1f02a4c309e276837758db68c@huawei.com> Message-ID: <87a6qq74gv.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Mahongwei (March, ICSL)" writes: > Hi > > > > From this blog: https://wiki.postgresql.org/wiki/A_Guide_to_CVE-2018-1058%3A_Protect_Your_Search_Path > > > > Do you think that this is just a mitigation, not a real fix, is there any plan to fix it? > I would argue that many possible vulnerabilities are 'mitigated' rather than 'fixed' and that the guidelines outlined in that blog post are effective mitigation of this vulnerability and therefore sufficient. Some would argue passwords are only a mitigation for unauthorised account access, not a fix. The CVE-2018-1058 vulnerability is really an example of a more general issue associated with environments which use some sort of search path to determine the location for executable code. Operating systems have a similar vulnerability with the PATH variable used to determine the search path for executable files. Basically, if someone can get a user to add a directory which they have write access to, they can create a trojan which could be exploited to compromise user security. It is for this reason that it is generally advised that on Linux systems, add a personal 'bin' or non-standard system directory to the end of your PATH variable rather than the beginning. For example, consider export PATH=~/bin:$PATH compared to export PATH= $PATH:~/bin and running the command sudo some_command to run "some_command" with increased privileges. If some 'bad actor' managed to compromise this user (a user who might have lower security controls than a "high risk" account or be on a host in a more 'permissive' security zone), they could drop a trojan into the user's bin directory. Under the first PATH example, the trojan sudo command will be executed when the user runs sudo, under the second PATH example, the system (and secure) sudo command will be found before the trojan and executed safely. Is the advice to add personal bin directories (or more generally, add additional 'non-system' directories at the end of the PATH) a mitigation of this risk? Yes. Is it sufficient protection? Yes. Does it need to be 'fixed'? Probably not and identifying ways that would prevent this issue are hard to find which don't either significantly limit the utility of a search path or add a level of inconvenience which would be difficult to justify. In many respects, the search_path variable is not really the issue. The issue is having a default 'public' schema which can be used by any user to add functions/procedures that could 'shadow' system functions or procedures or have a higher precedence in the search path than the function/procedure the user intends to run. In general, I will remove the 'public' schema from the default search_path. If user's want to access objects in that schema, they either have to explicitly specify the schema or they need to alter their search_path and add public. I also discourage users from using the public schema. Generally, I don't prevent users from being able to add public to their search path or from creating objects in the public schema (I assume if they go to the length of setting their search_path, they should know what they are doing). When risk assessments warrant it, I will remove the ability to create objects in public. Applications should put their database objects inside an application specific schema. Schemas are really just namespaces for databases and provide similar benefits to namespaces in programming languages. Failing to take advantage of this facility is like writing BASIC with lots of GOSUB and GOTOs - full of unexpected side effects, difficult to follow and hard to manage. -- Tim Cross