Bug 2153399 (CVE-2022-41946)

Summary: CVE-2022-41946 postgresql-jdbc: Information leak of prepared statement data due to insecure temporary file permissions
Product: [Other] Security Response Reporter: Vipul Nair <vinair>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: aileenc, alazarot, anstephe, avibelli, balejosg, bbuckingham, bcourt, bgeorges, bshahu, ccranfor, chazlett, clement.escoffier, cwarfiel, dandread, databases-maint, dkreling, ehelms, emingora, eric.wittmann, fjanus, fmongiar, gjospin, gmalinko, gsmet, hamadhan, hhorak, ibek, jalviso, janstey, jcechace, jnethert, jpavlik, jpechane, jrokos, jsherril, jstastny, jwon, karnsing, kverlaen, kyoshida, lthon, lzap, max.andersen, mhulan, michal.skrivanek, mnovotny, mperina, ngalvin, nmoumoul, orabin, osoukup, pantinor, pcreech, pdelbell, peholase, pgallagh, pjindal, pkubat, praiskup, probinso, rchan, rguimara, rruss, rsvoboda, sadas, sbiarozk, sbonazzo, sdouglas, security-response-team, stuart, ybuenos, ytale, zmiklank
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: postgres 42.2.27.jre7, postgres 42.2.27, postgres 42.3.8, postgres 42.4.3, postgres 42.5.1 Doc Type: If docs needed, set a value
Doc Text:
A flaw was found in org.postgresql. This issue allows the creation of a temporary file when using PreparedStatement.setText(int, InputStream) and PreparedStatemet.setBytea(int, InputStream). This could allow a user to create an unexpected file available to all users, which could end in unexpected behavior.
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-16 15:47:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2153433, 2153442, 2153443, 2153444, 2153445, 2154232, 2157986    
Bug Blocks: 2153385    

Description Vipul Nair 2022-12-14 14:19:25 UTC
PreparedStatement.setText(int, InputStream) and PreparedStatemet.setBytea(int, InputStream)
will create a temporary file if the InputStream is larger than 51k In affected versions a prepared statement using either `PreparedStatement.setText(int, InputStream)` or `PreparedStatemet.setBytea(int, InputStream)` will create a temporary file if the InputStream is larger than 2k. This will create a temporary file which is readable by other users on Unix like systems, but not MacOS.

Comment 1 Vipul Nair 2022-12-14 14:22:42 UTC
Created openas2 tracking bugs for this issue:

Affects: fedora-all [bug 2153420]

Comment 2 Sandipan Roy 2022-12-14 14:49:58 UTC
pgjdbc is an open source postgresql JDBC Driver. In affected versions a prepared statement using either `PreparedStatement.setText(int, InputStream)` or `PreparedStatemet.setBytea(int, InputStream)` will create a temporary file if the InputStream is larger than 2k. This will create a temporary file which is readable by other users on Unix like systems, but not MacOS. 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. 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.7 and higher users: this vulnerability is fixed in 4.5.0. Java 1.6 and lower users: no patch is available. 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 mitigate this vulnerability.

https://github.com/pgjdbc/pgjdbc/commit/9008dc9aade6dbfe4efafcd6872ebc55f4699cf5
https://github.com/pgjdbc/pgjdbc/security/advisories/GHSA-562r-vg33-8x8h
https://lists.debian.org/debian-lts-announce/2022/12/msg00003.html

Comment 3 Sandipan Roy 2022-12-14 15:04:57 UTC
Created postgresql-jdbc tracking bugs for this issue:

Affects: fedora-all [bug 2153433]

Comment 8 errata-xmlrpc 2023-02-14 12:12:09 UTC
This issue has been addressed in the following products:

  Red Hat build of Quarkus

Via RHSA-2023:0758 https://access.redhat.com/errata/RHSA-2023:0758

Comment 9 errata-xmlrpc 2023-02-14 13:09:14 UTC
This issue has been addressed in the following products:

  Red Hat Virtualization Engine 4.4
  Red Hat Virtualization 4 for Red Hat Enterprise Linux 8
  Red Hat Virtualization 4 Tools for Red Hat Enterprise Linux 8

Via RHSA-2023:0759 https://access.redhat.com/errata/RHSA-2023:0759

Comment 10 errata-xmlrpc 2023-02-21 15:41:58 UTC
This issue has been addressed in the following products:

  CEQ 2.13.2-1

Via RHSA-2023:0888 https://access.redhat.com/errata/RHSA-2023:0888

Comment 12 errata-xmlrpc 2023-03-08 14:55:16 UTC
This issue has been addressed in the following products:

  Red Hat build of Quarkus 2.7.7

Via RHSA-2023:1006 https://access.redhat.com/errata/RHSA-2023:1006

Comment 13 errata-xmlrpc 2023-03-09 10:47:04 UTC
This issue has been addressed in the following products:

  RHINT Camel-Q 2.7-1

Via RHSA-2023:1177 https://access.redhat.com/errata/RHSA-2023:1177

Comment 14 errata-xmlrpc 2023-04-04 15:20:01 UTC
This issue has been addressed in the following products:

  Red Hat Satellite 6.12 for RHEL 8

Via RHSA-2023:1630 https://access.redhat.com/errata/RHSA-2023:1630

Comment 16 errata-xmlrpc 2023-04-17 15:24:32 UTC
This issue has been addressed in the following products:

  RHINT Debezium 2.1.4

Via RHSA-2023:1815 https://access.redhat.com/errata/RHSA-2023:1815

Comment 18 errata-xmlrpc 2023-05-03 13:20:15 UTC
This issue has been addressed in the following products:

  Red Hat Satellite 6.13 for RHEL 8

Via RHSA-2023:2097 https://access.redhat.com/errata/RHSA-2023:2097

Comment 19 errata-xmlrpc 2023-05-09 07:38:11 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 9

Via RHSA-2023:2378 https://access.redhat.com/errata/RHSA-2023:2378

Comment 23 errata-xmlrpc 2023-05-16 08:22:13 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2023:2867 https://access.redhat.com/errata/RHSA-2023:2867

Comment 24 Product Security DevOps Team 2023-05-16 15:47:16 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2022-41946

Comment 30 errata-xmlrpc 2023-06-28 15:59:16 UTC
This issue has been addressed in the following products:

  RHINT Camel-K-1.10.1

Via RHSA-2023:3906 https://access.redhat.com/errata/RHSA-2023:3906

Comment 31 errata-xmlrpc 2023-06-29 20:07:54 UTC
This issue has been addressed in the following products:

  Red Hat Fuse 7.12

Via RHSA-2023:3954 https://access.redhat.com/errata/RHSA-2023:3954