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 1kXQxA-0001tv-4u for pgsql-general@arkaria.postgresql.org; Tue, 27 Oct 2020 15:32:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kXQx8-00015Z-T6 for pgsql-general@arkaria.postgresql.org; Tue, 27 Oct 2020 15:32:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXQx7-00015S-V9 for pgsql-general@lists.postgresql.org; Tue, 27 Oct 2020 15:32:02 +0000 Received: from sonic314-20.consmr.mail.ne1.yahoo.com ([66.163.189.146]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kXQx3-0001sy-Pr for pgsql-general@postgresql.org; Tue, 27 Oct 2020 15:32:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048; t=1603812715; bh=lBsyzsoRlJ9j6S7Db1jGSU4KGbb5rHAVUhi3Lo9KN44=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=oPol5N5fw1nI2M8/975YJWz5UqhTG3D0z2wyYxa6pwGL4wJAxGL66ty2mULGjtSZa7gVaPJ4aLT6qHmJA7XzIayB0Gfwm0mjdp8hf0AEpmVzY4Om8iqAyWAomnxYXkc7JGN3zPU2d+CxXv5ImNPeGFl7Gkn9eogmkoyeMLq6Qjhte7hci8FAkLux1rqYbu4+OMXZZHYshNipzkE5NAiylqb9s7H1AZg9umoVPm87CoslIN6YTeInrZbNKY1OQTX98I4dNURr6tK0Tc440DRg6JT8VR5z7X/dDPs1Vi5jd/FU4WtA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.4_4aU1QWY7GOU2JYsfWjVyo NG1sKKyZ9Lt9JyMc0LXn8nskjg88JHaM1jg95VaVmXrRuJYhAG2mU3kI8koy6UWnzfxWc.m8F.YU ajLHs7zJNFs7RZh6fPSoQsTM41faKCMn.hCj6d9W6qIC5WQJxFqBQYl8aXfD33Fg5xQTYrZxA.0C sWezQQTLyi3YF8rrUoFqV.gREDuRxUucoCkNImX4L8K70eeI9SnrxLvlTseVaAblVaw7JXjDExZt .N3gFR7I8SCXrIwP59J.gK3huieDNYDLhdVIxo1PJlVaLC9Oi8X0KQJzi7aTiPAC46wGxJMlUCPi roeGsOyYmcL9.CKwBIR9o1HI4GFisM675LxcW7cu90Y2rbh7ba2yv7RAr6Y6IAaefOC5JAt3nkC0 faFUfYNRuWO_pDBWZDvO3.l26uWFG_VEVrtI60NTFOHvOmWsR0joj4PQ_srxpjvRjcDE5jy4EUS5 lqD8tc05ftBTQbKZQCvoGQFvroGTKTmLljW4xd2XZVOOMLThWj4NKG__WkA_tOngG Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ne1.yahoo.com with HTTP; Tue, 27 Oct 2020 15:31:55 +0000 Date: Tue, 27 Oct 2020 15:31:52 +0000 (UTC) From: Susan Joseph Reply-To: Susan Joseph To: "xiebin18@huawei.com" , "magnus@hagander.net" Cc: "pgsql-general@postgresql.org" , "zhubo31@huawei.com" , "zhuzheng@huawei.com" , "brian.hou@huawei.com" , "yangshaobo6@huawei.com" , "mapinghu@huawei.com" , "songyunpeng@huawei.com" , "luoqi25@huawei.com" Message-ID: <2146965017.250516.1603812712804@mail.yahoo.com> In-Reply-To: References: Subject: =?UTF-8?Q?Re:_=E7=AD=94=E5=A4=8D:_Security_issues_co?= =?UTF-8?Q?ncerning_pgsql_replication?= MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_250515_1450621331.1603812712799" X-Mailer: WebService/1.1.16944 aolwebmail Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0 Content-Length: 29005 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_250515_1450621331.1603812712799 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I know when I set it up with a password protecting the private key it woul= d prompt me for the password when I started up the service.=20 =20 Susan Joseph sandajoseph@verizon.net =20 =20 -----Original Message----- From: xiebin (F) To: Magnus Hagander Cc: pgsql-general@postgresql.org ; zhubo (C) = ; Zhuzheng (IT) ; houxiaowei ; yangshaobo (A) ; mapinghu ; Songyunpeng ; luoqi (F) Sent: Tue, Oct 27, 2020 7:34 am Subject: =E7=AD=94=E5=A4=8D: Security issues concerning pgsql replication #yiv6531606513 #yiv6531606513 -- _filtered {} _filtered {} _filtered {} _fi= ltered {} _filtered {} _filtered {} _filtered {}#yiv6531606513 #yiv65316065= 13 p.yiv6531606513MsoNormal, #yiv6531606513 li.yiv6531606513MsoNormal, #yiv= 6531606513 div.yiv6531606513MsoNormal {margin:0cm;margin-bottom:.0001pt;fon= t-size:12.0pt;font-family:=E5=AE=8B=E4=BD=93;}#yiv6531606513 a:link, #yiv65= 31606513 span.yiv6531606513MsoHyperlink {color:blue;text-decoration:underli= ne;}#yiv6531606513 a:visited, #yiv6531606513 span.yiv6531606513MsoHyperlink= Followed {color:purple;text-decoration:underline;}#yiv6531606513 p.yiv65316= 06513gmail-m4735437323743741455msolistparagraph, #yiv6531606513 li.yiv65316= 06513gmail-m4735437323743741455msolistparagraph, #yiv6531606513 div.yiv6531= 606513gmail-m4735437323743741455msolistparagraph {margin-right:0cm;margin-l= eft:0cm;font-size:12.0pt;font-family:=E5=AE=8B=E4=BD=93;}#yiv6531606513 spa= n.yiv6531606513EmailStyle18 {font-family:sans-serif;color:#1F497D;}#yiv6531= 606513 .yiv6531606513MsoChpDefault {font-family:sans-serif;} _filtered {}#y= iv6531606513 div.yiv6531606513WordSection1 {}#yiv6531606513 Perhaps you mis= understand me. It is not user-database, but master-slave interaction that I= am concerning. The master-slave replication proceeds continually and requi= res no manual interference. =C2=A0Both master and slave=E2=80=99s private k= ey are involved, but ssl_passphrase_command is only used to parse passphras= e of master=E2=80=99s private key. Pgsql cannot get slave=E2=80=99s private= key automatically, so replication failed. I=E2=80=99ve tried and proved it= did not work. =C2=A0 I refered to the list of pgsql=E2=80=99s authenticat= e methods but did not find an appropriate one for replication. https://www.= postgresql.org/docs/12/client-authentication.html =C2=A0 Xie Bin =C2=A0 = =E5=8F=91=E4=BB=B6=E4=BA=BA: Magnus Hagander [mailto:magnus@hagander.net] =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2020=E5=B9=B410=E6=9C=8827=E6=97=A5 1= 7:00 =E6=94=B6=E4=BB=B6=E4=BA=BA: xiebin (F) =E6=8A=84=E9=80=81: pgsql-general@postgresql.org; zhubo (C) ; Zhuzheng (IT) ; houxiaowei ; yangshaobo (A) ; mapinghu = ; Songyunpeng ; luoqi (F) =E4=B8=BB=E9=A2=98: Re: Security issues concerning pgsql replication =C2= =A0 =C2=A0 =C2=A0 On Tue, Oct 27, 2020 at 9:52 AM xiebin (F) wrote:=20 Hi, =C2=A0 I was setting up a master/slave pgsql(version 12.4) cluster usin= g stream replication. I found 3 ways to authenticate, but all of them has s= ome security issue. =C2=A0 1.=C2=A0Disable authentication. cat pg_hba.conf= =C2=A0=C2=A0=C2=A0 host=C2=A0=C2=A0 all=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 all=C2=A0=C2=A0=C2=A0 0/0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 md5 =C2=A0= =C2=A0=C2=A0 host=C2=A0=C2=A0 replication=C2=A0=C2=A0 xie=C2=A0=C2=A0=C2=A0= 192.168.1.31/32=C2=A0=C2=A0 trust =C2=A0 In this case, untrusted users on s= lave may use pg_basebackup to stole data. =C2=A0 2.=C2=A0Using password. c= at pg_hba.conf =C2=A0=C2=A0=C2=A0 host=C2=A0=C2=A0 all=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 all=C2=A0=C2=A0=C2=A0 0/0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= md5 =C2=A0=C2=A0=C2=A0 host=C2=A0=C2=A0 replication=C2=A0=C2=A0 xie=C2=A0= =C2=A0=C2=A0192.168.1.31/32=C2=A0=C2=A0 md5 =C2=A0 cat /var/lib/pgsql/.pgpa= ss (on slave) =C2=A0=C2=A0=C2=A0 192.168.1.30:5432:xie:mydb:xie =C2=A0 In t= his case, the password is stored unencrypted. File access control may help,= but it=E2=80=99s not secure enough.=20 =C2=A0 =C2=A0 Why not? The user who can read that file, can also read the= entire database on the standby node already. =C2=A0=20 3.=C2=A0Using certificate. cat pg_hba.conf =C2=A0=C2=A0=C2=A0 host=C2=A0= =C2=A0 all=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 all= =C2=A0=C2=A0=C2=A0 0/0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 md5 =C2=A0=C2=A0=C2=A0 hostssl=C2=A0=C2= =A0=C2=A0 replication=C2=A0=C2=A0 xie=C2=A0=C2=A0=C2=A0192.168.1.31/32=C2= =A0=C2=A0 cert clientcert=3D1 =C2=A0 cat postgresql.conf | grep ssl =C2=A0= =C2=A0=C2=A0 ssl =3D on ssl_ca_file =3D 'root.crt' ssl_cert_file =3D 'serve= r.crt' ssl_crl_file =3D '' ssl_key_file =3D 'server.key' =C2=A0 cat recove= ry.conf =C2=A0=C2=A0=C2=A0 primary_conninfo =3D 'host=3D192.168.1.30 port= =3D5432 user=3Dxie application_name=3Dstream_relication sslrootcert=3D/tmp/= root.crt sslcert=3D/tmp/xie.crt sslkey=3D/tmp/xie.key' restore_command =3D = '' recovery_target_timeline =3D 'latest' primary_slot_name =3D 'rep_slot' = =C2=A0 The certificates are created by official instructionshttps://www.pos= tgresql.org/docs/12/ssl-tcp.html#SSL-CERTIFICATE-CREATION. But the private = key is not encrypted. I noticed in psql 11+ version, a new configurationssl= _passphrase_command is added, so that encrypted private key can be used. Bu= t as far as I know, encrypted private key is not supported in stream replic= ation. =C2=A0 I wonder if there is another way to authenticate in replicati= on? Or does pgsql has any plan to support encrypted private key in replicat= ion? =C2=A0=20 =C2=A0 PostgreSQL replication supports all authentication methods that Pos= tgeSQL=C2=A0supports for regular connections, in general. While I haven't t= ried it, ssl_passphrase_command should work for this as well as long as it = doesn't require manual user interaction. But it could for example read the = passphrase from a pipe where it's provided off,or from a hardware device. D= o keep in mind that replication might need multiple authentications (for ex= ample if the network disconnects, it has to reconnect). =C2=A0 You can als= o use for example GSSAPI and Kerberos to do the login. You will then of cou= rse have to figure out how to securely authenticate the postgres OS user on= the standby node to the Kerberos system, but that's doable. (Though I beli= eve most Kerberos implementations also rely on filesystem security to prote= ct the tickets, so if you don't trust your filesystem, you may have a probl= em with that -- as well as indeed most other authentication systems -- so y= ou'd have to investigate that within the kerberos system). =C2=A0 -- =C2= =A0Magnus Hagander =C2=A0Me: https://www.hagander.net/ =C2=A0Work: https://www.redpill-linpro.com/=20 ------=_Part_250515_1450621331.1603812712799 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I know when I set it up with a password protecting t= he private key it would prompt me for the password when I started up the se= rvice.

Susan Joseph
sandajoseph@verizon.net


-----= Original Message-----
From: xiebin (F) <xiebin18@huawei.com>
To: Magnus Hagander <magnus@hagander.net>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>; zhub= o (C) <zhubo31@huawei.com>; Zhuzheng (IT) <zhuzheng@huawei.com>= ; houxiaowei <brian.hou@huawei.com>; yangshaobo (A) <yangshaobo6@h= uawei.com>; mapinghu <mapinghu@huawei.com>; Songyunpeng <songyu= npeng@huawei.com>; luoqi (F) <luoqi25@huawei.com>
Sent: Tue, Oct 27, 2020 7:34 am
Subject: =E7=AD=94=E5=A4=8D: Security issues concerning pgsql replication
Perhaps you misunderstand me.
=20
It is not user-database, but master-slave = interaction that I am concerning.
=20
The master-slave replication proceeds cont= inually and requires no manual interference.  Both master and slave=E2= =80=99s private key are involved, but ssl_passphrase_command is only used to parse passphrase of master=E2=80=99s private key. Pgsql cannot get= slave=E2=80=99s private key automatically, so replication failed. I=E2=80= =99ve tried and proved it did not work.
=20
 
=20
I refered to the list of pgsql=E2=80=99s a= uthenticate methods but did not find an appropriate one for replication.
=20 =20
 
=20
Xie Bin
=20
 
=20
=E5=8F=91=E4=BB=B6=E4=BA=BA: Magnus Hagander [mailto:magnus@hagander.net]
=E5=8F= =91=E9=80=81=E6=97=B6=E9=97=B4: 2020=E5=B9=B410=E6=9C=8827=E6=97=A5 17:00
=E6=94=B6=E4=BB=B6=E4=BA=BA: xiebin (F) <xiebin18@huawei.com>
=E6=8A=84=E9=80=81: pgsql-general@postgresql.org; zhubo (C) <zhubo31@huawei.com>;= Zhuzheng (IT) <zhuzheng@huawei.com>; houxiaowei <brian.hou@huawei= .com>; yangshaobo (A) <yangshaobo6@huawei.com>; mapinghu <mapin= ghu@huawei.com>; Songyunpeng <songyunpeng@huawei.com>; luoqi (F) <luoqi25@huawei.c= om>
=E4=B8=BB=E9=A2=98: Re: Security issues concerning pgsql replication =20
  =20
  =20
  =20
On Tue, Oct 27, = 2020 at 9:52 AM xiebin (F) <xiebin18@huawei.com> wrote:
=20
Hi,
=20
 
=20
I was setting up a master/slave pgsql(version 12= .4) cluster using stream replication. I found 3 ways to authenticate, but a= ll of them has some security issue.
=20
 
=20
1.  Disable authent= ication.
=20
cat pg_hba.conf
=20
    = host   all         &= nbsp; all    0/0       &n= bsp;       md5
=20
    = host   replication   xie    192= .168.1.31/32   trust =20
 
=20
In this case, untruste= d users on slave may use pg_basebackup to stole data.
=20
 
=20
2.  Using password.=
=20
cat pg_hba.conf
=20
    = host   all         &= nbsp; all    0/0       &n= bsp;       md5
=20
    = host   replication   xie    192= .168.1.31/32   md5 =20
 =
=20
cat /var/lib/pgsql/= .pgpass (on slave)
=20
    = 192.168.1.30:5432:xie:mydb:xie
=20
 =
=20
In this case, the pass= word is stored unencrypted. File access control may help, but it=E2=80=99s = not secure enough.
=20
  =20
  =20
Why not? The use= r who can read that file, can also read the entire database on the standby = node already.
=20
 
=20
3.  Using certifica= te.
=20
cat pg_hba.conf
=20
    = host   all         &= nbsp; all    0/0       &n= bsp;       md5
=20
    = hostssl    replication   xie    192= .168.1.31/32   cert clientcert=3D1
=20
 
=20
cat postgresql.conf= | grep ssl
=20
    = ssl =3D on
=20
ssl_ca_file =3D 'ro= ot.crt'
=20
ssl_cert_file =3D '= server.crt'
=20
ssl_crl_file =3D ''=
=20
ssl_key_file =3D 's= erver.key'
=20
 
=20
cat recovery.conf
=20
    = primary_conninfo =3D 'host=3D192.168.1.30 port=3D5432 user=3Dxie applicatio= n_name=3Dstream_relication sslrootcert=3D/tmp/root.crt sslcert=3D/tmp/xie.c= rt sslkey=3D/tmp/xie.key'
=20
restore_command =3D= ''
=20
recovery_target_tim= eline =3D 'latest'
=20
primary_slot_name = =3D 'rep_slot'
=20
 
=20 =20
I noticed in psql 11+ = version, a new configuration ssl_passphrase_command is added, so that encrypted private key can b= e used.
=20
But as far as I know, = encrypted private key is not supported in stream replication.
=20
 
=20
I wonder if there is another way to authenticate= in replication? Or does pgsql has any plan to support encrypted private ke= y in replication?
=20
 
=20
  =20
PostgreSQL repli= cation supports all authentication methods that PostgeSQL supports for= regular connections, in general. While I haven't tried it, ssl_passphrase_= command should work for this as well as long as it doesn't require manual user interaction. But it could for example read the passphr= ase from a pipe where it's provided off,or from a hardware device. Do keep = in mind that replication might need multiple authentications (for example i= f the network disconnects, it has to reconnect).
=20
  =20
You can also use= for example GSSAPI and Kerberos to do the login. You will then of course h= ave to figure out how to securely authenticate the postgres OS user on the = standby node to the Kerberos system, but that's doable. (Though I believe most Kerberos implementations also rely on filesystem se= curity to protect the tickets, so if you don't trust your filesystem, you m= ay have a problem with that -- as well as indeed most other authentication = systems -- so you'd have to investigate that within the kerberos system).
=20
------=_Part_250515_1450621331.1603812712799--