Skip to main content
Menu
Advisories

pgjdbc GSS encryption accepts replayed packets and can stop encrypting

GHSA-HCJC-54FP-2P42Published Updated GitHub

Description

With GSS encryption, pgjdbc accepted server packets that were replayed or out of order. An integrity-only server packet also turned off encryption for the packets the driver sent after it.

Details

GSSContext.unwrap() reports a duplicate, old, out-of-sequence or gap token in the MessageProp. It does not fail. The driver did not check these flags. An attacker on the network could drop a server reply and deliver an earlier one from the same connection.

The driver shared one MessageProp between reading and writing. An incoming token without privacy cleared the privacy flag, and later outgoing packets were signed but not encrypted. Only a party with the session key, such as the server, can create such a token.

Proof of concept

A malicious backend that sends messages to the driver like this:

backend to client: [length][sealed token T] [length][sealed token T]
// The driver delivers both copies of T to the protocol parser.

Impact

A network attacker can make the driver accept an earlier server reply as the answer to the current query. A server that sends one integrity-only packet makes the driver send later SQL and parameters readable on the network. This needs gssEncMode=prefer or require and a server that accepts GSS encryption. The default since 42.2.18 is allow, which does not start GSS encryption.

Affected versions

References

GitHub · pgjdbc/pgjdbc