Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
acc919b
Harden tsvector code against overflows.
tglsfdc Aug 10, 2026
d5c1178
Harden tsquery code against overflows.
tglsfdc Aug 10, 2026
299f532
Fix potential buffer overrun in regexp match/split functions.
MasahikoSawada Aug 10, 2026
849a839
Be more wary about constant's datatype in scalarineqsel().
tglsfdc Aug 10, 2026
da28a0c
Replace fixed-size, too-short array with a palloc'd one.
tglsfdc Aug 10, 2026
c858f91
Protect some fixed-size arrays that have FUNC_MAX_ARGS elements.
tglsfdc Aug 10, 2026
6b82127
Fix pg_trgm's picksplit function with all-true datums
hlinnaka Aug 10, 2026
bc9ae6e
Use palloc_array() in pltcl and plperl to avoid overflow
hlinnaka Aug 10, 2026
210cce1
ecpg: Fix out-of-bound writes due to processing of invalid bytea data
michaelpq Aug 10, 2026
e20f0d6
Obstruct EXTRACT() field name deparse injection.
nathan-bossart Aug 10, 2026
4a06582
Cross-check the type of a portal running EXECUTE or FETCH.
robertmhaas Aug 10, 2026
1802fb2
Check for USAGE privilege on the subtype in CREATE TYPE AS RANGE.
nathan-bossart Aug 10, 2026
ac4bd2f
Check for USAGE privilege on the composite type in ALTER TABLE OF.
nathan-bossart Aug 10, 2026
c68d412
Invalidate plan cache after role changes.
nathan-bossart Aug 10, 2026
8513d2a
Save/restore more lexer state when skipping text due to \if.
tglsfdc Aug 10, 2026
28bd2ef
Fix errorhandling for PGP encryption
danielgustafsson Aug 10, 2026
d0df0a7
pgcrypto: Add option to revert to prior decryption behavior
jchampio Aug 10, 2026
1659d45
psql: Don't do backquote expansion in \unrestrict.
nathan-bossart Aug 10, 2026
c4ffaf8
Guard against overlength time zone abbreviations in to_char().
tglsfdc Aug 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/pg_trgm/trgm_gist.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
else
size_alpha = SIGLENBIT(siglen) -
sizebitvec((cache[j].allistrue) ? GETSIGN(datum_l) :
GETSIGN(cache[j].sign),
cache[j].sign,
siglen);
}
else
Expand All @@ -903,7 +903,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
else
size_beta = SIGLENBIT(siglen) -
sizebitvec((cache[j].allistrue) ? GETSIGN(datum_r) :
GETSIGN(cache[j].sign),
cache[j].sign,
siglen);
}
else
Expand Down
26 changes: 26 additions & 0 deletions contrib/pgcrypto/expected/pgp-decrypt.out
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,29 @@ UCAAw2JRIISttRHMfDpDuZJpvYo=
'), 'key', 'debug=1');
NOTICE: dbg: parse_compressed_data: bzip2 unsupported
ERROR: Unsupported compression algorithm
-- Check ignore-cipher-failure. This message isn't actually encrypted; it was
-- created with cipher-algo=bf using an OpenSSL that didn't actually support
-- Blowfish. After the fix for CVE-2026-14663, we no longer create these broken
-- ciphertexts, but we allow users to return to the previous behavior during
-- decryption so that the bad wrapper can be stripped.
--
-- Note that if Blowfish is supported by the linked OpenSSL, both decryptions
-- will fail.
select pgp_sym_decrypt(dearmor('
-----BEGIN PGP MESSAGE-----

ww0EBAMC8wIKbtvzJtxi0jABUleCwFJWGCkYKcsNdABqdtXaU2VjcmV0LtMUlnPH3A2QBmZrcucm
1GPb/s2Bkdg=
=6aqD
-----END PGP MESSAGE-----
'), 'wrong key');
ERROR: Wrong key or corrupt data
select pgp_sym_decrypt(dearmor('
-----BEGIN PGP MESSAGE-----

ww0EBAMC8wIKbtvzJtxi0jABUleCwFJWGCkYKcsNdABqdtXaU2VjcmV0LtMUlnPH3A2QBmZrcucm
1GPb/s2Bkdg=
=6aqD
-----END PGP MESSAGE-----
'), 'wrong key', 'ignore-cipher-failure=1');
ERROR: Wrong key or corrupt data
32 changes: 31 additions & 1 deletion contrib/pgcrypto/expected/pgp-decrypt_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ yA6Ce1QTMK3KdL2MPfamsTUSAML8huCJMwYQFfE=
=JcP+
-----END PGP MESSAGE-----
'), 'foobar');
ERROR: Wrong key or corrupt data
ERROR: encrypt error: Cipher cannot be initialized ?
select pgp_sym_decrypt(dearmor('
-----BEGIN PGP MESSAGE-----
Comment: dat1.aes.sha1.mdc.s2k3.z0
Expand Down Expand Up @@ -419,3 +419,33 @@ UCAAw2JRIISttRHMfDpDuZJpvYo=
'), 'key', 'debug=1');
NOTICE: dbg: parse_compressed_data: bzip2 unsupported
ERROR: Unsupported compression algorithm
-- Check ignore-cipher-failure. This message isn't actually encrypted; it was
-- created with cipher-algo=bf using an OpenSSL that didn't actually support
-- Blowfish. After the fix for CVE-2026-14663, we no longer create these broken
-- ciphertexts, but we allow users to return to the previous behavior during
-- decryption so that the bad wrapper can be stripped.
--
-- Note that if Blowfish is supported by the linked OpenSSL, both decryptions
-- will fail.
select pgp_sym_decrypt(dearmor('
-----BEGIN PGP MESSAGE-----

ww0EBAMC8wIKbtvzJtxi0jABUleCwFJWGCkYKcsNdABqdtXaU2VjcmV0LtMUlnPH3A2QBmZrcucm
1GPb/s2Bkdg=
=6aqD
-----END PGP MESSAGE-----
'), 'wrong key');
ERROR: encrypt error: Cipher cannot be initialized ?
select pgp_sym_decrypt(dearmor('
-----BEGIN PGP MESSAGE-----

ww0EBAMC8wIKbtvzJtxi0jABUleCwFJWGCkYKcsNdABqdtXaU2VjcmV0LtMUlnPH3A2QBmZrcucm
1GPb/s2Bkdg=
=6aqD
-----END PGP MESSAGE-----
'), 'wrong key', 'ignore-cipher-failure=1');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

202 changes: 202 additions & 0 deletions contrib/pgcrypto/expected/pgp-encrypt_1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
--
-- PGP encrypt
--
-- ensure consistent test output regardless of the default bytea format
SET bytea_output TO escape;
select pgp_sym_decrypt(pgp_sym_encrypt('Secret.', 'key'), 'key');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- check whether the defaults are ok
select pgp_sym_decrypt(pgp_sym_encrypt('Secret.', 'key'),
'key', 'expect-cipher-algo=aes128,
expect-disable-mdc=0,
expect-sess-key=0,
expect-s2k-mode=3,
expect-s2k-digest-algo=sha1,
expect-compress-algo=0
');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- maybe the expect- stuff simply does not work
select pgp_sym_decrypt(pgp_sym_encrypt('Secret.', 'key'),
'key', 'expect-cipher-algo=bf,
expect-disable-mdc=1,
expect-sess-key=1,
expect-s2k-mode=0,
expect-s2k-digest-algo=md5,
expect-compress-algo=1
');
NOTICE: pgp_decrypt: unexpected cipher_algo: expected 4 got 7
NOTICE: pgp_decrypt: unexpected s2k_mode: expected 0 got 3
NOTICE: pgp_decrypt: unexpected s2k_digest_algo: expected 1 got 2
NOTICE: pgp_decrypt: unexpected use_sess_key: expected 1 got 0
NOTICE: pgp_decrypt: unexpected disable_mdc: expected 1 got 0
NOTICE: pgp_decrypt: unexpected compress_algo: expected 1 got 0
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- bytea as text
select pgp_sym_decrypt(pgp_sym_encrypt_bytea('Binary', 'baz'), 'baz');
ERROR: Not text data
-- text as bytea
select pgp_sym_decrypt_bytea(pgp_sym_encrypt('Text', 'baz'), 'baz');
pgp_sym_decrypt_bytea
-----------------------
Text
(1 row)

-- algorithm change
select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 'cipher-algo=bf'),
'key', 'expect-cipher-algo=bf');
ERROR: encrypt error: Cipher cannot be initialized ?
select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 'cipher-algo=aes'),
'key', 'expect-cipher-algo=aes128');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 'cipher-algo=aes192'),
'key', 'expect-cipher-algo=aes192');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- s2k change
select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 's2k-mode=0'),
'key', 'expect-s2k-mode=0');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 's2k-mode=1'),
'key', 'expect-s2k-mode=1');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 's2k-mode=3'),
'key', 'expect-s2k-mode=3');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- s2k count change
select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 's2k-count=1024'),
'key', 'expect-s2k-count=1024');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- s2k_count rounds up
select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 's2k-count=65000000'),
'key', 'expect-s2k-count=65000000');
NOTICE: pgp_decrypt: unexpected s2k_count: expected 65000000 got 65011712
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- s2k digest change
select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 's2k-digest-algo=md5'),
'key', 'expect-s2k-digest-algo=md5');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 's2k-digest-algo=sha1'),
'key', 'expect-s2k-digest-algo=sha1');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- sess key
select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 'sess-key=0'),
'key', 'expect-sess-key=0');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1'),
'key', 'expect-sess-key=1');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1, cipher-algo=bf'),
'key', 'expect-sess-key=1, expect-cipher-algo=bf');
ERROR: encrypt error: Cipher cannot be initialized ?
select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1, cipher-algo=aes192'),
'key', 'expect-sess-key=1, expect-cipher-algo=aes192');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1, cipher-algo=aes256'),
'key', 'expect-sess-key=1, expect-cipher-algo=aes256');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- no mdc
select pgp_sym_decrypt(
pgp_sym_encrypt('Secret.', 'key', 'disable-mdc=1'),
'key', 'expect-disable-mdc=1');
pgp_sym_decrypt
-----------------
Secret.
(1 row)

