Fix errorhandling for PGP encryption

PGP encryption was using px_cipher_encrypt without checking if any
error was returned.  When OpenSSL is running in FIPS mode, or when
the legacy provider hasn't been loaded, not all ciphers which are
supported by the PGP code are available and fail the init step in
px_cipher_encrypt.  Since the PGP encryption failed to notice this
it XORed the non-encrypted block with the plaintext, effectively
disabling the encryption.

This was found due to a report of PGP encryption not respecting
the pgcrypto.builtin_crypto_enabled flag and allowing Blowfish
and DES.  This however turned out to be a false positive, since
the PGP code only use ciphers from OpenSSL and not the built in
ciphers.

Bug: #19457
Reported-by: Shishir Sharma <[email protected]>
Reviewed-by: Jacob Champion <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Security: CVE-2026-14663
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ba207f58f38955fdd787839eb757d48fa8c15c5b
Author: Daniel Gustafsson <[email protected]>

Modified Files
--------------
contrib/pgcrypto/expected/pgp-decrypt_1.out        |   2 +-
contrib/pgcrypto/expected/pgp-encrypt_1.out        | 192 +++++++++++++++++++++
contrib/pgcrypto/expected/pgp-pubkey-decrypt_1.out |   2 +-
contrib/pgcrypto/pgp-cfb.c                         |   8 +-
doc/src/sgml/pgcrypto.sgml                         |   5 +
5 files changed, 206 insertions(+), 3 deletions(-)

Reply via email to