pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Feike Steenbergen <feikesteenbergen@gmail.com>
To: andrew.wheelwright@familysearch.org
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14600: Passwords in user mappings leaked by psql \deu+ command
Date: Wed, 29 Mar 2017 19:53:50 +0200
Message-ID: <CAK_s-G0SeC7HOsO2s8QSPtNu3Dczmj4o7+E+1_BPWO3sDW2mdA@mail.gmail.com> (raw)
In-Reply-To: <CAK_s-G0gCFL_0NDwdHWBzbp81=4hrzDUoB=a0-BQJ-4m-z3pVA@mail.gmail.com>
References: <20170328053814.2690.5600@wrigleys.postgresql.org>
	<CAK_s-G0gCFL_0NDwdHWBzbp81=4hrzDUoB=a0-BQJ-4m-z3pVA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Attached a patch which copies the logic from commit
93a6be63a55a8cd0d73b3fa81eb6a46013a3a974.

In the current implementation we only consider privileges of the foreign
server
in determining whether or not to show the user mapping details. This patch
copies the same logic (and documentation) used in commit
93a6be63a55a8cd0d73b3fa81eb6a46013a3a974 to not always show the user mapping
options.

regards,

Feike

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

user_mappings_leak.patch (application/octet-stream, 1.7K) download diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index ac39c639ed..f75f69e86f 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -11042,8 +11042,12 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx <entry></entry> <entry> User mapping specific options, as <quote>keyword=value</> - strings, if the current user is the owner of the foreign - server, else null + strings. This column will show as null + unless the current user is the user being mapped, or the mapping + is for <literal>PUBLIC</literal> and the current user is the + server owner, or the current user is a superuser. The intent is + to protect password information stored as user mapping + option. </entry> </row> </tbody> diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index d357c8b8fd..43fe44fbe9 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -920,10 +920,11 @@ CREATE VIEW pg_user_mappings AS ELSE A.rolname END AS usename, - CASE WHEN pg_has_role(S.srvowner, 'USAGE') OR has_server_privilege(S.oid, 'USAGE') THEN - U.umoptions - ELSE - NULL + CASE + WHEN U.umuser <> 0::oid AND A.rolname = "current_user"() OR U.umuser = 0::oid AND pg_has_role(S.srvowner::name, 'USAGE'::text) OR ( SELECT pg_authid.rolsuper + FROM pg_authid + WHERE pg_authid.rolname = "current_user"()) THEN U.umoptions + ELSE NULL::text[] END AS umoptions FROM pg_user_mapping U JOIN pg_foreign_server S ON (U.umserver = S.oid)

view thread (4+ messages)  latest in thread

Message-ID: <CAK_s-G0SeC7HOsO2s8QSPtNu3Dczmj4o7+E+1_BPWO3sDW2mdA@mail.gmail.com>
Permalink:  ../CAK_s-G0SeC7HOsO2s8QSPtNu3Dczmj4o7+E+1_BPWO3sDW2mdA@mail.gmail.com/
Also on:    postgresql.org/message-id/CAK_s-G0SeC7HOsO2s8QSPtNu3Dczmj4o7+E+1_BPWO3sDW2mdA@mail.gmail.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: feikesteenbergen@gmail.com, andrew.wheelwright@familysearch.org
  Subject: Re: BUG #14600: Passwords in user mappings leaked by psql \deu+ command
  In-Reply-To: <CAK_s-G0SeC7HOsO2s8QSPtNu3Dczmj4o7+E+1_BPWO3sDW2mdA@mail.gmail.com>
  References: <20170328053814.2690.5600@wrigleys.postgresql.org> <CAK_s-G0gCFL_0NDwdHWBzbp81=4hrzDUoB=a0-BQJ-4m-z3pVA@mail.gmail.com> <CAK_s-G0SeC7HOsO2s8QSPtNu3Dczmj4o7+E+1_BPWO3sDW2mdA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox