# CVE-2022-31197: SQL Injection in ResultSet.refreshRow() with malicious column names in pgjdbc

- Priority: **Prioritise**
- Reason: Public exploit (GitHub, Date unknown)
- Next step: Check applicability and the vendor advisory: no fix release is recorded here
- Status: published
- Published: 2022-08-03 · Modified: 2025-11-03
- Aliases: SUSE-SU-2022:3537-1, SUSE-SU-2022:3541-1, SUSE-SU-2022:3613-1, SUSE-SU-2022:3705-1, RHSA-2023:0318, UBUNTU-CVE-2022-31197, DEBIAN-CVE-2022-31197, DLA-3140-1, CGA-35fq-3q9x-2xgr, CGA-397g-95r7-c8vf, CGA-3j2j-rv6v-g8hc, CGA-3vfp-c8pq-98p3, CGA-4495-r7v3-h8w4, CGA-4crq-8v3w-g2j7, CGA-65xj-cvxw-f25w, CGA-69xg-vgxq-vf74, CGA-6g8m-2xvf-gc4m, CGA-72m9-c3h9-rf7q, CGA-7qc9-pgmh-p35r, CGA-89ff-pjm5-c2c3, CGA-89pg-x4qp-hr64, CGA-8wg4-h7jg-pxq4, CGA-9j3w-cfr5-px8p, CGA-c2gf-gx26-g2cv, CGA-cxmw-7x96-wmwc, CGA-fccr-3435-qv72, CGA-fg4h-hf65-9phv, CGA-fqm5-f9mh-mgcg, CGA-fwrj-xww7-9cr7, CGA-fxxj-v2vr-ww4p, CGA-g6g6-g572-692w, CGA-hcm4-fgpc-rxhf, CGA-j7j2-p77w-cfq5, CGA-jq9q-9rgp-cjjf, CGA-m46m-p6m9-fqfj, CGA-m6fg-fvx3-w64q, CGA-m9wc-cvv3-2wr6, CGA-mqm2-qhj2-q27q, CGA-mwxq-86vf-h79h, CGA-mxxw-9hq8-gqq2, CGA-p45w-hp7r-g2rg, CGA-prx8-hm2q-gjvc, CGA-q3g9-5w84-xj4v, CGA-qch5-3rw3-xjq6, CGA-qh73-p2g4-4g2m, CGA-v7hr-qpg9-6m9r, CGA-vh92-j834-f49h, CGA-vmv6-9c94-f2f9, CGA-wfm2-v7mx-vgh6, CGA-wjj7-9wvq-98hp, CGA-wp8x-8h78-xcwq, CGA-wwx3-m3wf-hjh4, CGA-wx49-pr69-mg24, CGA-xgpx-hcw5-grjj, CGA-xj3j-rrm7-8mv4, CGA-xmqc-xp64-32vj, CGA-3766-6329-r925, CGA-f794-g8q2-xhhh, CGA-fqv6-m5xf-9wf3, BIT-postgresql-jdbc-driver-2022-31197, GHSA-r38f-c4h4-hqq2, ALPINE-CVE-2022-31197
- Record: https://cvemate.com/vulnerability/CVE-2022-31197 · JSON: https://cvemate.com/vulnerability/CVE-2022-31197/json

## Description

```text
PostgreSQL JDBC Driver (PgJDBC for short) allows Java programs to connect to a PostgreSQL database using standard, database independent Java code. The PGJDBC implementation of the `java.sql.ResultRow.refreshRow()` method is not performing escaping of column names so a malicious column name that contains a statement terminator, e.g. `;`, could lead to SQL injection. This could lead to executing additional SQL commands as the application's JDBC user. User applications that do not invoke the `ResultSet.refreshRow()` method are not impacted. User application that do invoke that method are impacted if the underlying database that they are querying via their JDBC application may be under the control of an attacker. The attack requires the attacker to trick the user into executing SQL against a table name who's column names would contain the malicious SQL and subsequently invoke the `refreshRow()` method on the ResultSet. Note that the application's JDBC user and the schema owner need not be the same. A JDBC application that executes as a privileged user querying database schemas owned by potentially malicious less-privileged users would be vulnerable. In that situation it may be possible for the malicious user to craft a schema that causes the application to execute commands as the privileged user. Patched versions will be released as `42.2.26` and `42.4.1`. Users are advised to upgrade. There are no known workarounds for this issue.
```

