CVE-2022-41946

CVE-2022-41946 is a medium-severity security vulnerability in org.postgresql:postgresql (maven), affecting versions >= 42.2.0, < 42.2.27. It is fixed in 42.2.27, 42.4.3, 42.5.1, 42.3.8.

Summary

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

Impact

CVE-2022-41946 has a CVSS score of 4.7 (Medium). The vector is requires local access, low privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (42.2.27, 42.4.3, 42.5.1, 42.3.8); upgrading removes the vulnerable code path.

Affected versions

org.postgresql:postgresql (>= 42.2.0, < 42.2.27) org.postgresql:postgresql (>= 42.4.0, < 42.4.3) org.postgresql:postgresql (>= 42.5.0, < 42.5.1) org.postgresql:postgresql (>= 42.3.0, < 42.3.8)

Security releases

org.postgresql:postgresql → 42.2.27 (maven) org.postgresql:postgresql → 42.4.3 (maven) org.postgresql:postgresql → 42.5.1 (maven) org.postgresql:postgresql → 42.3.8 (maven)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

Upgrade the following packages to resolve this vulnerability:

org.postgresql:postgresql to 42.2.27 or later; org.postgresql:postgresql to 42.4.3 or later; org.postgresql:postgresql to 42.5.1 or later; org.postgresql:postgresql to 42.3.8 or later

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently Asked Questions

  1. What is CVE-2022-41946? CVE-2022-41946 is a medium-severity security vulnerability in org.postgresql:postgresql (maven), affecting versions >= 42.2.0, < 42.2.27. It is fixed in 42.2.27, 42.4.3, 42.5.1, 42.3.8.
  2. How severe is CVE-2022-41946? CVE-2022-41946 has a CVSS score of 4.7 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of org.postgresql:postgresql are affected by CVE-2022-41946? org.postgresql:postgresql (maven) versions >= 42.2.0, < 42.2.27 is affected.
  4. Is there a fix for CVE-2022-41946? Yes. CVE-2022-41946 is fixed in 42.2.27, 42.4.3, 42.5.1, 42.3.8. Upgrade to this version or later.
  5. Is CVE-2022-41946 exploitable, and should I be worried? Whether CVE-2022-41946 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2022-41946 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2022-41946?
    • Upgrade org.postgresql:postgresql to 42.2.27 or later
    • Upgrade org.postgresql:postgresql to 42.4.3 or later
    • Upgrade org.postgresql:postgresql to 42.5.1 or later
    • Upgrade org.postgresql:postgresql to 42.3.8 or later

Other vulnerabilities in org.postgresql:postgresql

CVE-2026-42198CVE-2024-1597CVE-2022-41946CVE-2022-31197CVE-2012-1618

Stop the waste.
Protect your environment with Kodem.