CVE-2022-41946 is a medium-severity (CVSS 4.7) Information Exposure vulnerability in org.postgresql:postgresql. 1 public exploit or proof-of-concept reference is indexed, so weaponization risk is real. A fix is available for org.postgresql:postgresql — see the affected versions and patch details below.
TemporaryFolder on unix-like systems does not limit access to created files in pgjdbc
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
org.postgresql:postgresql☕org.postgresql:postgresql☕org.postgresql:postgresql☕org.postgresql:postgresqlReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects Maven packages — download data is not available via public APIs for these ecosystems.
Description
Vulnerability
PreparedStatement.setText(int, InputStream)
and
PreparedStatemet.setBytea(int, InputStream)
will create a temporary file if the InputStream is larger than 51k
Example of vulnerable code:
String s = "some very large string greater than 51200 bytes";
PreparedStatement.setInputStream(1, new ByteArrayInputStream(s.getBytes()) );
This will create a temporary file which is readable by other users on Unix like systems, but not MacOS.
Impact On Unix like systems, the system's temporary directory is shared between all users on that system. Because of this, when files and directories are written into this directory they are, by default, readable by other users on that same system.
This vulnerability does not allow other users to overwrite the contents of these directories or files. This is purely an information disclosure vulnerability.
When analyzing the impact of this vulnerability, here are the important questions to ask:
Is the driver running in an environment where the OS has other untrusted users. If yes, and you answered 'yes' to question 1, this vulnerability impacts you. If no, this vulnerability does not impact you. Patches Because certain JDK file system APIs were only added in JDK 1.7, this this fix is dependent upon the version of the JDK you are using.
Java 1.8 and higher users: this vulnerability is fixed in 42.2.27, 42.3.8, 42.4.3, 42.5.1 Java 1.7 users: this vulnerability is fixed in 42.2.27.jre7 Java 1.6 and lower users: no patch is available; you must use the workaround below. Workarounds If you are unable to patch, or are stuck running on Java 1.6, specifying the java.io.tmpdir system environment variable to a directory that is exclusively owned by the executing user will fix this vulnerability.
References CWE-200: Exposure of Sensitive Information to an Unauthorized Actor Fix commit https://github.com/pgjdbc/pgjdbc/commit/9008dc9aade6dbfe4efafcd6872ebc55f4699cf5 Similar Vulnerabilities Google Guava - https://github.com/google/guava/issues/4011 Apache Ant - https://nvd.nist.gov/vuln/detail/CVE-2020-1945 JetBrains Kotlin Compiler - https://nvd.nist.gov/vuln/detail/CVE-2020-15824
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| ☕Maven | org.postgresql:postgresql | ≥ 42.2.0&&< 42.2.27 | 42.2.27org.postgresql:postgresql:42.2.27 |
| ☕Maven | org.postgresql:postgresql | ≥ 42.3.0&&< 42.3.8 | 42.3.8org.postgresql:postgresql:42.3.8 |
| ☕Maven | org.postgresql:postgresql | ≥ 42.4.0&&< 42.4.3 | 42.4.3org.postgresql:postgresql:42.4.3 |
| ☕Maven | org.postgresql:postgresql | ≥ 42.5.0&&< 42.5.1 | 42.5.1org.postgresql:postgresql:42.5.1 |
Affected Products
debian linuxdebianpostgresql jdbc driverpostgresqlResearch use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for org.postgresql:postgresql, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update org.postgresql:postgresql to 42.2.27 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2022-41946 is resolved across your whole dependency graph.
Workarounds
Assume what was exposed is already known: rotate any credential, token or key that the affected component could return, restrict the endpoint to callers that genuinely need it, and strip sensitive fields from responses and error output at the boundary rather than relying on the client not to read them.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
Red Hat Satellite ships a PostgreSQL JDBC Driver for Hibernate ORM framework, which is embeds into Candlepin. Although Candlepin itself doesn't make direct use of the PreparedStatement methods from the PostgreSQL JDBC Driver, Hibernate ORM does utilize these methods, potentially making framework affected. Satellite…
| Product | Fixed in | Advisory |
|---|---|---|
| CEQ 2.13.2-1 | see advisory | RHSA-2023:0888 |
| Red Hat build of Quarkus | see advisory | RHSA-2023:0758 |
| Red Hat build of Quarkus 2.7.7 | jdbc-postgresql | RHSA-2023:1006 |
| Red Hat Enterprise Linux 8 | postgresql-jdbc-0:42.2.14-2.el8 | RHSA-2023:2867 |
| Red Hat Enterprise Linux 9 | postgresql-jdbc-0:42.2.27-1.el9 | RHSA-2023:2378 |
| Red Hat Fuse 7.12 | jdbc-postgresql | RHSA-2023:3954 |
| Red Hat Satellite 6.12 for RHEL 8 | candlepin-0:4.1.20-1.el8sat | RHSA-2023:1630 |
| Red Hat Satellite 6.13 for RHEL 8 | candlepin-0:4.2.13-1.el8sat | RHSA-2023:2097 |
Frequently Asked Questions
Is CVE-2022-41946 in your dependencies?
Find it across Maven, including transitive dependencies.