pgsql: Require PGP-decrypted text to pass encoding validation.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Require PGP-decrypted text to pass encoding validation.
Date: 2026-02-09 14:16:18
Message-ID: E1vpS3m-0025Hv-00@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Require PGP-decrypted text to pass encoding validation.

pgp_sym_decrypt() and pgp_pub_decrypt() will raise such errors, while
bytea variants will not. The existing "dat3" test decrypted to non-UTF8
text, so switch that query to bytea.

The long-term intent is for type "text" to always be valid in the
database encoding. pgcrypto has long been known as a source of
exceptions to that intent, but a report about exploiting invalid values
of type "text" brought this module to the forefront. This particular
exception is straightforward to fix, with reasonable effect on user
queries. Back-patch to v14 (all supported versions).

Reported-by: Paul Gerste (as part of zeroday.cloud)
Reported-by: Moritz Sanft (as part of zeroday.cloud)
Author: shihao zhong <zhong950419(at)gmail(dot)com>
Reviewed-by: cary huang <hcary328(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAGRkXqRZyo0gLxPJqUsDqtWYBbgM14betsHiLRPj9mo2=z9VvA@mail.gmail.com
Backpatch-through: 14
Security: CVE-2026-2006

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/dc072a09ad6a0b89d021047b2418f517a430966d

Modified Files
--------------
contrib/pgcrypto/expected/pgp-decrypt.out | 23 ++++++++++++++++++++++-
contrib/pgcrypto/expected/pgp-decrypt_1.out | 23 ++++++++++++++++++++++-
contrib/pgcrypto/pgp-pgsql.c | 2 ++
contrib/pgcrypto/sql/pgp-decrypt.sql | 22 +++++++++++++++++++++-
4 files changed, 67 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-02-09 15:15:05 pgsql: Add a syscache on pg_extension.oid.
Previous Message Álvaro Herrera 2026-02-09 12:28:10 pgsql: Allow log_min_messages to be set per process type