Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wcKMx-003GY1-31 for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Jun 2026 09:58:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wcKLx-000DFN-2T for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Jun 2026 09:57:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wcKLx-000DFF-1a for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 09:57:05 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wcKLv-000000000UL-2R4g for pgsql-bugs@lists.postgresql.org; Wed, 24 Jun 2026 09:57:05 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-4629d80fa08so773352f8f.3 for ; Wed, 24 Jun 2026 02:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1782295021; x=1782899821; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=CrqxeRERfAQRji01xubeGKqYa6evaSqYO4cZzuaax/I=; b=DPVNdgUQs77jYUgRSq24UqSqOR2dGhMy7WcdY74GLVfZKE19Tv8n/5l+FsqzovfRfv OF24tJr2r4c+EFgNXGBGxIEgfMT75tcG9XffbjB+BWIAdOMVehD7AZm99JdZg6uNsChY LMsysfppNL/2mJPSOYkmxwEEX6Mkk5JtzqkZFYQWbgSEK38qgT7g1yyDKFX3V/UFdzm2 aGXJGYh4ela4enfRntJGUV0DPNbwj1gFmZuOjDSWjXdMjyO6uHAFUrPhtHrUlhULTp+a QEqF0/ROGkTMKgHDYhtvKTjt8qMQBOb5E+QED8eT+4ctCaG+vsrjajanlxIYIgz3TBVA M5mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782295021; x=1782899821; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CrqxeRERfAQRji01xubeGKqYa6evaSqYO4cZzuaax/I=; b=R4EpO2n80tQ4GI0uMPiH54I78i3tNz2+JO79WlLQEbWNNn1ZA15eDMV9o9hcZGU+HX 3n7hFOHq+Lot7P18SAlO6n251tzXjNclqNK6nBX1ZtSY22aBgJmn6tSFWErE5fdb6gkO ZXG/1JXbXuXCMophXmUqW58LspsXvKIa5QM6jzGBk/wMvEqXdCb6Xr1eG8N+DlaZA9ZW 2cQFLPgzATjdaJ+7AxtIpXF9o3H9AYry2YyBG3dtQWdVcLh6BLOFAG9RTzTq/vw+GiWo XQQaBLneKoOiZS+q5mGS/jvZJIcomYZqQY23Tb1NwvXDjZhPeBj432OQg3wUS+6lsltp HGdQ== X-Forwarded-Encrypted: i=1; AHgh+RoF24QO4SGllhz3SU09aRlQX+L9J3npeNNti4obLrRdDKuy4zE7ECvgRlbfy3VKvBroXey42giOcEiq@lists.postgresql.org X-Gm-Message-State: AOJu0YxkbcDZzL7ItHIptUetCTqXjQmwL46X0nW8t9bzaO+TdfsZJqIS TN/SgUQBXlNa1pziXQRxTIPuqrxRND/1vnMOGPcGYPu7xS9IkP9KqeLdqyXyvrNJ2V8= X-Gm-Gg: AfdE7ckKDYRDxeiT0BdoCek37IsuIY9S6s0/5ac8lgj00CwrmrOtq+wUO2miDUfc9SR TWomIVQNEBaYpJx9S/lumqJZ4KYVpiSbn3gaQoE26Un73ccFkMDeR/bjAcBfv66StPef8PnYbMG E5YSfXYP7ux+5k8cowHHYsXeWEo3sl1aGnD0FWKYqpkAMner8242qZ68hEIYgWdapCqzoxjFDC4 Al6iIhUJou6EV2bTbFADALKeE/cXJkvWqcmAn0jq9zYRbE54hnlPbkIV5Wjk+QF5v4sYkVW6QhO p1vSIbqPQSTuCI6mLj0zoFjvCA6apUqNSbPlR74GuRKiyJlksg99LIOwKxdcTKGOn8+N77rcc+n bQJDruic/LA0N+jkzUMtgazqPmROR4Gc+bWeAMur0kqrA/j8hufehMhwrVx1hPUz+twohQyaqGv gvI6eraX5SRp9B X-Received: by 2002:a05:6000:46cc:b0:441:1e41:194 with SMTP id ffacd0b85a97d-46c050ed739mr3344007f8f.17.1782295021173; Wed, 24 Jun 2026 02:57:01 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([213.208.157.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c221d93cdsm6021118f8f.18.2026.06.24.02.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 02:57:00 -0700 (PDT) Message-ID: Subject: Re: BUG #19483: pg_upgrade fails with orphan records in pg_init_priv catalog table From: Laurenz Albe To: =?ISO-8859-1?Q?H=FCseyin?= Demir , Tom Lane Cc: Greg Sabino Mullane , pgsql-bugs@lists.postgresql.org Date: Wed, 24 Jun 2026 11:56:58 +0200 In-Reply-To: References: <19483-80de42dc4e62cfd6@postgresql.org> <104812.1780847519@sss.pgh.pa.us> <5184088806e70ed5db7e83bd6540a016b3802c1d.camel@cybertec.at> <0d7531c192859057c6aad54c89a8d453376bd00c.camel@cybertec.at> <592839.1782153054@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2026-06-24 at 08:14 +0200, H=C3=BCseyin Demir wrote: > You can see the attached v5 patch. Basically, v5 solves the problem by > adding dangling-role filtering directly inside buildACLCommands(). A > role name that consists entirely of digits is potentially a dangling > OID reference and it resolves by querying pg_authid once at the start > of the dump for any legitimate all-digit role names. The patch looks good and passes my tests. It fails the regression tests on my system with pg_dump: error: query failed: ERROR: permission denied for table pg_auth= id I think you should use pg_roles rather than pg_authid, so that it remains possible to use pg_dump with a non-superuser. While the technique of fetching the all-numeric role names in advance is certainly much cheaper than running a complicated subquery for every object dumped, I have one remaining doubt: What if there is a dangling role OID 65432 in pg_init_privs *and* a valid role with the same name (but a different OID)? Then the patch would tacitly restore the dangling reference to the latter role. Apart from the result being wrong, I wonder if that could be used for a privilege escalation attack: you detect that there are dangling pg_init_privs entries that grant high privileges. Then you abuse your CREATEROLE to create a role with the same name as the dangling OID. After a dump and restore, your role has been assigned those privileges. Perhaps it would be a better approach to fetch the data from pg_init_privs once at the beginning of the dump, ignoring the entries with dangling OIDs? Yours, Laurenz Albe