]> 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:00:59 +0000 (08:00 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sun, 8 Feb 2026 23:00:59 +0000 (08:00 +0900)
commit379695d3cc70d040b547d912ce4842090d917ece
tree41d0097c7ea483240c4cf90b70c591ba1dc5541a
parent73dd7163c5d19f93b629d1ccd9d2a2de6e9667f6
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]