CVE-2023-39417

Postgresql: extension script @substitutions@ within quoting allow sql injection

7.5 high EPSS 1.63%

Published 11 Aug 2023 Updated 26 Nov 2026 CNA: redhat

Check your servers for CVE-2023-39417

The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2023-39417 affects postgresql, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.

Check my servers

Description

IN THE EXTENSION SCRIPT, a SQL Injection vulnerability was found in PostgreSQL if it uses @extowner@, @extschema@, or @extschema:...@ inside a quoting construct (dollar quoting, '', or ""). If an administrator has installed files of a vulnerable, trusted, non-bundled extension, an attacker with database-level CREATE privilege can execute arbitrary code as the bootstrap superuser.

Severity (CVSS)

7.5 high CVSS 3.1 from redhat (CNA)
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H
Attack vector
network: an attacker can reach the vulnerable part over the network, often from the internet
Attack complexity
high: an attack depends on conditions outside the control of the attacker, such as a race
Privileges required
low: the attacker needs an ordinary user account
User interaction
none: nobody has to click or open anything
Scope
unchanged: the damage stays inside the vulnerable component
Impact
confidentiality high, integrity high, availability high: what an attacker can read (confidentiality), change (integrity) or stop (availability)

Exploitation

EPSS 1.63%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 76.9% of all scored CVEs. Scores of 1 Dec 2026.

The assessment of CISA (SSVC, 9 Jul 2025):

Exploitation
none: CISA did not find evidence of exploitation or a public proof of concept
Automatable
no: each attack takes manual steps
Technical impact
total: full control of the component or of its data

Weakness

  • CWE-89 Improper Neutralization of Special Elements used in an SQL Command

Affected products

As the CNA lists them.

