]> git.ipfire.org Git - thirdparty/postgresql.git/commit
pgcrypto: Fix buffer overflow in pgp_pub_decrypt_bytea()
authorMichael Paquier <michael@paquier.xyz>
Sun, 8 Feb 2026 23:01:09 +0000 (08:01 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sun, 8 Feb 2026 23:01:09 +0000 (08:01 +0900)
commit527b730f41b2f2fbcda92cfd1dbbc50c14c9a46f
treefa5bc6fd747c884419bad180dc5931249f1a036b
parent79378568178764d962d11e1f5a00a7bf7f480278
pgcrypto: Fix buffer overflow in pgp_pub_decrypt_bytea()

pgp_pub_decrypt_bytea() was missing a safeguard for the session key
length read from the message data, that can be given in input of
pgp_pub_decrypt_bytea().  This can result in the possibility of a buffer
overflow for the session key data, when the length specified is longer
than PGP_MAX_KEY, which is the maximum size of the buffer where the
session data is copied to.

A script able to rebuild the message and key data that can trigger the
overflow is included in this commit, based on some contents provided by
the reporter, heavily editted by me.  A SQL test is added, based on the
data generated by the script.

Reported-by: Team Xint Code as part of zeroday.cloud
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Noah Misch <noah@leadboat.com>
Security: CVE-2026-2005
Backpatch-through: 14
contrib/pgcrypto/Makefile
contrib/pgcrypto/expected/pgp-pubkey-session.out [new file with mode: 0644]
contrib/pgcrypto/meson.build
contrib/pgcrypto/pgp-pubdec.c
contrib/pgcrypto/px.c
contrib/pgcrypto/px.h
contrib/pgcrypto/scripts/pgp_session_data.py [new file with mode: 0644]
contrib/pgcrypto/sql/pgp-pubkey-session.sql [new file with mode: 0644]