-- crlf
select encode(pgp_sym_decrypt_bytea(
pgp_sym_encrypt(E'1\n2\n3\r\n', 'key', 'convert-crlf=1'),
'key'), 'hex');
encode
----------------------
310d0a320d0a330d0d0a
(1 row)

-- conversion should be lossless
select encode(digest(pgp_sym_decrypt(
pgp_sym_encrypt(E'\r\n0\n1\r\r\n\n2\r', 'key', 'convert-crlf=1'),
'key', 'convert-crlf=1'), 'sha1'), 'hex') as result,
encode(digest(E'\r\n0\n1\r\r\n\n2\r', 'sha1'), 'hex') as expect;
result | expect
------------------------------------------+------------------------------------------
47bde5d88d6ef8770572b9cbb4278b402aa69966 | 47bde5d88d6ef8770572b9cbb4278b402aa69966
(1 row)

3 changes: 2 additions & 1 deletion contrib/pgcrypto/expected/pgp-info.out
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@ from encdata order by id;
B68504FD128E1FF9
FD0206C409B74875
FD0206C409B74875
(5 rows)
D936CF64BB73F466
(6 rows)

30 changes: 30 additions & 0 deletions contrib/pgcrypto/expected/pgp-pubkey-decrypt.out
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,20 @@ blH2nKZC9d6fi4YzSYMepZpMOFR65M80MCMiDUGnZBB8sEADu2/iVtqDUeG8mAA=
=PHJ1
-----END PGP MESSAGE-----
');
-- CVE-2026-14663. This message was created with cipher-algo=bf using an OpenSSL
-- that didn't actually support Blowfish.
insert into encdata (id, data) values (6, '
-----BEGIN PGP MESSAGE-----

wcBOA9k2z2S7c/RmEAP8DYbU6AeEo6riMMdnf2G62BM9gC0Z32ODydewy3Ki8AnSzpwBDAHuDMcr
P6RJDWvBOVOwgxHEwR7ZHMoFRDJEXdo6rQ9dQpDtbasMLyi6Lm1q+PbEefVd9WkU7fvFAFQx8k3t
lxrlWg/byoNplc7/hFxIFO8bN+FIlLgilAdApNcD/3Mg2/nd7pczovsYoryf9ib04kQ+SVWs3iNE
StoyEXT+oaT8u1vAxiY7fzPpQX1pnlHBUXn+v1J6LQL5Bwi5CTqOyDSyaFfgU0gQwTReFjS6L4Fs
Cv+2cFwbJBGIzr1aI4DLbzSelkmVm4hbOVeET4DJVlUVhhIyy6ZfoXiTEG6s0jMB2JdRGIl0EUQR
RMsQdABqdt5jU2VjcmV0IG1zZ9MUIIP4SPiU2pM/nF/A1hrltMhn/ZI=
=Mkdj
-----END PGP MESSAGE-----
');
-- successful decrypt
select pgp_pub_decrypt(dearmor(data), dearmor(seckey))
from keytbl, encdata where keytbl.id=1 and encdata.id=1;
Expand All @@ -600,6 +614,13 @@ from keytbl, encdata where keytbl.id=2 and encdata.id=2;
Secret msg
(1 row)

select pgp_pub_decrypt(dearmor(data), dearmor(seckey), '', 'ignore-cipher-failure=1')
from keytbl, encdata where keytbl.id=2 and encdata.id=2;
pgp_pub_decrypt
-----------------
Secret msg
(1 row)

select pgp_pub_decrypt(dearmor(data), dearmor(seckey))
from keytbl, encdata where keytbl.id=3 and encdata.id=3;
pgp_pub_decrypt
Expand Down Expand Up @@ -654,3 +675,12 @@ from keytbl, encdata where keytbl.id=5 and encdata.id=1;
select pgp_pub_decrypt(dearmor(data), dearmor(seckey))
from keytbl, encdata where keytbl.id=6 and encdata.id=5;
ERROR: Wrong key or corrupt data
-- Check that ignore-cipher-failure can strip faulty encryption if OpenSSL
-- doesn't support the cipher. (The decryption will correctly fail both times if
-- OpenSSL does support it.)
select pgp_pub_decrypt(dearmor(data), dearmor(seckey))
from keytbl, encdata where keytbl.id=1 and encdata.id=6;
ERROR: Wrong key or corrupt data
select pgp_pub_decrypt(dearmor(data), dearmor(seckey), '', 'ignore-cipher-failure=1')
from keytbl, encdata where keytbl.id=1 and encdata.id=6;
ERROR: Wrong key or corrupt data
30 changes: 30 additions & 0 deletions contrib/pgcrypto/expected/pgp-pubkey-decrypt_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,20 @@ blH2nKZC9d6fi4YzSYMepZpMOFR65M80MCMiDUGnZBB8sEADu2/iVtqDUeG8mAA=
=PHJ1
-----END PGP MESSAGE-----
');
-- CVE-2026-14663. This message was created with cipher-algo=bf using an OpenSSL
-- that didn't actually support Blowfish.
insert into encdata (id, data) values (6, '
-----BEGIN PGP MESSAGE-----

wcBOA9k2z2S7c/RmEAP8DYbU6AeEo6riMMdnf2G62BM9gC0Z32ODydewy3Ki8AnSzpwBDAHuDMcr
P6RJDWvBOVOwgxHEwR7ZHMoFRDJEXdo6rQ9dQpDtbasMLyi6Lm1q+PbEefVd9WkU7fvFAFQx8k3t
lxrlWg/byoNplc7/hFxIFO8bN+FIlLgilAdApNcD/3Mg2/nd7pczovsYoryf9ib04kQ+SVWs3iNE
StoyEXT+oaT8u1vAxiY7fzPpQX1pnlHBUXn+v1J6LQL5Bwi5CTqOyDSyaFfgU0gQwTReFjS6L4Fs
Cv+2cFwbJBGIzr1aI4DLbzSelkmVm4hbOVeET4DJVlUVhhIyy6ZfoXiTEG6s0jMB2JdRGIl0EUQR
RMsQdABqdt5jU2VjcmV0IG1zZ9MUIIP4SPiU2pM/nF/A1hrltMhn/ZI=
=Mkdj
-----END PGP MESSAGE-----
');
-- successful decrypt
select pgp_pub_decrypt(dearmor(data), dearmor(seckey))
from keytbl, encdata where keytbl.id=1 and encdata.id=1;
Expand All @@ -595,6 +609,9 @@ from keytbl, encdata where keytbl.id=1 and encdata.id=1;

select pgp_pub_decrypt(dearmor(data), dearmor(seckey))
from keytbl, encdata where keytbl.id=2 and encdata.id=2;
ERROR: encrypt error: Cipher cannot be initialized ?
select pgp_pub_decrypt(dearmor(data), dearmor(seckey), '', 'ignore-cipher-failure=1')
from keytbl, encdata where keytbl.id=2 and encdata.id=2;
ERROR: Wrong key or corrupt data
select pgp_pub_decrypt(dearmor(data), dearmor(seckey))
from keytbl, encdata where keytbl.id=3 and encdata.id=3;
Expand Down Expand Up @@ -650,3 +667,16 @@ from keytbl, encdata where keytbl.id=5 and encdata.id=1;
select pgp_pub_decrypt(dearmor(data), dearmor(seckey))
from keytbl, encdata where keytbl.id=6 and encdata.id=5;
ERROR: Wrong key or corrupt data
-- Check that ignore-cipher-failure can strip faulty encryption if OpenSSL
-- doesn't support the cipher. (The decryption will correctly fail both times if
-- OpenSSL does support it.)
select pgp_pub_decrypt(dearmor(data), dearmor(seckey))
from keytbl, encdata where keytbl.id=1 and encdata.id=6;
ERROR: encrypt error: Cipher cannot be initialized ?
select pgp_pub_decrypt(dearmor(data), dearmor(seckey), '', 'ignore-cipher-failure=1')
from keytbl, encdata where keytbl.id=1 and encdata.id=6;
pgp_pub_decrypt
-----------------
Secret msg
(1 row)

Loading
Loading