ProductVersions
Red Hat Advanced Cluster Security 4.2
package advanced-cluster-security/rhacs-central-db-rhel8
unaffected 4.2.4-6 and later
Other versions: affected
Red Hat Advanced Cluster Security 4.2
package advanced-cluster-security/rhacs-main-rhel8
unaffected 4.2.4-6 and later
Other versions: affected
Red Hat Advanced Cluster Security 4.2
package advanced-cluster-security/rhacs-operator-bundle
unaffected 4.2.4-7 and later
Other versions: affected
Red Hat Advanced Cluster Security 4.2
package advanced-cluster-security/rhacs-scanner-db-rhel8
unaffected 4.2.4-6 and later
Other versions: affected
Red Hat Advanced Cluster Security 4.2
package advanced-cluster-security/rhacs-scanner-db-slim-rhel8
unaffected 4.2.4-7 and later
Other versions: affected
Red Hat Enterprise Linux 8
package postgresql:13
unaffected 8090020231114113712.a75119d5 and later
Other versions: affected
Red Hat Enterprise Linux 8
package postgresql:12
unaffected 8090020231128173330.a75119d5 and later
Other versions: affected
Red Hat Enterprise Linux 8
package postgresql:15
unaffected 8090020231114113548.a75119d5 and later
Other versions: affected
Red Hat Enterprise Linux 8.2 Advanced Update Support
package postgresql:12
unaffected 8020020231128165246.4cda2c84 and later
Other versions: affected
Red Hat Enterprise Linux 8.2 Telecommunications Update Service
package postgresql:12
unaffected 8020020231128165246.4cda2c84 and later
Other versions: affected
Red Hat Enterprise Linux 8.2 Update Services for SAP Solutions
package postgresql:12
unaffected 8020020231128165246.4cda2c84 and later
Other versions: affected
Red Hat Enterprise Linux 8.4 Advanced Mission Critical Update Support
package postgresql:12
unaffected 8040020231127153301.522a0ee4 and later
Other versions: affected
Red Hat Enterprise Linux 8.4 Advanced Mission Critical Update Support
package postgresql:13
unaffected 8040020231127154806.522a0ee4 and later
Other versions: affected
Red Hat Enterprise Linux 8.4 Telecommunications Update Service
package postgresql:12
unaffected 8040020231127153301.522a0ee4 and later
Other versions: affected
Red Hat Enterprise Linux 8.4 Telecommunications Update Service
package postgresql:13
unaffected 8040020231127154806.522a0ee4 and later
Other versions: affected
Red Hat Enterprise Linux 8.4 Update Services for SAP Solutions
package postgresql:12
unaffected 8040020231127153301.522a0ee4 and later
Other versions: affected
Red Hat Enterprise Linux 8.4 Update Services for SAP Solutions
package postgresql:13
unaffected 8040020231127154806.522a0ee4 and later
Other versions: affected
Red Hat Enterprise Linux 8.6 Extended Update Support
package postgresql:13
unaffected 8060020231114115246.ad008a3a and later
Other versions: affected
Red Hat Enterprise Linux 8.6 Extended Update Support
package postgresql:12
unaffected 8060020231128165328.ad008a3a and later
Other versions: affected
Red Hat Enterprise Linux 8.8 Extended Update Support
package postgresql:13
unaffected 8080020231114105206.63b34585 and later
Other versions: affected
Red Hat Enterprise Linux 8.8 Extended Update Support
package postgresql:12
unaffected 8080020231128165335.63b34585 and later
Other versions: affected
Red Hat Enterprise Linux 8.8 Extended Update Support
package postgresql:15
unaffected 8080020231113134015.63b34585 and later
Other versions: affected
Red Hat Enterprise Linux 9
package postgresql
unaffected 0:13.13-1.el9_3 and later
Other versions: affected
Red Hat Enterprise Linux 9
package postgresql:15
unaffected 9030020231120082734.rhel9 and later
Other versions: affected
Red Hat Enterprise Linux 9.0 Extended Update Support
package postgresql
unaffected 0:13.13-1.el9_0 and later
Other versions: affected
Red Hat Enterprise Linux 9.2 Extended Update Support
package postgresql:15
unaffected 9020020231115020618.rhel9 and later
Other versions: affected
Red Hat Enterprise Linux 9.2 Extended Update Support
package postgresql
unaffected 0:13.13-1.el9_2 and later
Other versions: affected
Red Hat Software Collections for Red Hat Enterprise Linux 7
package rh-postgresql12-postgresql
unaffected 0:12.17-1.el7 and later
Other versions: affected
Red Hat Software Collections for Red Hat Enterprise Linux 7
package rh-postgresql13-postgresql
unaffected 0:13.13-1.el7 and later
Other versions: affected
RHACS-3.74-RHEL-8
package advanced-cluster-security/rhacs-central-db-rhel8
unaffected 3.74.8-9 and later
Other versions: affected
RHACS-3.74-RHEL-8
package advanced-cluster-security/rhacs-main-rhel8
unaffected 3.74.8-9 and later
Other versions: affected
RHACS-3.74-RHEL-8
package advanced-cluster-security/rhacs-operator-bundle
unaffected 3.74.8-7 and later
Other versions: affected
RHACS-3.74-RHEL-8
package advanced-cluster-security/rhacs-scanner-db-rhel8
unaffected 3.74.8-9 and later
Other versions: affected
RHACS-3.74-RHEL-8
package advanced-cluster-security/rhacs-scanner-db-slim-rhel8
unaffected 3.74.8-9 and later
Other versions: affected
RHACS-4.1-RHEL-8
package advanced-cluster-security/rhacs-central-db-rhel8
unaffected 4.1.6-6 and later
Other versions: affected
RHACS-4.1-RHEL-8
package advanced-cluster-security/rhacs-main-rhel8
unaffected 4.1.6-6 and later
Other versions: affected
RHACS-4.1-RHEL-8
package advanced-cluster-security/rhacs-operator-bundle
unaffected 4.1.6-6 and later
Other versions: affected
RHACS-4.1-RHEL-8
package advanced-cluster-security/rhacs-scanner-db-rhel8
unaffected 4.1.6-6 and later
Other versions: affected
RHACS-4.1-RHEL-8
package advanced-cluster-security/rhacs-scanner-db-slim-rhel8
unaffected 4.1.6-6 and later
Other versions: affected
Red Hat Enterprise Linux 6
package postgresql
unknown the record does not list versions
Red Hat Enterprise Linux 7
package postgresql
unknown the record does not list versions
Red Hat Enterprise Linux 8
package postgresql:10/postgresql
unaffected the record does not list versions
Red Hat Software Collections
package rh-postgresql10-postgresql
affected the record does not list versions

Is my server affected?

Find the installed version of postgresql and compare it with the fixed version of your distribution. Distributions often fix a CVE in a package version of their own, so the version number of the upstream project can mislead.

Debian, Ubuntu

dpkg -l | grep -i postgresql
# packages whose changelog names the CVE (fixed in the installed version)
zgrep -l CVE-2023-39417 /usr/share/doc/*/changelog.Debian.gz
# Ubuntu
pro fix CVE-2023-39417

RHEL, Rocky, Alma, Fedora

rpm -q postgresql
# lists the advisory while the fix is not installed
dnf updateinfo list --cve CVE-2023-39417

Alpine

apk list --installed | grep -i postgresql

With Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:

trivy rootfs --scanners vuln / | grep CVE-2023-39417
trivy image --scanners vuln IMAGE | grep CVE-2023-39417

Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.

References

Advisories

11 more

Other references

Source: the record CVE-2023-39417 of the CVE List (CVE Program), CVE Terms of Use; the CISA KEV catalog and the CISA ADP container; EPSS of FIRST; the CWE catalog of MITRE, CWE Terms of Use. The text of the record is shown as published. Data sources and licences.