]> 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:07 +0000 (08:01 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sun, 8 Feb 2026 23:01:07 +0000 (08:01 +0900)
commit7a7d9693c72e680af86298f01d850f95fef0988e
tree4c985045b7cf4f1eab54f1c9ac0079c34f97ffa4
parent4d3d88844b1b6c18e2ec752b03cb304d3b296216
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]