## Signals

- CVSS: 8 high (v3.1, NVD) CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H
- EPSS: 2.355%, percentile 84.279%, as of 2026-12-04
- Known exploited (KEV): CISA not listed, ENISA not listed, CIRCL not listed
- Ransomware use: none recorded
- Public exploits: 1 (github)

## Affected (first 20 of 72)

- alpine java-postgresql-jdbc (Alpine Linux): \< 42.4.2-r0
- chainguard mariadb-10.11 (Chainguard): \< 10.11.8-r2
- chainguard mariadb-10.11-backup (Chainguard): \< 10.11.8-r2
- chainguard mariadb-10.11-bench (Chainguard): \< 10.11.8-r2
- chainguard mariadb-10.11-client (Chainguard): \< 10.11.8-r2
- chainguard mariadb-10.11-dev (Chainguard): \< 10.11.8-r2
- chainguard mariadb-10.11-doc (Chainguard): \< 10.11.8-r2
- chainguard mariadb-10.11-embedded (Chainguard): \< 10.11.8-r2
- chainguard mariadb-10.11-oci-entrypoint (Chainguard): \< 10.11.8-r2
- chainguard mariadb-10.6 (Chainguard): \< 10.6.18-r2
- chainguard mariadb-10.6-backup (Chainguard): \< 10.6.18-r2
- chainguard mariadb-10.6-bench (Chainguard): \< 10.6.18-r2
- chainguard mariadb-10.6-client (Chainguard): \< 10.6.18-r2
- chainguard mariadb-10.6-dev (Chainguard): \< 10.6.18-r2
- chainguard mariadb-10.6-doc (Chainguard): \< 10.6.18-r2
- chainguard mariadb-10.6-embedded (Chainguard): \< 10.6.18-r2
- chainguard mariadb-10.6-oci-entrypoint (Chainguard): \< 10.6.18-r2
- chainguard mariadb-10.6-test (Chainguard): \< 10.6.18-r2
- chainguard mariadb-11.2 (Chainguard): \< 11.2.3-r2
- chainguard mariadb-11.2-backup (Chainguard): \< 11.2.3-r2

## References (first 20 of 28)

- <https://github.com/pgjdbc/pgjdbc/security/advisories/GHSA-r38f-c4h4-hqq2>
- <https://github.com/pgjdbc/pgjdbc/commit/739e599d52ad80f8dcd6efedc6157859b1a9d637>
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/I6WHUADTZBBQLVHO4YG4XCWDGWBT4LRP/>
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTFE6SV33P5YYU2GNTQZQKQRVR3GYE4S/>
- <https://lists.debian.org/debian-lts-announce/2022/10/msg00009.html>
- <https://lists.debian.org/debian-lts-announce/2024/12/msg00017.html>
- <https://www.suse.com/support/update/announcement/2022/suse-su-20223537-1/>
- <https://bugzilla.suse.com/1202170>
- <https://www.suse.com/security/cve/CVE-2022-31197>
- <https://www.suse.com/support/update/announcement/2022/suse-su-20223541-1/>
- <https://www.suse.com/support/update/announcement/2022/suse-su-20223613-1/>
- <https://www.suse.com/support/update/announcement/2022/suse-su-20223705-1/>
- <https://access.redhat.com/errata/RHSA-2023:0318>
- <https://access.redhat.com/security/updates/classification/#moderate>
- <https://bugzilla.redhat.com/show_bug.cgi?id=2129428>
- <https://security.access.redhat.com/data/csaf/v2/advisories/2023/rhsa-2023_0318.json>
- <https://access.redhat.com/security/cve/CVE-2022-31197>
- <https://www.cve.org/CVERecord?id=CVE-2022-31197>
- <https://nvd.nist.gov/vuln/detail/CVE-2022-31197>
- <https://ubuntu.com/security/CVE-2022-31197>

---

Data as of 2026-12-05T05:10:46.989Z. The priority label is CveMate's own model from public evidence, not an official rating, and it knows nothing about your assets. How labels are decided: https://cvemate.com/faq#priority
